|
2 | 2 |
|
3 | 3 | grammar SimpleEquations extends Numerals, de.monticore.symbols.BasicSymbols { |
4 | 4 |
|
5 | | - scope ProgramBlock = (Statement ";" | FunctionCall ";" | FunctionDefinition)* (Expression ";")? ; |
| 5 | + symbol scope SimpleEquationCompilationUnit = Name "{" (ProgramBlock | FunctionDefinition )+ "}"; |
| 6 | + scope ProgramBlock = (Statement ";" | FunctionCall ";")* (Expression ";")? ; |
6 | 7 |
|
7 | 8 | interface Statement; |
8 | 9 | interface Expression; |
9 | 10 |
|
10 | | - scope FunctionCall implements Expression, Statement = Name "(" ArgList ")"; |
11 | | - |
| 11 | + FunctionCall implements Expression, Statement = Name "(" ArgList ")"; |
12 | 12 | ArgList = (args:Expression ("," args:Expression)*)?; |
13 | 13 |
|
14 | 14 | symbol scope FunctionDefinition implements Function, Statement = returnType:Name "func" name:Name FormalParameters "{" ProgramBlock "}"; |
15 | | - |
16 | | - FormalParameterListing = (VariableAsParameter | ",")+; |
17 | 15 | FormalParameters = "(" FormalParameterListing? ")"; |
| 16 | + FormalParameterListing = (VariableAsParameter | ",")+; |
| 17 | + VariableAsParameter implements Variable = type:Name Name; |
18 | 18 |
|
19 | 19 | PlusEquation implements Expression = left:Expression "+" right:Expression; |
20 | 20 | MinusEquation implements Expression = left:Expression "-" right:Expression; |
21 | 21 | MultiplyEquation implements Expression = left:Expression "*" right:Expression; |
22 | 22 | DivideEquation implements Expression = left:Expression "/" right:Expression; |
23 | 23 | GreaterThanExpression implements Expression = left:Expression ">" right:Expression; |
24 | 24 |
|
25 | | - symbol VariableDefinition implements Statement, Variable = type:Name Name "=" value:Expression; |
| 25 | + VariableDefinition implements Statement, Variable = type:Name Name "=" value:Expression; |
26 | 26 | VariableUsage implements Statement = Name "=" value:Expression; |
27 | | - VariableAsParameter implements Variable = type:Name Name; |
28 | 27 | PrintStatement implements Statement = "print" "(" Expression ")"; |
29 | 28 | IfStatement implements Statement = "if" "(" condition:Expression ")" "{" thenBlock:ProgramBlock "}" ("else" "{" elseBlock:ProgramBlock "}")?; |
30 | 29 | ReturnStatement implements Statement = "return" Expression; |
|
0 commit comments