Class: Whittle::Terminal
Overview
Represents an terminal Rule, matching a pattern in the input String
Constant Summary
Constants inherited from Rule
Rule::DUMP_ACTION, Rule::NULL_ACTION
Instance Attribute Summary
Attributes inherited from Rule
#action, #assoc, #components, #name, #prec
Instance Method Summary collapse
-
#scan(source, offset, line) ⇒ Hash
Invoked for terminal rules during lexing, ignored for nonterminal rules.
-
#terminal? ⇒ Boolean
Hard-coded to always return true.
Methods inherited from Rule
#%, #^, #as, #build_parse_table, #skip!
Instance Method Details
#scan(source, offset, line) ⇒ Hash
Invoked for terminal rules during lexing, ignored for nonterminal rules.
Returns nil if nothing is matched.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/whittle/terminal.rb', line 29 def scan(source, offset, line) if match = source.match(@pattern, offset) { :rule => self, :value => match[0], :line => line + match[0].count("\r\n", "\n"), :discarded => @action.equal?(NULL_ACTION) } end end |
#terminal? ⇒ Boolean
Hard-coded to always return true
9 10 11 |
# File 'lib/whittle/terminal.rb', line 9 def terminal? true end |