Skip to content
Snippets Groups Projects
Commit 95c73d6e authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Improved grammar with example

parent eb58e8c4
No related branches found
No related tags found
No related merge requests found
......@@ -5,12 +5,33 @@ import java.util.Collection;
class TestClass extends AbstractTestClass {
private String name;
private String name = "fdhjls";
private String familyName = "fdhjls";
public void hello(String name, int num) {
// if
if (this.name) {
// assignment
familyName = "fdjsklø";
}
// while
while (age) {
// feature call
this.name(age);
}
// do/while
do {
} while (age);
// for
for (int a; a; a++) {
}
// foreach
for (int a : b) {
}
}
private int age;
private int age = 54;
}
\ No newline at end of file
......@@ -86,7 +86,7 @@ ParameterDeclaration:
// Statements
Statement:
BlockStatement | EmptyStatement | VariablesDeclaration | Assignment | FeatureStatement |
BlockStatement | EmptyStatement | VariablesDeclaration | AssignmentStatement | FeatureStatement |
IfStatement | WhileStatement | DoWhileStatement | ForStatement
;
......@@ -132,6 +132,10 @@ Assignment:
(varDecl = [AssignmentTarget | ID] (ASSIGN_OP expr = Expression)) |
(varDecl = [AssignmentTarget | ID] PRE_POST_ASSIGN_OP)
)
;
AssignmentStatement:
assignment = Assignment
';'
;
......@@ -153,11 +157,6 @@ DoWhileStatement:
'while' '(' condition = Expression ')' ';'
;
XForStatement:
'for' '(' initStatement = VariablesDeclaration condition = Expression ';' stepStatement = Assignment')'
bodyStatement = Statement
;
ForStatement:
'for' '('
type = TypeReference name = ID
......@@ -166,7 +165,7 @@ ForStatement:
(':' forEachInitializer = Expression) |
(
('=' initializer = Expression)?
otherVars += VariableDeclarationPart (',' otherVars += VariableDeclarationPart)* ';'
(otherVars += VariableDeclarationPart (',' otherVars += VariableDeclarationPart)*)? ';'
condition = Expression ';' assign = Assignment
)
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment