Class: Spectre::SymParser
- Inherits:
-
Object
- Object
- Spectre::SymParser
- Includes:
- Parser
- Defined in:
- lib/spectre/base/grammar.rb
Overview
Provides lazy evaluation of the Parser name, so you can use it recursively and before specifying it.
Instance Attribute Summary
Attributes included from Parser
Instance Method Summary collapse
-
#initialize(sym) ⇒ SymParser
constructor
Initializes the SymParser to look for
sym
. - #inspect ⇒ Object
- #scan(is) ⇒ Object
Methods included from Parser
#backtrack, #create_match, from_POD, #pre_skip?, #to_p
Constructor Details
#initialize(sym) ⇒ SymParser
Initializes the SymParser to look for sym
.
37 38 39 |
# File 'lib/spectre/base/grammar.rb', line 37 def initialize sym @sym = sym end |
Instance Method Details
#inspect ⇒ Object
48 49 50 |
# File 'lib/spectre/base/grammar.rb', line 48 def inspect "[<#{@sym.inspect}>]" end |
#scan(is) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/spectre/base/grammar.rb', line 41 def scan is n = @node.find @sym raise "rule #{@sym.inspect} not found." unless n n.parent = @node n.parse is end |