Skip to content

Commit 6440763

Browse files
committed
parser: Allow syntax for chaining methods, remove syntax for extended-class indexing
1 parent e10dff0 commit 6440763

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fusion/core/parser.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,18 @@ local pattern = re.compile([[
197197
(ws 'else' ws {:else: rstatement :})?
198198
|}
199199
200+
function_call_first <-
201+
variable ws
202+
({:has_self: ':' ws {name / r} :} ws)?
203+
function_call_name <-
204+
(& ('.' variable / ':'))
205+
'.'? ws variable? ws
206+
({:has_self: ':' ws {name / r} :} ws)?
200207
function_call <- {| {:type: '' -> 'function_call' :}
201-
((& '@') {:is_method: '' -> true :})? (
202-
(variable / literal) ({:has_self: ':' {name / r} :} ws
203-
{:index_class: ws '<' ws {expression} ws '>' :}? )?
204-
) ws '(' ws function_call_body? ws ')'
208+
((& '@') {:is_self: '' -> true :})? -- the @ at the beginning
209+
{| function_call_first ws '(' ws function_args? ws ')' ws |} -- first call
210+
{| (function_call_name ws '(' ws function_args? ws ')' ws) |}* -- chained
205211
|}
206-
function_call_body <- {:generator: {|
207-
expression_list ws 'for' ws (variable_list / r) ws 'in' ws expression /
208-
variable_list ws 'in' ws expression
209-
|} :} / function_args
210212
function_args <- expression_list?
211213
212214
assignment <- {| {:type: '' -> 'assignment' :}

0 commit comments

Comments
 (0)