%%%
%% Section 15.12: Method Invocation Expressions
%%
%% @author Martin Bravenboer <martin.bravenboer@gmail.com>
%%%
module languages/java-15/expressions/MethodInvocation
imports
languages/java-15/expressions/Main
exports
sorts MethodSpec
context-free syntax
MethodSpec "(" {Expr ","}* ")" -> Expr {cons("Invoke")}
MethodName -> MethodSpec {cons("Method")}
Expr "." TypeArgs? Id -> MethodSpec {cons("Method")}
"super" "." TypeArgs? Id -> MethodSpec {cons("SuperMethod")}
TypeName "." "super" "." TypeArgs? Id -> MethodSpec {cons("QSuperMethod")}
AmbName "." TypeArgs Id -> MethodSpec {cons("GenericMethod")}
%% This priority forbids a Expr "." MethodSpec if the expression is a plain ExprName.
%% This solves an ambiguity with the MethodName and AmbName . TypeArgs MethodSpecs.
%% foo.bar.fred() results in a MethodName MethodSpec.
%% (foo.bar).fred() results in the Expr. MethodSpec
%% foo.bar.<T>fred() results in a GenericMethod
context-free priorities
Expr "." TypeArgs? Id -> MethodSpec
> ExprName -> Expr