Class: Alf::Lang::Parser::Lispy
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Functional
#Heading, #Relation, #Tuple, def_aggregator_method, def_operator_method
Constructor Details
#initialize(helpers = [], connection = nil) ⇒ Lispy
9
10
11
12
13
14
15
|
# File 'lib/alf/lang/parser/lispy.rb', line 9
def initialize(helpers = [], connection = nil)
@connection = connection
@extensions = helpers
helpers.each do |helper|
helper.send(:extend_object, self)
end
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
16
17
18
|
# File 'lib/alf/lang/parser/lispy.rb', line 16
def connection
@connection
end
|
Class Method Details
.const_missing(name) ⇒ Object
Resolve DUM and DEE in ruby 1.9.2 context
51
52
53
54
55
56
57
58
|
# File 'lib/alf/lang/parser/lispy.rb', line 51
def self.const_missing(name)
case name.to_s
when 'DEE' then ::Alf::Relation::DEE
when 'DUM' then ::Alf::Relation::DUM
else
super
end
end
|
Instance Method Details
#connection! ⇒ Object
18
19
20
21
22
|
# File 'lib/alf/lang/parser/lispy.rb', line 18
def connection!
connection.tap{|c|
::Kernel.raise(UnboundError, "#{self} not bound") unless c
}
end
|
#inspect ⇒ Object
37
38
39
|
# File 'lib/alf/lang/parser/lispy.rb', line 37
def inspect
"Lispy(#{@extensions.inspect})"
end
|
#parse(expr = nil, path = nil, line = nil, &block) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/alf/lang/parser/lispy.rb', line 24
def parse(expr = nil, path = nil, line = nil, &block)
if (expr && block) || (expr.nil? and block.nil?)
raise ArgumentError, "Either `expr` or `block` should be specified"
end
expr = evaluate(expr, path, line, &block) if block or expr.is_a?(String)
expr = __send__(expr) if expr.is_a?(Symbol)
expr
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/alf/lang/parser/lispy.rb', line 33
def to_s
"Lispy(#{@extensions.map(&:name).compact.join(',')})"
end
|