EBNF test using Java Primary production
parent
25eea7ea1b
commit
7bf27a5eb2
|
@ -162,3 +162,47 @@ IN: peg.ebnf.tests
|
||||||
"1+1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call parse-result-ast
|
"1+1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call parse-result-ast
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
EBNF: primary
|
||||||
|
Primary = PrimaryNoNewArray
|
||||||
|
PrimaryNoNewArray = ClassInstanceCreationExpression
|
||||||
|
| MethodInvocation
|
||||||
|
| FieldAccess
|
||||||
|
| ArrayAccess
|
||||||
|
| "this"
|
||||||
|
ClassInstanceCreationExpression = "new" ClassOrInterfaceType "(" ")"
|
||||||
|
| Primary "." "new" Identifier "(" ")"
|
||||||
|
MethodInvocation = Primary "." MethodName "(" ")"
|
||||||
|
| MethodName "(" ")"
|
||||||
|
FieldAccess = Primary "." Identifier
|
||||||
|
| "super" "." Identifier
|
||||||
|
ArrayAccess = Primary "[" Expression "]"
|
||||||
|
| ExpressionName "[" Expression "]"
|
||||||
|
ClassOrInterfaceType = ClassName | InterfaceTypeName
|
||||||
|
ClassName = "C" | "D"
|
||||||
|
InterfaceTypeName = "I" | "J"
|
||||||
|
Identifier = "x" | "y" | ClassOrInterfaceType
|
||||||
|
MethodName = "m" | "n"
|
||||||
|
ExpressionName = Identifier
|
||||||
|
Expression = "i" | "j"
|
||||||
|
main = Primary
|
||||||
|
;EBNF
|
||||||
|
|
||||||
|
{ "this" } [
|
||||||
|
"this" primary parse-result-ast
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ V{ "this" "." "x" } } [
|
||||||
|
"this.x" primary parse-result-ast
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ V{ V{ "this" "." "x" } "." "y" } } [
|
||||||
|
"this.x.y" primary parse-result-ast
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ V{ V{ "this" "." "x" } "." "m" "(" ")" } } [
|
||||||
|
"this.x.m()" primary parse-result-ast
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ V{ V{ V{ "x" "[" "i" "]" } "[" "j" "]" } "." "y" } } [
|
||||||
|
"x[i][j].y" primary parse-result-ast
|
||||||
|
] unit-test
|
||||||
|
|
Loading…
Reference in New Issue