fix call site and now seperated assignment (was bunged as operator)

This commit is contained in:
Torsten Ruger 2015-10-09 17:27:22 +03:00
parent c9942ec516
commit 7f2f64c713
13 changed files with 68 additions and 67 deletions

View File

@ -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 >>

View File

@ -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))

View File

@ -0,0 +1,5 @@
name = 10
-- -- --
s(:assignment,
s(:name, :name),
s(:int, 10))

View File

@ -1,8 +1,7 @@
puts(3 , a )
-- -- --
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 3),
s(:name, :a))))
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 3),
s(:name, :a)))

View File

@ -1,8 +1,7 @@
baz(42, foo)
-- -- --
s(:expressions,
s(:call,
s(:name, :baz),
s(:arguments,
s(:int, 42),
s(:name, :foo))))
s(:call,
s(:name, :baz),
s(:arguments,
s(:int, 42),
s(:name, :foo)))

View File

@ -1,7 +1,6 @@
puts( "hello")
-- -- --
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:string, "hello"))))
s(:call,
s(:name, :puts),
s(:arguments,
s(:string, "hello")))

View File

@ -1,8 +1,7 @@
42.put()
-- -- --
s(:expressions,
s(:call,
s(:name, :put),
s(:arguments),
s(:receiver,
s(:int, 42))))
s(:call,
s(:name, :put),
s(:arguments),
s(:receiver,
s(:int, 42)))

View File

@ -1,7 +1,6 @@
puts( 5)
-- -- --
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 5))))
s(:call,
s(:name, :puts),
s(:arguments,
s(:int, 5)))

View File

@ -1,7 +1,6 @@
foo(42)
-- -- --
s(:expressions,
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42))))
s(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)))

View File

@ -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(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:class_name, :Object)))

View File

@ -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(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, :my_my)))

View File

@ -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(:call,
s(:name, :foo),
s(:arguments,
s(:int, 42)),
s(:receiver,
s(:name, :self)))

View File

@ -1,8 +1,7 @@
"hello".puts()
-- -- --
s(:expressions,
s(:call,
s(:name, :puts),
s(:arguments),
s(:receiver,
s(:string, "hello"))))
s(:call,
s(:name, :puts),
s(:arguments),
s(:receiver,
s(:string, "hello")))