Class: Regexp::Parser
- Inherits:
-
Object
- Object
- Regexp::Parser
- Includes:
- Expression, Expression::UnicodeProperty, Syntax
- Defined in:
- lib/regexp_parser/parser.rb,
lib/regexp_parser/version.rb
Defined Under Namespace
Classes: ParserError, UnknownTokenError, UnknownTokenTypeError
Constant Summary collapse
- VERSION =
'0.4.13'
Constants included from Syntax
Syntax::VERSIONS, Syntax::VERSION_FORMAT, Syntax::VERSION_REGEXP
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Syntax
new, supported?, version_class
Methods included from Expression
Class Method Details
.parse(input, syntax = "ruby/#{RUBY_VERSION}", &block) ⇒ Object
21 22 23 |
# File 'lib/regexp_parser/parser.rb', line 21 def self.parse(input, syntax = "ruby/#{RUBY_VERSION}", &block) new.parse(input, syntax, &block) end |
Instance Method Details
#parse(input, syntax = "ruby/#{RUBY_VERSION}", &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/regexp_parser/parser.rb', line 25 def parse(input, syntax = "ruby/#{RUBY_VERSION}", &block) @nesting = [@root = @node = Root.new((input))] @options_stack = [@root.] @switching_options = false @conditional_nesting = [] Regexp::Lexer.scan(input, syntax) do |token| parse_token token end if block_given? block.call @root else @root end end |