Class: Flexr::Regexp::Parser
- Inherits:
-
Object
- Object
- Flexr::Regexp::Parser
- Defined in:
- lib/flexr/regexp/parser.rb
Constant Summary collapse
- ESCAPES =
{ "n" => 0x0a, "t" => 0x09, "r" => 0x0d, "f" => 0x0c, "v" => 0x0b, "a" => 0x07, "e" => 0x1b, "0" => 0 }.freeze
- PROPERTY_ALIASES =
{ "digit" => "Nd", "alpha" => "Alphabetic", "alnum" => "Alnum", "word" => "Word", "space" => "Space" }.freeze
- POSIX_CLASSES =
%w[alnum alpha blank cntrl digit graph lower print punct space upper xdigit].freeze
- LITERAL_ESCAPES =
(%w[. [ ] { } ( ) * + ? | ^ $ \\ / - #] + [" "]).freeze
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, options: 0, encoding: Encoding::UTF_8, unicode: false) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source, options: 0, encoding: Encoding::UTF_8, unicode: false) ⇒ Parser
Returns a new instance of Parser.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flexr/regexp/parser.rb', line 19 def initialize(source, options: 0, encoding: Encoding::UTF_8, unicode: false) @source = source @options = @encoding = encoding @unicode = unicode @index = 0 @class_depth = 0 offset = 0 @byte_offsets = [0] source.each_char do |character| offset += character.bytesize @byte_offsets << offset end end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
17 18 19 |
# File 'lib/flexr/regexp/parser.rb', line 17 def source @source end |
Instance Method Details
#parse ⇒ Object
34 35 36 37 38 39 |
# File 'lib/flexr/regexp/parser.rb', line 34 def parse node = parse_expression raise_syntax("unexpected `#{current}`") unless eof? validate_anchor_positions(node) node end |