mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 02:08:04 +00:00
Merge branch 'refs/heads/main' into testsuites
This commit is contained in:
commit
db80632604
@ -4,7 +4,8 @@ program : (class)+;
|
||||
|
||||
class : PUBLIC? 'class' id '{' (var | meth)* '}';
|
||||
|
||||
var : type id ';' | type id '=' expr';';
|
||||
var : type id ';' | type id assignSign expr';';
|
||||
assignSign : '=' | '+=' | '-=' | '*=';
|
||||
returntype : type | VOID;
|
||||
type : INT | BOOL | CHAR;
|
||||
|
||||
@ -26,23 +27,29 @@ stmt : 'if' '(' expr ')' block ('else' block)? #If
|
||||
| stmtexpr #StatementExpressionstmt
|
||||
;
|
||||
|
||||
stmtexpr : id '=' expr ';' #Assign
|
||||
stmtexpr : id assignSign expr ';' #Assignment
|
||||
| methCall ';' #MethodCall
|
||||
| NEW type '(' args? ')' #New
|
||||
;
|
||||
|
||||
expr : expr binaryOp expr #BinaryOperation
|
||||
| unaryOp expr #UnaryOperation
|
||||
| literal #Constant
|
||||
| '(' expr ')' #Expression
|
||||
| methCall #MethodCallExpression
|
||||
| id #Identifier
|
||||
| fieldId #Identifier
|
||||
| stmtexpr #StatementExpressionexpr
|
||||
| NULL #Null
|
||||
;
|
||||
|
||||
binaryOp : ADD | SUB | MUL | GT | LT | GE | LE | EQ | NE | AND | OR | NOT;
|
||||
unaryOp : SUB | NOT;
|
||||
|
||||
fieldId : ('this' '.')? (recipient '.')* id;
|
||||
|
||||
methCall : id '(' args? ')';
|
||||
methCall : ('this' '.')? (recipient '.')* methName;
|
||||
recipient : methName | id;
|
||||
methName : id '(' args? ')';
|
||||
args : expr (',' expr)*;
|
||||
|
||||
literal : NUMBER | BOOLEANLITERAL | CHARLITERAL;
|
||||
@ -52,6 +59,7 @@ id : IDENTIFIER;
|
||||
|
||||
PUBLIC : 'public';
|
||||
NEW : 'new';
|
||||
NULL : 'null';
|
||||
|
||||
SUB : '-';
|
||||
ADD : '+';
|
||||
@ -64,6 +72,7 @@ EQ : '==';
|
||||
NE : '!=';
|
||||
AND : '&&';
|
||||
OR : '||';
|
||||
|
||||
NOT : '!';
|
||||
|
||||
INT : 'int';
|
||||
|
@ -11,6 +11,5 @@ public enum Operator {
|
||||
EQ,
|
||||
NE,
|
||||
AND,
|
||||
OR,
|
||||
NOT
|
||||
OR
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user