Class: Calyx::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/calyx/rule.rb

Overview

Represents a named rule connected to a tree of productions that can be evaluated and a trace which represents where the rule was declared.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, productions, trace) ⇒ Rule

Returns a new instance of Rule.



7
8
9
10
11
# File 'lib/calyx/rule.rb', line 7

def initialize(name, productions, trace)
  @name = name.to_sym
  @productions = productions
  @trace = trace
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/calyx/rule.rb', line 5

def name
  @name
end

#productionsObject (readonly)

Returns the value of attribute productions.



5
6
7
# File 'lib/calyx/rule.rb', line 5

def productions
  @productions
end

#traceObject (readonly)

Returns the value of attribute trace.



5
6
7
# File 'lib/calyx/rule.rb', line 5

def trace
  @trace
end

Instance Method Details

#evaluate(options) ⇒ Object



13
14
15
# File 'lib/calyx/rule.rb', line 13

def evaluate(options)
  productions.evaluate(options)
end