fix call site and now seperated assignment (was bunged as operator)
This commit is contained in:
parent
c9942ec516
commit
7f2f64c713
@ -2,9 +2,12 @@ module Parser
|
||||
module CallSite
|
||||
include Parslet
|
||||
|
||||
rule(:field_access) { name.as(:receiver) >> str(".") >> name.as(:field) }
|
||||
rule(:r_value) { operator_value | call_site | field_access | basic_type }
|
||||
|
||||
rule(:r_value) { call_site | field_access | basic_type }
|
||||
rule(:assign) { str('=') >> space?}
|
||||
rule(:assignment){ (field_access|name).as(:l_value) >> assign.as(:assign) >> r_value.as(:r_value) }
|
||||
|
||||
rule(:field_def) { type >> name >> (assign >> r_value.as(:value) ).maybe}
|
||||
|
||||
rule(:argument_list) {
|
||||
left_parenthesis >>
|
||||
|
@ -1,6 +1,9 @@
|
||||
a = 5
|
||||
self.a = 5
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:assign,
|
||||
s(:name, :a),
|
||||
s(:int, 5)))
|
||||
s(:assignment,
|
||||
s(:field_access,
|
||||
s(:receiver,
|
||||
s(:name, :self)),
|
||||
s(:field,
|
||||
s(:name, :a))),
|
||||
s(:int, 5))
|
||||
|
5
test/cases/assignment/name.tst
Normal file
5
test/cases/assignment/name.tst
Normal file
@ -0,0 +1,5 @@
|
||||
name = 10
|
||||
-- -- --
|
||||
s(:assignment,
|
||||
s(:name, :name),
|
||||
s(:int, 10))
|
@ -1,8 +1,7 @@
|
||||
puts(3 , a )
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :puts),
|
||||
s(:arguments,
|
||||
s(:int, 3),
|
||||
s(:name, :a))))
|
||||
s(:name, :a)))
|
||||
|
@ -1,8 +1,7 @@
|
||||
baz(42, foo)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :baz),
|
||||
s(:arguments,
|
||||
s(:int, 42),
|
||||
s(:name, :foo))))
|
||||
s(:name, :foo)))
|
||||
|
@ -1,7 +1,6 @@
|
||||
puts( "hello")
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :puts),
|
||||
s(:arguments,
|
||||
s(:string, "hello"))))
|
||||
s(:string, "hello")))
|
||||
|
@ -1,8 +1,7 @@
|
||||
42.put()
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :put),
|
||||
s(:arguments),
|
||||
s(:receiver,
|
||||
s(:int, 42))))
|
||||
s(:int, 42)))
|
||||
|
@ -1,7 +1,6 @@
|
||||
puts( 5)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :puts),
|
||||
s(:arguments,
|
||||
s(:int, 5))))
|
||||
s(:int, 5)))
|
||||
|
@ -1,7 +1,6 @@
|
||||
foo(42)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :foo),
|
||||
s(:arguments,
|
||||
s(:int, 42))))
|
||||
s(:int, 42)))
|
||||
|
@ -1,9 +1,8 @@
|
||||
Object.foo(42)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :foo),
|
||||
s(:arguments,
|
||||
s(:int, 42)),
|
||||
s(:receiver,
|
||||
s(:module, "Object"))))
|
||||
s(:class_name, :Object)))
|
||||
|
@ -1,9 +1,8 @@
|
||||
my_my.foo(42)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :foo),
|
||||
s(:arguments,
|
||||
s(:int, 42)),
|
||||
s(:receiver,
|
||||
s(:name, :my_my))))
|
||||
s(:name, :my_my)))
|
||||
|
@ -1,9 +1,8 @@
|
||||
self.foo(42)
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :foo),
|
||||
s(:arguments,
|
||||
s(:int, 42)),
|
||||
s(:receiver,
|
||||
s(:name, :self))))
|
||||
s(:name, :self)))
|
||||
|
@ -1,8 +1,7 @@
|
||||
"hello".puts()
|
||||
-- -- --
|
||||
s(:expressions,
|
||||
s(:call,
|
||||
s(:name, :puts),
|
||||
s(:arguments),
|
||||
s(:receiver,
|
||||
s(:string, "hello"))))
|
||||
s(:string, "hello")))
|
||||
|
Loading…
Reference in New Issue
Block a user