Skip to content

Commit fe89db5

Browse files
committed
Update SimpleEquations.mc4
1 parent e6f791f commit fe89db5

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

monticore-test/01.experiments/interpreter/src/main/grammars/SimpleEquations.mc4

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22

33
grammar SimpleEquations extends Numerals, de.monticore.symbols.BasicSymbols {
44

5-
scope ProgramBlock = (Statement ";" | FunctionCall ";" | FunctionDefinition)* (Expression ";")? ;
5+
symbol scope SimpleEquationCompilationUnit = Name "{" (ProgramBlock | FunctionDefinition )+ "}";
6+
scope ProgramBlock = (Statement ";" | FunctionCall ";")* (Expression ";")? ;
67

78
interface Statement;
89
interface Expression;
910

10-
scope FunctionCall implements Expression, Statement = Name "(" ArgList ")";
11-
11+
FunctionCall implements Expression, Statement = Name "(" ArgList ")";
1212
ArgList = (args:Expression ("," args:Expression)*)?;
1313

1414
symbol scope FunctionDefinition implements Function, Statement = returnType:Name "func" name:Name FormalParameters "{" ProgramBlock "}";
15-
16-
FormalParameterListing = (VariableAsParameter | ",")+;
1715
FormalParameters = "(" FormalParameterListing? ")";
16+
FormalParameterListing = (VariableAsParameter | ",")+;
17+
VariableAsParameter implements Variable = type:Name Name;
1818

1919
PlusEquation implements Expression = left:Expression "+" right:Expression;
2020
MinusEquation implements Expression = left:Expression "-" right:Expression;
2121
MultiplyEquation implements Expression = left:Expression "*" right:Expression;
2222
DivideEquation implements Expression = left:Expression "/" right:Expression;
2323
GreaterThanExpression implements Expression = left:Expression ">" right:Expression;
2424

25-
symbol VariableDefinition implements Statement, Variable = type:Name Name "=" value:Expression;
25+
VariableDefinition implements Statement, Variable = type:Name Name "=" value:Expression;
2626
VariableUsage implements Statement = Name "=" value:Expression;
27-
VariableAsParameter implements Variable = type:Name Name;
2827
PrintStatement implements Statement = "print" "(" Expression ")";
2928
IfStatement implements Statement = "if" "(" condition:Expression ")" "{" thenBlock:ProgramBlock "}" ("else" "{" elseBlock:ProgramBlock "}")?;
3029
ReturnStatement implements Statement = "return" Expression;

0 commit comments

Comments
 (0)