mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 17:08:03 +00:00
fix mainmethod potentially empty
This commit is contained in:
parent
f6d546be86
commit
1f0d690043
@ -2,7 +2,7 @@ grammar Decaf;
|
|||||||
|
|
||||||
program : (class)+;
|
program : (class)+;
|
||||||
|
|
||||||
class : PUBLIC? 'class' id '{' mainmeth (field | meth | constructor)* '}';
|
class : PUBLIC? 'class' id '{' mainmeth? (field | meth | constructor)* '}';
|
||||||
|
|
||||||
field : type id ';';
|
field : type id ';';
|
||||||
localVar : type id ';';
|
localVar : type id ';';
|
||||||
|
@ -25,7 +25,10 @@ public class ASTGenerator {
|
|||||||
if (ctx.field() != null) {
|
if (ctx.field() != null) {
|
||||||
fields = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList();
|
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<>();
|
List<Constructor> constructors = new ArrayList<>();
|
||||||
if (ctx.constructor() != null) {
|
if (ctx.constructor() != null) {
|
||||||
constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList();
|
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;
|
package de.maishai.antlr;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.ParserRuleContext;
|
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;
|
package de.maishai.antlr;
|
||||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
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;
|
package de.maishai.antlr;
|
||||||
import org.antlr.v4.runtime.Lexer;
|
import org.antlr.v4.runtime.Lexer;
|
||||||
import org.antlr.v4.runtime.CharStream;
|
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;
|
package de.maishai.antlr;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
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;
|
package de.maishai.antlr;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user