mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2025-02-16 13:53:18 +00:00
Fix records and Decaf
This commit is contained in:
parent
9566823ad1
commit
d9182e369d
src/main
@ -6,9 +6,10 @@ class : PUBLIC? 'class' id '{' (var | meth)* '}';
|
||||
|
||||
var : type id ';' | type id '=' expr';';
|
||||
returntype : type | VOID;
|
||||
type : INT | BOOL;
|
||||
type : INT | BOOL | CHAR;
|
||||
|
||||
meth : PUBLIC? 'static'? returntype id '(' params? ')' block;
|
||||
meth : PUBLIC? 'static'? returntype id '(' params? ')' block | mainmeth;
|
||||
mainmeth : PUBLIC 'static' 'void' 'main' '(' params? ')' block;
|
||||
params : param (',' param)*;
|
||||
param : type id;
|
||||
|
||||
@ -59,7 +60,7 @@ ADD : '+';
|
||||
MUL : '*';
|
||||
|
||||
INT : 'int';
|
||||
BOOL : 'bool';
|
||||
BOOL : 'boolean';
|
||||
VOID : 'void';
|
||||
|
||||
CHAR: ['][a-zA-Z]['];
|
||||
|
11
src/main/java/de/maishai/ast/records/MainMethod.java
Normal file
11
src/main/java/de/maishai/ast/records/MainMethod.java
Normal file
@ -0,0 +1,11 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
|
||||
import de.maishai.ast.Node;
|
||||
import de.maishai.ast.ReturnType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record MainMethod(ReturnType type, Id id, List<Parameter> params, Block block) implements Node {
|
||||
}
|
@ -5,5 +5,5 @@ import de.maishai.ast.Node;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record Program(List<Class> variables, List<Method> methods) implements Node {
|
||||
public record Program(List<Class> variables) implements Node {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user