Class: RPrec::RegexpLexer
- Inherits:
-
Object
- Object
- RPrec::RegexpLexer
- Defined in:
- lib/rprec/regexp_lexer.rb
Overview
RegexpLexer
is a lexer using regexp patterns.
Instance Attribute Summary collapse
- #block ⇒ Proc readonly
- #pattern ⇒ Regexp readonly
- #skip ⇒ Regexp readonly
Instance Method Summary collapse
-
#initialize(skip:, pattern:, &block) ⇒ RegexpLexer
constructor
A new instance of RegexpLexer.
- #lex(source) ⇒ RPrec::RegexpStream
Constructor Details
#initialize(skip:, pattern:, &block) ⇒ RegexpLexer
Returns a new instance of RegexpLexer.
11 12 13 14 15 |
# File 'lib/rprec/regexp_lexer.rb', line 11 def initialize(skip:, pattern:, &block) @skip = /\G#{skip}/ @pattern = /\G#{pattern}/ @block = block end |
Instance Attribute Details
#block ⇒ Proc (readonly)
24 25 26 |
# File 'lib/rprec/regexp_lexer.rb', line 24 def block @block end |
#pattern ⇒ Regexp (readonly)
22 23 24 |
# File 'lib/rprec/regexp_lexer.rb', line 22 def pattern @pattern end |
#skip ⇒ Regexp (readonly)
20 21 22 |
# File 'lib/rprec/regexp_lexer.rb', line 20 def skip @skip end |
Instance Method Details
#lex(source) ⇒ RPrec::RegexpStream
28 29 30 |
# File 'lib/rprec/regexp_lexer.rb', line 28 def lex(source) RegexpStream.new(self, source) end |