Class: Sexpr::Matcher::Reference
- Inherits:
-
Object
- Object
- Sexpr::Matcher::Reference
- Includes:
- Sexpr::Matcher
- Defined in:
- lib/sexpr/matcher/reference.rb
Instance Attribute Summary collapse
-
#grammar ⇒ Object
readonly
Returns the value of attribute grammar.
-
#rule_name ⇒ Object
readonly
Returns the value of attribute rule_name.
Instance Method Summary collapse
- #eat(sexp) ⇒ Object
-
#initialize(rule_name, grammar) ⇒ Reference
constructor
A new instance of Reference.
- #inspect ⇒ Object
- #match?(sexp) ⇒ Boolean
- #rule ⇒ Object
Methods included from Sexpr::Matcher
Constructor Details
#initialize(rule_name, grammar) ⇒ Reference
Returns a new instance of Reference.
9 10 11 12 |
# File 'lib/sexpr/matcher/reference.rb', line 9 def initialize(rule_name, grammar) @rule_name = rule_name @grammar = grammar end |
Instance Attribute Details
#grammar ⇒ Object (readonly)
Returns the value of attribute grammar.
7 8 9 |
# File 'lib/sexpr/matcher/reference.rb', line 7 def grammar @grammar end |
#rule_name ⇒ Object (readonly)
Returns the value of attribute rule_name.
6 7 8 |
# File 'lib/sexpr/matcher/reference.rb', line 6 def rule_name @rule_name end |
Instance Method Details
#eat(sexp) ⇒ Object
22 23 24 |
# File 'lib/sexpr/matcher/reference.rb', line 22 def eat(sexp) rule && rule.eat(sexp) end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/sexpr/matcher/reference.rb', line 26 def inspect "(ref #{rule_name}, #{rule.inspect})" end |
#match?(sexp) ⇒ Boolean
18 19 20 |
# File 'lib/sexpr/matcher/reference.rb', line 18 def match?(sexp) rule && rule.match?(sexp) end |
#rule ⇒ Object
14 15 16 |
# File 'lib/sexpr/matcher/reference.rb', line 14 def rule @rule ||= @grammar[@rule_name] end |