Class: Electr::BaseRule

Inherits:
Object
  • Object
show all
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

ExpressionRule, RootRule

Instance Method Summary collapse

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

#applyObject

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.

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/electr/parser/rules/base_rule.rb', line 21

def apply
  raise NotImplementedError
end