1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
%%%
%% Section 15.8: Primary Expressions
%%
%% @author Martin Bravenboer <martin@cs.uu.nl>
%%%
module languages/java-14/expressions/Primary
imports
languages/java-14/lexical/literals/Main
languages/java-14/names/Main
languages/java-14/expressions/Main
exports
%%%
%% Section 15.8.1: Lexical Literals
%%%
sorts Literal
context-free syntax
Literal -> Expr {cons("Lit")}
IntLiteral -> Literal
FloatLiteral -> Literal
BoolLiteral -> Literal
CharLiteral -> Literal
StringLiteral -> Literal
NullLiteral -> Literal
%%%
%% Section 15.8.2: Class Literals
%%%
sorts ClassLiteral
context-free syntax
ClassLiteral -> Literal
Type "." "class" -> ClassLiteral {cons("Class")}
"void" "." "class" -> ClassLiteral {cons("VoidClass")}
%%%
%% Section 15.8.3/4: (Qualified this)
%%%
context-free syntax
"this" -> Expr {cons("This")}
ClassName "." "this" -> Expr {cons("QThis")}
%%%
%% Section 15.8.5: Parenthesized Expression
%%%
context-free syntax
"(" Expr ")" -> Expr {bracket}
|