Fix records and Decaf

This commit is contained in:
Boolean-True 2024-04-24 21:56:50 +02:00
parent 9566823ad1
commit d9182e369d
3 changed files with 16 additions and 4 deletions
src/main
antlr
java/de/maishai/ast/records

@ -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]['];

@ -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 {
}