Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xjava-example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TDT4250
2021
xjava-example
Commits
95c73d6e
Commit
95c73d6e
authored
3 years ago
by
Hallvard Trætteberg
Browse files
Options
Downloads
Patches
Plain Diff
Improved grammar with example
parent
eb58e8c4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tdt4250.xjava.examples/examples/TestClass.xjava
+25
-4
25 additions, 4 deletions
tdt4250.xjava.examples/examples/TestClass.xjava
tdt4250.xjava/src/tdt4250/Xjava.xtext
+6
-7
6 additions, 7 deletions
tdt4250.xjava/src/tdt4250/Xjava.xtext
with
31 additions
and
11 deletions
tdt4250.xjava.examples/examples/TestClass.xjava
+
25
−
4
View file @
95c73d6e
...
...
@@ -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
This diff is collapsed.
Click to expand it.
tdt4250.xjava/src/tdt4250/Xjava.xtext
+
6
−
7
View file @
95c73d6e
...
...
@@ -86,7 +86,7 @@ ParameterDeclaration:
// Statements
Statement:
BlockStatement | EmptyStatement | VariablesDeclaration | Assignment | FeatureStatement |
BlockStatement | EmptyStatement | VariablesDeclaration | Assignment
Statement
| 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
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment