Class: LexerKit::DFA::RegexAST::Regex
- Inherits:
-
Data
- Object
- Data
- LexerKit::DFA::RegexAST::Regex
- Defined in:
- lib/lexer_kit/dfa/regex_ast.rb
Overview
Complete regex pattern with flags Wraps an AST node with pattern-level settings
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#case_insensitive ⇒ Object
readonly
Returns the value of attribute case_insensitive.
Class Method Summary collapse
-
.parse(pattern) ⇒ Regex
Parse a pattern into Regex.
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast
44 45 46 |
# File 'lib/lexer_kit/dfa/regex_ast.rb', line 44 def ast @ast end |
#case_insensitive ⇒ Object (readonly)
Returns the value of attribute case_insensitive
44 45 46 |
# File 'lib/lexer_kit/dfa/regex_ast.rb', line 44 def case_insensitive @case_insensitive end |
Class Method Details
.parse(pattern) ⇒ Regex
Parse a pattern into Regex
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/lexer_kit/dfa/regex_ast.rb', line 48 def self.parse(pattern) case pattern when self pattern when LexerKit::RegexAstProvider pattern.to_regex else source = pattern.is_a?(Regexp) ? pattern.source : pattern case_insensitive = pattern.is_a?(Regexp) && pattern.casefold? ast = RegexParser.new(source).parse new(ast: ast, case_insensitive: case_insensitive) end end |