96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/testml/compiler/lite.rb', line 96
def parse_expression
calls = []
while !done and peek !~ /^(#{ENDING}|#{COMP})$/ do
token = pop
if token =~ /^#{NUM}$/
calls.push TestML::Num.new(token.to_i)
elsif token =~ /^#{QSTR}$/
str = token[1..-2]
calls.push TestML::Str.new(str)
elsif token =~ /^#{WORD}$/
call = TestML::Call.new(token)
if !done and peek == '('
call.args = parse_args
end
calls.push call
elsif token =~ /^#{POINT}$/
token =~ /(#{WORD})/ or fail
points.push $1
calls.push TestML::Point.new($1)
else
fail_("Unknown token '#{token}'")
end
if !done and peek == '.'
pop
end
end
return calls.size == 1 \
? calls[0]
: TestML::Expression.new(calls)
end
|