fun submain(args string[]) int {
123
}
+ # UFCS call (call regular function like a method)
foo.bar()
+# foo.bar.baz()
+ # Struct/Union field access
+ foo.bar
+# foo.bar.baz
}
exp = constant(p);
}
- /* determine if this is a function call */
- if (matches(p, '(')) {
- exp = Apply(exp, expr_list(p, '(', ')'));
- } else if (accept(p, '.')) {
- AST* func = identifier(p);
- AST* args = expr_list(p, '(', ')');
- explist_prepend(args, exp);
- exp = Apply(func, args);
- }
+ /* check for member reference or UFCS call */
+ AST *member = NULL, *args = NULL;
+ if (accept(p, '.'))
+ member = identifier(p);
+ if (matches(p, '('))
+ args = expr_list(p, '(', ')');
+
+ if (member && !args)
+ exp = exp; // ??? AST for struct reference
+ else if (member && args)
+ exp = Apply(member, args);
+ else if (!member && args)
+ exp = args;
return exp;
}