Class: Packrat::RegexpLiteral

Inherits:
GrammarElement show all
Defined in:
lib/packrat/grammar.rb,
lib/packrat/grammar.rb

Direct Known Subclasses

StringLiteral

Instance Attribute Summary

Attributes inherited from GrammarElement

#hidden

Instance Method Summary collapse

Methods inherited from GrammarElement

#to_packrat_grammar_element

Constructor Details

#initialize(re) ⇒ RegexpLiteral

Returns a new instance of RegexpLiteral.



50
51
52
# File 'lib/packrat/grammar.rb', line 50

def initialize(re)
  @re = re
end

Instance Method Details

#inspectObject



53
# File 'lib/packrat/grammar.rb', line 53

def inspect; @re.inspect; end

#parse(parser) ⇒ Object



530
531
532
533
534
# File 'lib/packrat/grammar.rb', line 530

def parse(parser)
  oldpos = parser.pos
  len = parser.skip(@re)
  len ? parser.lexeme(oldpos, len) : false
end