Class: SexpGrammar::Terminal

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/sexp_grammar/terminal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#valueObject (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

#inspectObject



11
12
13
# File 'lib/sexp_grammar/terminal.rb', line 11

def inspect
  "(terminal #{value.inspect})"
end

#match?(sexp) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/sexp_grammar/terminal.rb', line 15

def match?(sexp)
  terminal_match?(sexp)
end