Class: Electr::BaseRule
- Inherits:
-
Object
- Object
- Electr::BaseRule
- Defined in:
- lib/electr/parser/rules/base_rule.rb
Overview
Base class for the rules. «Just» follow the grammar’s rules to produce the AST.
Direct Known Subclasses
Instance Method Summary collapse
-
#apply ⇒ Object
Public: Apply the rule to the list of lexical units, creating and/or modifying the ast node.
-
#initialize(units, ast_node) ⇒ BaseRule
constructor
Initialize a new rule.
Constructor Details
#initialize(units, ast_node) ⇒ BaseRule
Initialize a new rule. The units and ast_node objects given in arguments will be modified by #apply.
units - Array of LexicalUnits. ast_node - An AST object, for adding children, etc.
12 13 14 15 16 |
# File 'lib/electr/parser/rules/base_rule.rb', line 12 def initialize(units, ast_node) @units = units @ast_node = ast_node @series = [] end |
Instance Method Details
#apply ⇒ Object
Public: Apply the rule to the list of lexical units, creating and/or modifying the ast node. #apply modify the units and ast_node objects given to #initialize.
21 22 23 |
# File 'lib/electr/parser/rules/base_rule.rb', line 21 def apply raise NotImplementedError end |