Class: SexpGrammar::Terminal
- Inherits:
-
Object
- Object
- SexpGrammar::Terminal
- Includes:
- Element
- Defined in:
- lib/sexp_grammar/terminal.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eat(sexp) ⇒ Object
-
#initialize(value) ⇒ Terminal
constructor
A new instance of Terminal.
- #inspect ⇒ Object
- #match?(sexp) ⇒ Boolean
Methods included from Element
Constructor Details
#initialize(value) ⇒ Terminal
Returns a new instance of Terminal.
7 8 9 |
# File 'lib/sexp_grammar/terminal.rb', line 7 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/sexp_grammar/terminal.rb', line 5 def value @value end |
Instance Method Details
#eat(sexp) ⇒ Object
19 20 21 |
# File 'lib/sexp_grammar/terminal.rb', line 19 def eat(sexp) match?(sexp.first) ? sexp[1..-1] : nil end |
#inspect ⇒ Object
11 12 13 |
# File 'lib/sexp_grammar/terminal.rb', line 11 def inspect "(terminal #{value.inspect})" end |
#match?(sexp) ⇒ Boolean
15 16 17 |
# File 'lib/sexp_grammar/terminal.rb', line 15 def match?(sexp) terminal_match?(sexp) end |