Class: SexpGrammar::Grammar
- Inherits:
-
Object
- Object
- SexpGrammar::Grammar
- Defined in:
- lib/sexp_grammar/grammar.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #[](rule_name) ⇒ Object
-
#initialize(rules = {}, root = rules.keys.first) ⇒ Grammar
constructor
A new instance of Grammar.
- #match?(sexp) ⇒ Boolean (also: #===)
Constructor Details
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
4 5 6 |
# File 'lib/sexp_grammar/grammar.rb', line 4 def rules @rules end |
Instance Method Details
#[](rule_name) ⇒ Object
11 12 13 |
# File 'lib/sexp_grammar/grammar.rb', line 11 def [](rule_name) @rules[rule_name] end |
#match?(sexp) ⇒ Boolean Also known as: ===
15 16 17 |
# File 'lib/sexp_grammar/grammar.rb', line 15 def match?(sexp) @root.match?(sexp) end |