diff --git a/extra/peg/ebnf/ebnf-tests.factor b/extra/peg/ebnf/ebnf-tests.factor index fbf13f69a2..c2c0a50a59 100644 --- a/extra/peg/ebnf/ebnf-tests.factor +++ b/extra/peg/ebnf/ebnf-tests.factor @@ -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 ] 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