Module: Strling::Core
- Defined in:
- lib/strling/core/ir.rb,
lib/strling/core/nodes.rb,
lib/strling/core/errors.rb,
lib/strling/core/parser.rb,
lib/strling/core/compiler.rb,
lib/strling/core/validator.rb,
lib/strling/core/hint_engine.rb
Defined Under Namespace
Classes: Alt, Anchor, Backref, CharClass, ClassEscape, ClassItem, ClassLiteral, ClassRange, Compiler, Cursor, Dot, Esc, Flags, Group, IRAlt, IRAnchor, IRBackref, IRCharClass, IRClassEscape, IRClassItem, IRClassLiteral, IRClassRange, IRDot, IRGroup, IRLit, IRLook, IROp, IRQuant, IRSeq, Lit, Look, Node, Parser, Quant, STRlingParseError, Seq, Validator
Constant Summary collapse
- ParseError =
Alias for backward compatibility
STRlingParseError
Class Method Summary collapse
-
.compile(node) ⇒ Object
Module-level compile function for convenience.
-
.get_hint(message, text, pos) ⇒ String?
Generate a helpful hint for a parse error.
-
.parse(text) ⇒ Object
Module-level parse function for convenience.
-
.validate(node, flags) ⇒ Object
Module-level validate function for convenience.
Class Method Details
.compile(node) ⇒ Object
Module-level compile function for convenience
92 93 94 |
# File 'lib/strling/core/compiler.rb', line 92 def self.compile(node) Compiler.compile(node) end |
.get_hint(message, text, pos) ⇒ String?
Generate a helpful hint for a parse error
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/strling/core/hint_engine.rb', line 17 def self.get_hint(, text, pos) # Extract key parts of the error message case when /Invalid quantifier/ "Quantifiers (*, +, ?, {m,n}) must follow something to repeat. They can't appear at the start of a pattern or immediately after another quantifier." when /Cannot quantify anchor/ "Anchors (^, $, \\b, \\B, etc.) match positions, not characters, so they can't be repeated with quantifiers like * or +." when /Unclosed/ "Make sure every opening bracket has a matching closing bracket. Check for: ( ), [ ], { }" when /Unmatched/ "This closing bracket doesn't have a matching opening bracket. Did you mean to escape it?" when /Unknown escape sequence/ "This escape sequence isn't recognized. Common escapes include: \\n (newline), \\t (tab), \\d (digit), \\w (word character), \\s (whitespace)." when /Invalid flag/ "Valid flags are: i (case-insensitive), m (multiline), s (dotall), u (unicode), x (extended/free-spacing)." when /Alternation lacks/ "Alternation (|) requires a pattern on both sides. Example: 'cat|dog', not 'cat|' or '|dog'." when /Unexpected trailing input/ "The pattern ended but there's still input remaining. Check for extra characters or unmatched brackets." when /Directive after pattern content/ "Directives like %flags must appear before the pattern content, not after." else nil end end |