mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 01:38:03 +00:00
fix mainmethod potentially empty
This commit is contained in:
parent
f6d546be86
commit
1f0d690043
@ -2,7 +2,7 @@ grammar Decaf;
|
||||
|
||||
program : (class)+;
|
||||
|
||||
class : PUBLIC? 'class' id '{' mainmeth (field | meth | constructor)* '}';
|
||||
class : PUBLIC? 'class' id '{' mainmeth? (field | meth | constructor)* '}';
|
||||
|
||||
field : type id ';';
|
||||
localVar : type id ';';
|
||||
|
@ -25,7 +25,10 @@ public class ASTGenerator {
|
||||
if (ctx.field() != null) {
|
||||
fields = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList();
|
||||
}
|
||||
MainMethod mainMethod = generateMainMethod(ctx.mainmeth());
|
||||
MainMethod mainMethod = null;
|
||||
if(ctx.mainmeth() != null){
|
||||
mainMethod = generateMainMethod(ctx.mainmeth());
|
||||
}
|
||||
List<Constructor> constructors = new ArrayList<>();
|
||||
if (ctx.constructor() != null) {
|
||||
constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList();
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/dev/Compilerbau/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/dev/Compilerbau/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/dev/Compilerbau/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/dev/Compilerbau/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// Generated from C:/Users/laure/Documents/Dev/Compilerbau/Projekt/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
// Generated from C:/dev/Compilerbau/CompilerULTIMATE/src/main/antlr/Decaf.g4 by ANTLR 4.13.1
|
||||
package de.maishai.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user