Compare commits

...

5 Commits

Author SHA1 Message Date
Bruder John
2539b7cff1 Merge branch 'main' into johns-branch 2024-05-08 11:50:18 +02:00
Purplumbi
993bd8fc60 Generated Antlr 2024-05-08 11:47:17 +02:00
Purplumbi
402249e1ac Merge remote-tracking branch 'origin/main'
# Conflicts:
#	src/main/java/parser/Main.java
2024-05-08 11:44:13 +02:00
Purplumbi
5681e3e5f2 AST 2024-05-08 11:43:04 +02:00
i22011
c48a3671fb Structure 2024-05-08 11:42:34 +02:00
31 changed files with 2595 additions and 134 deletions

View File

@ -0,0 +1,3 @@
public class Example {
}

View File

@ -1,10 +1,11 @@
package parser;
import bytecode.ByteCodeGenerator;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import parser.ASTBuilder;
import parser.ClassDeclarationNode;
import parser.ProgramNode;
import parser.generated.SimpleJavaLexer;
import parser.generated.SimpleJavaParser;
@ -15,7 +16,7 @@ public class Main {
public static void main(String[] args) throws Exception {
CharStream codeCharStream = null;
try {
codeCharStream = CharStreams.fromPath(Paths.get("path/to/your/file.txt"));
codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java"));
parsefile(codeCharStream);
} catch (IOException e) {
System.err.println("Error reading the file: " + e.getMessage());

View File

@ -1,4 +1,4 @@
package parser;
package ast;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,5 +0,0 @@
package ast;
public enum AccessModifier {
Public,Private
}

View File

@ -1,7 +0,0 @@
package ast;
public abstract class ClassDeclaration {
public AccessModifier accessModifier;
}

View File

@ -0,0 +1,24 @@
package ast;
import java.util.ArrayList;
import java.util.List;
public class ClassNode extends ASTNode{
public String name;
public List<MemberNode> members = new ArrayList<>();
public boolean hasConstructor = false;
public void addMember(MemberNode member) {
if (member instanceof ConstructorNode) {
this.hasConstructor = true;
}
members.add(member);
}
public void ensureConstructor(){
if(!hasConstructor) {
ConstructorNode constructor = new ConstructorNode("public", name);
members.add(0,constructor);
}
}
}

View File

@ -0,0 +1,7 @@
package ast;
public class ConstructorNode extends MethodNode{
public ConstructorNode(String visibility, String name) {
super(visibility, name);
}
}

View File

@ -0,0 +1,12 @@
package ast;
public class FieldNode {
String type;
String name;
public FieldNode(String type, String name){
this.type = type;
this.name = name;
}
}

View File

@ -1,13 +0,0 @@
package ast;
public class Identifier {
private String name;
public Identifier(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}

View File

@ -0,0 +1,4 @@
package ast;
public class MemberNode extends ASTNode{
}

View File

@ -0,0 +1,11 @@
package ast;
public class MethodNode extends MemberNode{
public String visibility;
public String name;
public MethodNode(String visibility, String name){
this.visibility = visibility;
this.name = name;
}
}

View File

@ -0,0 +1,12 @@
package ast;
import java.util.ArrayList;
import java.util.List;
public class ProgramNode extends ASTNode {
public List<ClassNode> classes = new ArrayList<>();
public void addClass(ClassNode classNode) {
classes.add(classNode);
}
}

View File

@ -1,7 +0,0 @@
package ast;
public interface Type {
}

View File

@ -0,0 +1,5 @@
package ast;
public class TypeNode {
String type;
}

View File

@ -5,8 +5,7 @@ import java.io.IOException;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import parser.ClassDeclarationNode;
import parser.ProgramNode;
import ast.ProgramNode;
public class ByteCodeGenerator {

View File

@ -1,5 +1,6 @@
package parser;
import ast.*;
import parser.generated.SimpleJavaBaseVisitor;
import parser.generated.SimpleJavaParser;
@ -8,13 +9,28 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
public ASTNode visitProgram(SimpleJavaParser.ProgramContext ctx) {
ProgramNode program = new ProgramNode();
for (SimpleJavaParser.ClassDeclarationContext classDeclCtx : ctx.classDeclaration()) {
program.addClass((ClassDeclarationNode) visit(classDeclCtx));
program.addClass((ClassNode) visit(classDeclCtx));
}
return program;
}
@Override
public ASTNode visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) {
return new ClassDeclarationNode(ctx.IDENTIFIER().getText());
ClassNode classNode = new ClassNode();
classNode.name = ctx.IDENTIFIER().getText();
for (SimpleJavaParser.MemberDeclarationContext member : ctx.memberDeclaration()) {
classNode.addMember((MemberNode) visit(member));
}
classNode.ensureConstructor(); // Check and add default constructor if needed
return classNode;
}
@Override
public ASTNode visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) {
TypeNode type = (TypeNode) visit(ctx.type());
String identifier = ctx.IDENTIFIER().getText();
return new FieldNode(type, identifier);
}
}

View File

@ -1,11 +0,0 @@
package parser;
import parser.ASTNode;
public class ClassDeclarationNode extends ASTNode {
public String identifier;
public ClassDeclarationNode(String identifier) {
this.identifier = identifier;
}
}

View File

@ -1,15 +0,0 @@
package parser;
import parser.ASTNode;
import parser.ClassDeclarationNode;
import java.util.ArrayList;
import java.util.List;
public class ProgramNode extends ASTNode {
public List<ClassDeclarationNode> classes = new ArrayList<>();
public void addClass(ClassDeclarationNode classNode) {
classes.add(classNode);
}
}

View File

@ -2,8 +2,56 @@ grammar SimpleJava;
program : classDeclaration+;
classDeclaration : 'class' IDENTIFIER '{' '}';
classDeclaration : 'class' IDENTIFIER '{' memberDeclaration* '}';
memberDeclaration : fieldDeclaration | methodDeclaration;
fieldDeclaration : type IDENTIFIER ';';
methodDeclaration : 'public' 'static' type IDENTIFIER '(' parameterList? ')' '{' statement* '}' ;
parameterList : parameter (',' parameter)* ;
parameter : type IDENTIFIER ;
type : 'int' | 'boolean' | 'char' ;
statement
: variableDeclarationStatement
| assignmentStatement
| ifStatement
| whileStatement
| returnStatement
| block
;
variableDeclarationStatement : type IDENTIFIER ('=' expression)? ';' ;
assignmentStatement : IDENTIFIER '=' expression ';' ;
ifStatement : 'if' '(' expression ')' statement ('else' statement)? ;
whileStatement : 'while' '(' expression ')' statement ;
returnStatement : 'return' (expression)? ';' ;
block : '{' statement* '}' ;
expression
: expression ('&&' | '||') expression
| expression ('==' | '!=' | '<' | '<=' | '>' | '>=') expression
| expression ('+' | '-' | '*' | '/' | '%') expression
| '-' expression
| '!' expression
| '(' expression ')'
| literal
| IDENTIFIER
;
literal : INTEGERLITERAL | booleanLiteral | charLiteral ;
INTEGERLITERAL : [0-9]+ ;
booleanLiteral : 'true' | 'false' ;
charLiteral : '\'' . '\'' ;
IDENTIFIER : [a-zA-Z][a-zA-Z0-9_]* ;
WS : [ \t\r\n]+ -> skip;

View File

@ -1 +0,0 @@
class Test { }

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,71 @@
T__0=1
T__1=2
T__2=3
IDENTIFIER=4
WS=5
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
INTEGERLITERAL=35
IDENTIFIER=36
WS=37
'class'=1
'{'=2
'}'=3
';'=4
'public'=5
'static'=6
'('=7
')'=8
','=9
'int'=10
'boolean'=11
'char'=12
'='=13
'if'=14
'else'=15
'while'=16
'return'=17
'&&'=18
'||'=19
'=='=20
'!='=21
'<'=22
'<='=23
'>'=24
'>='=25
'+'=26
'-'=27
'*'=28
'/'=29
'%'=30
'!'=31
'true'=32
'false'=33
'\''=34

View File

@ -1,4 +1,4 @@
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.ParserRuleContext;
@ -36,6 +36,210 @@ public class SimpleJavaBaseListener implements SimpleJavaListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameterList(SimpleJavaParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameterList(SimpleJavaParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameter(SimpleJavaParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameter(SimpleJavaParser.ParameterContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterType(SimpleJavaParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitType(SimpleJavaParser.TypeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStatement(SimpleJavaParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStatement(SimpleJavaParser.StatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIfStatement(SimpleJavaParser.IfStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBlock(SimpleJavaParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBlock(SimpleJavaParser.BlockContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterExpression(SimpleJavaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitExpression(SimpleJavaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLiteral(SimpleJavaParser.LiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLiteral(SimpleJavaParser.LiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { }
/**
* {@inheritDoc}

View File

@ -1,4 +1,4 @@
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
@ -26,4 +26,123 @@ public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implem
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameterList(SimpleJavaParser.ParameterListContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitParameter(SimpleJavaParser.ParameterContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitType(SimpleJavaParser.TypeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStatement(SimpleJavaParser.StatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIfStatement(SimpleJavaParser.IfStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBlock(SimpleJavaParser.BlockContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitExpression(SimpleJavaParser.ExpressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLiteral(SimpleJavaParser.LiteralContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx) { return visitChildren(ctx); }
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
@ -17,7 +17,11 @@ public class SimpleJavaLexer extends Lexer {
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, IDENTIFIER=4, WS=5;
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
T__31=32, T__32=33, T__33=34, INTEGERLITERAL=35, IDENTIFIER=36, WS=37;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@ -28,20 +32,31 @@ public class SimpleJavaLexer extends Lexer {
private static String[] makeRuleNames() {
return new String[] {
"T__0", "T__1", "T__2", "IDENTIFIER", "WS"
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
"T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
"T__33", "INTEGERLITERAL", "IDENTIFIER", "WS"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'class'", "'{'", "'}'"
null, "'class'", "'{'", "'}'", "';'", "'public'", "'static'", "'('",
"')'", "','", "'int'", "'boolean'", "'char'", "'='", "'if'", "'else'",
"'while'", "'return'", "'&&'", "'||'", "'=='", "'!='", "'<'", "'<='",
"'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "'true'", "'false'",
"'''"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, null, null, "IDENTIFIER", "WS"
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, "INTEGERLITERAL",
"IDENTIFIER", "WS"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
@ -103,32 +118,134 @@ public class SimpleJavaLexer extends Lexer {
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\u0004\u0000\u0005#\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
"\u0004\u0000%\u00d5\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
"\u0007\u0004\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+
"\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003"+
"\u0001\u0003\u0005\u0003\u0018\b\u0003\n\u0003\f\u0003\u001b\t\u0003\u0001"+
"\u0004\u0004\u0004\u001e\b\u0004\u000b\u0004\f\u0004\u001f\u0001\u0004"+
"\u0001\u0004\u0000\u0000\u0005\u0001\u0001\u0003\u0002\u0005\u0003\u0007"+
"\u0004\t\u0005\u0001\u0000\u0003\u0002\u0000AZaz\u0004\u000009AZ__az\u0003"+
"\u0000\t\n\r\r $\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001"+
"\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001"+
"\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0001\u000b\u0001\u0000"+
"\u0000\u0000\u0003\u0011\u0001\u0000\u0000\u0000\u0005\u0013\u0001\u0000"+
"\u0000\u0000\u0007\u0015\u0001\u0000\u0000\u0000\t\u001d\u0001\u0000\u0000"+
"\u0000\u000b\f\u0005c\u0000\u0000\f\r\u0005l\u0000\u0000\r\u000e\u0005"+
"a\u0000\u0000\u000e\u000f\u0005s\u0000\u0000\u000f\u0010\u0005s\u0000"+
"\u0000\u0010\u0002\u0001\u0000\u0000\u0000\u0011\u0012\u0005{\u0000\u0000"+
"\u0012\u0004\u0001\u0000\u0000\u0000\u0013\u0014\u0005}\u0000\u0000\u0014"+
"\u0006\u0001\u0000\u0000\u0000\u0015\u0019\u0007\u0000\u0000\u0000\u0016"+
"\u0018\u0007\u0001\u0000\u0000\u0017\u0016\u0001\u0000\u0000\u0000\u0018"+
"\u001b\u0001\u0000\u0000\u0000\u0019\u0017\u0001\u0000\u0000\u0000\u0019"+
"\u001a\u0001\u0000\u0000\u0000\u001a\b\u0001\u0000\u0000\u0000\u001b\u0019"+
"\u0001\u0000\u0000\u0000\u001c\u001e\u0007\u0002\u0000\u0000\u001d\u001c"+
"\u0001\u0000\u0000\u0000\u001e\u001f\u0001\u0000\u0000\u0000\u001f\u001d"+
"\u0001\u0000\u0000\u0000\u001f \u0001\u0000\u0000\u0000 !\u0001\u0000"+
"\u0000\u0000!\"\u0006\u0004\u0000\u0000\"\n\u0001\u0000\u0000\u0000\u0003"+
"\u0000\u0019\u001f\u0001\u0006\u0000\u0000";
"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+
"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+
"\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002"+
"\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+
"\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+
"\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+
"\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+
"\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+
"\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+
"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0001\u0000\u0001\u0000"+
"\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+
"\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004"+
"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+
"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005"+
"\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001"+
"\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+
"\n\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+
"\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e"+
"\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f"+
"\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010"+
"\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011"+
"\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013"+
"\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015"+
"\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001\u0018"+
"\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a"+
"\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d"+
"\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f"+
"\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001 \u0001!\u0001!\u0001"+
"\"\u0004\"\u00c4\b\"\u000b\"\f\"\u00c5\u0001#\u0001#\u0005#\u00ca\b#\n"+
"#\f#\u00cd\t#\u0001$\u0004$\u00d0\b$\u000b$\f$\u00d1\u0001$\u0001$\u0000"+
"\u0000%\u0001\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b"+
"\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b"+
"\u000e\u001d\u000f\u001f\u0010!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016"+
"-\u0017/\u00181\u00193\u001a5\u001b7\u001c9\u001d;\u001e=\u001f? A!C\""+
"E#G$I%\u0001\u0000\u0004\u0001\u000009\u0002\u0000AZaz\u0004\u000009A"+
"Z__az\u0003\u0000\t\n\r\r \u00d7\u0000\u0001\u0001\u0000\u0000\u0000"+
"\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000"+
"\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000"+
"\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f"+
"\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013"+
"\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017"+
"\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b"+
"\u0001\u0000\u0000\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f"+
"\u0001\u0000\u0000\u0000\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000"+
"\u0000\u0000\u0000%\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000"+
"\u0000\u0000)\u0001\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000"+
"-\u0001\u0000\u0000\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001"+
"\u0000\u0000\u0000\u00003\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000"+
"\u0000\u00007\u0001\u0000\u0000\u0000\u00009\u0001\u0000\u0000\u0000\u0000"+
";\u0001\u0000\u0000\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001"+
"\u0000\u0000\u0000\u0000A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000"+
"\u0000\u0000E\u0001\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000"+
"I\u0001\u0000\u0000\u0000\u0001K\u0001\u0000\u0000\u0000\u0003Q\u0001"+
"\u0000\u0000\u0000\u0005S\u0001\u0000\u0000\u0000\u0007U\u0001\u0000\u0000"+
"\u0000\tW\u0001\u0000\u0000\u0000\u000b^\u0001\u0000\u0000\u0000\re\u0001"+
"\u0000\u0000\u0000\u000fg\u0001\u0000\u0000\u0000\u0011i\u0001\u0000\u0000"+
"\u0000\u0013k\u0001\u0000\u0000\u0000\u0015o\u0001\u0000\u0000\u0000\u0017"+
"w\u0001\u0000\u0000\u0000\u0019|\u0001\u0000\u0000\u0000\u001b~\u0001"+
"\u0000\u0000\u0000\u001d\u0081\u0001\u0000\u0000\u0000\u001f\u0086\u0001"+
"\u0000\u0000\u0000!\u008c\u0001\u0000\u0000\u0000#\u0093\u0001\u0000\u0000"+
"\u0000%\u0096\u0001\u0000\u0000\u0000\'\u0099\u0001\u0000\u0000\u0000"+
")\u009c\u0001\u0000\u0000\u0000+\u009f\u0001\u0000\u0000\u0000-\u00a1"+
"\u0001\u0000\u0000\u0000/\u00a4\u0001\u0000\u0000\u00001\u00a6\u0001\u0000"+
"\u0000\u00003\u00a9\u0001\u0000\u0000\u00005\u00ab\u0001\u0000\u0000\u0000"+
"7\u00ad\u0001\u0000\u0000\u00009\u00af\u0001\u0000\u0000\u0000;\u00b1"+
"\u0001\u0000\u0000\u0000=\u00b3\u0001\u0000\u0000\u0000?\u00b5\u0001\u0000"+
"\u0000\u0000A\u00ba\u0001\u0000\u0000\u0000C\u00c0\u0001\u0000\u0000\u0000"+
"E\u00c3\u0001\u0000\u0000\u0000G\u00c7\u0001\u0000\u0000\u0000I\u00cf"+
"\u0001\u0000\u0000\u0000KL\u0005c\u0000\u0000LM\u0005l\u0000\u0000MN\u0005"+
"a\u0000\u0000NO\u0005s\u0000\u0000OP\u0005s\u0000\u0000P\u0002\u0001\u0000"+
"\u0000\u0000QR\u0005{\u0000\u0000R\u0004\u0001\u0000\u0000\u0000ST\u0005"+
"}\u0000\u0000T\u0006\u0001\u0000\u0000\u0000UV\u0005;\u0000\u0000V\b\u0001"+
"\u0000\u0000\u0000WX\u0005p\u0000\u0000XY\u0005u\u0000\u0000YZ\u0005b"+
"\u0000\u0000Z[\u0005l\u0000\u0000[\\\u0005i\u0000\u0000\\]\u0005c\u0000"+
"\u0000]\n\u0001\u0000\u0000\u0000^_\u0005s\u0000\u0000_`\u0005t\u0000"+
"\u0000`a\u0005a\u0000\u0000ab\u0005t\u0000\u0000bc\u0005i\u0000\u0000"+
"cd\u0005c\u0000\u0000d\f\u0001\u0000\u0000\u0000ef\u0005(\u0000\u0000"+
"f\u000e\u0001\u0000\u0000\u0000gh\u0005)\u0000\u0000h\u0010\u0001\u0000"+
"\u0000\u0000ij\u0005,\u0000\u0000j\u0012\u0001\u0000\u0000\u0000kl\u0005"+
"i\u0000\u0000lm\u0005n\u0000\u0000mn\u0005t\u0000\u0000n\u0014\u0001\u0000"+
"\u0000\u0000op\u0005b\u0000\u0000pq\u0005o\u0000\u0000qr\u0005o\u0000"+
"\u0000rs\u0005l\u0000\u0000st\u0005e\u0000\u0000tu\u0005a\u0000\u0000"+
"uv\u0005n\u0000\u0000v\u0016\u0001\u0000\u0000\u0000wx\u0005c\u0000\u0000"+
"xy\u0005h\u0000\u0000yz\u0005a\u0000\u0000z{\u0005r\u0000\u0000{\u0018"+
"\u0001\u0000\u0000\u0000|}\u0005=\u0000\u0000}\u001a\u0001\u0000\u0000"+
"\u0000~\u007f\u0005i\u0000\u0000\u007f\u0080\u0005f\u0000\u0000\u0080"+
"\u001c\u0001\u0000\u0000\u0000\u0081\u0082\u0005e\u0000\u0000\u0082\u0083"+
"\u0005l\u0000\u0000\u0083\u0084\u0005s\u0000\u0000\u0084\u0085\u0005e"+
"\u0000\u0000\u0085\u001e\u0001\u0000\u0000\u0000\u0086\u0087\u0005w\u0000"+
"\u0000\u0087\u0088\u0005h\u0000\u0000\u0088\u0089\u0005i\u0000\u0000\u0089"+
"\u008a\u0005l\u0000\u0000\u008a\u008b\u0005e\u0000\u0000\u008b \u0001"+
"\u0000\u0000\u0000\u008c\u008d\u0005r\u0000\u0000\u008d\u008e\u0005e\u0000"+
"\u0000\u008e\u008f\u0005t\u0000\u0000\u008f\u0090\u0005u\u0000\u0000\u0090"+
"\u0091\u0005r\u0000\u0000\u0091\u0092\u0005n\u0000\u0000\u0092\"\u0001"+
"\u0000\u0000\u0000\u0093\u0094\u0005&\u0000\u0000\u0094\u0095\u0005&\u0000"+
"\u0000\u0095$\u0001\u0000\u0000\u0000\u0096\u0097\u0005|\u0000\u0000\u0097"+
"\u0098\u0005|\u0000\u0000\u0098&\u0001\u0000\u0000\u0000\u0099\u009a\u0005"+
"=\u0000\u0000\u009a\u009b\u0005=\u0000\u0000\u009b(\u0001\u0000\u0000"+
"\u0000\u009c\u009d\u0005!\u0000\u0000\u009d\u009e\u0005=\u0000\u0000\u009e"+
"*\u0001\u0000\u0000\u0000\u009f\u00a0\u0005<\u0000\u0000\u00a0,\u0001"+
"\u0000\u0000\u0000\u00a1\u00a2\u0005<\u0000\u0000\u00a2\u00a3\u0005=\u0000"+
"\u0000\u00a3.\u0001\u0000\u0000\u0000\u00a4\u00a5\u0005>\u0000\u0000\u00a5"+
"0\u0001\u0000\u0000\u0000\u00a6\u00a7\u0005>\u0000\u0000\u00a7\u00a8\u0005"+
"=\u0000\u0000\u00a82\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005+\u0000"+
"\u0000\u00aa4\u0001\u0000\u0000\u0000\u00ab\u00ac\u0005-\u0000\u0000\u00ac"+
"6\u0001\u0000\u0000\u0000\u00ad\u00ae\u0005*\u0000\u0000\u00ae8\u0001"+
"\u0000\u0000\u0000\u00af\u00b0\u0005/\u0000\u0000\u00b0:\u0001\u0000\u0000"+
"\u0000\u00b1\u00b2\u0005%\u0000\u0000\u00b2<\u0001\u0000\u0000\u0000\u00b3"+
"\u00b4\u0005!\u0000\u0000\u00b4>\u0001\u0000\u0000\u0000\u00b5\u00b6\u0005"+
"t\u0000\u0000\u00b6\u00b7\u0005r\u0000\u0000\u00b7\u00b8\u0005u\u0000"+
"\u0000\u00b8\u00b9\u0005e\u0000\u0000\u00b9@\u0001\u0000\u0000\u0000\u00ba"+
"\u00bb\u0005f\u0000\u0000\u00bb\u00bc\u0005a\u0000\u0000\u00bc\u00bd\u0005"+
"l\u0000\u0000\u00bd\u00be\u0005s\u0000\u0000\u00be\u00bf\u0005e\u0000"+
"\u0000\u00bfB\u0001\u0000\u0000\u0000\u00c0\u00c1\u0005\'\u0000\u0000"+
"\u00c1D\u0001\u0000\u0000\u0000\u00c2\u00c4\u0007\u0000\u0000\u0000\u00c3"+
"\u00c2\u0001\u0000\u0000\u0000\u00c4\u00c5\u0001\u0000\u0000\u0000\u00c5"+
"\u00c3\u0001\u0000\u0000\u0000\u00c5\u00c6\u0001\u0000\u0000\u0000\u00c6"+
"F\u0001\u0000\u0000\u0000\u00c7\u00cb\u0007\u0001\u0000\u0000\u00c8\u00ca"+
"\u0007\u0002\u0000\u0000\u00c9\u00c8\u0001\u0000\u0000\u0000\u00ca\u00cd"+
"\u0001\u0000\u0000\u0000\u00cb\u00c9\u0001\u0000\u0000\u0000\u00cb\u00cc"+
"\u0001\u0000\u0000\u0000\u00ccH\u0001\u0000\u0000\u0000\u00cd\u00cb\u0001"+
"\u0000\u0000\u0000\u00ce\u00d0\u0007\u0003\u0000\u0000\u00cf\u00ce\u0001"+
"\u0000\u0000\u0000\u00d0\u00d1\u0001\u0000\u0000\u0000\u00d1\u00cf\u0001"+
"\u0000\u0000\u0000\u00d1\u00d2\u0001\u0000\u0000\u0000\u00d2\u00d3\u0001"+
"\u0000\u0000\u0000\u00d3\u00d4\u0006$\u0000\u0000\u00d4J\u0001\u0000\u0000"+
"\u0000\u0004\u0000\u00c5\u00cb\u00d1\u0001\u0006\u0000\u0000";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {

View File

@ -1,8 +1,71 @@
T__0=1
T__1=2
T__2=3
IDENTIFIER=4
WS=5
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
INTEGERLITERAL=35
IDENTIFIER=36
WS=37
'class'=1
'{'=2
'}'=3
';'=4
'public'=5
'static'=6
'('=7
')'=8
','=9
'int'=10
'boolean'=11
'char'=12
'='=13
'if'=14
'else'=15
'while'=16
'return'=17
'&&'=18
'||'=19
'=='=20
'!='=21
'<'=22
'<='=23
'>'=24
'>='=25
'+'=26
'-'=27
'*'=28
'/'=29
'%'=30
'!'=31
'true'=32
'false'=33
'\''=34

View File

@ -1,4 +1,4 @@
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.ParseTreeListener;
@ -27,4 +27,174 @@ public interface SimpleJavaListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
* @param ctx the parse tree
*/
void enterMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
* @param ctx the parse tree
*/
void exitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
* @param ctx the parse tree
*/
void enterFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
* @param ctx the parse tree
*/
void exitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
* @param ctx the parse tree
*/
void enterMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
* @param ctx the parse tree
*/
void exitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#parameterList}.
* @param ctx the parse tree
*/
void enterParameterList(SimpleJavaParser.ParameterListContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#parameterList}.
* @param ctx the parse tree
*/
void exitParameterList(SimpleJavaParser.ParameterListContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#parameter}.
* @param ctx the parse tree
*/
void enterParameter(SimpleJavaParser.ParameterContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#parameter}.
* @param ctx the parse tree
*/
void exitParameter(SimpleJavaParser.ParameterContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#type}.
* @param ctx the parse tree
*/
void enterType(SimpleJavaParser.TypeContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#type}.
* @param ctx the parse tree
*/
void exitType(SimpleJavaParser.TypeContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#statement}.
* @param ctx the parse tree
*/
void enterStatement(SimpleJavaParser.StatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#statement}.
* @param ctx the parse tree
*/
void exitStatement(SimpleJavaParser.StatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
* @param ctx the parse tree
*/
void enterVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
* @param ctx the parse tree
*/
void exitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
* @param ctx the parse tree
*/
void enterAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
* @param ctx the parse tree
*/
void exitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#ifStatement}.
* @param ctx the parse tree
*/
void enterIfStatement(SimpleJavaParser.IfStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
* @param ctx the parse tree
*/
void exitIfStatement(SimpleJavaParser.IfStatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#whileStatement}.
* @param ctx the parse tree
*/
void enterWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
* @param ctx the parse tree
*/
void exitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#returnStatement}.
* @param ctx the parse tree
*/
void enterReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#returnStatement}.
* @param ctx the parse tree
*/
void exitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#block}.
* @param ctx the parse tree
*/
void enterBlock(SimpleJavaParser.BlockContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#block}.
* @param ctx the parse tree
*/
void exitBlock(SimpleJavaParser.BlockContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#expression}.
* @param ctx the parse tree
*/
void enterExpression(SimpleJavaParser.ExpressionContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#expression}.
* @param ctx the parse tree
*/
void exitExpression(SimpleJavaParser.ExpressionContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#literal}.
* @param ctx the parse tree
*/
void enterLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#literal}.
* @param ctx the parse tree
*/
void exitLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
*/
void enterBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
*/
void exitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Enter a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
*/
void enterCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
/**
* Exit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
*/
void exitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
// Generated from C:/Users/ARB00072/Desktop/DHBW/4. Semester/Compilerbau/Endprojekt/NichtHaskell2.0/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
package parser.generated;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
@ -22,4 +22,106 @@ public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#memberDeclaration}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitMemberDeclaration(SimpleJavaParser.MemberDeclarationContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#fieldDeclaration}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFieldDeclaration(SimpleJavaParser.FieldDeclarationContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#methodDeclaration}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitMethodDeclaration(SimpleJavaParser.MethodDeclarationContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#parameterList}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitParameterList(SimpleJavaParser.ParameterListContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#parameter}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitParameter(SimpleJavaParser.ParameterContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#type}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitType(SimpleJavaParser.TypeContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#statement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitStatement(SimpleJavaParser.StatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#variableDeclarationStatement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitVariableDeclarationStatement(SimpleJavaParser.VariableDeclarationStatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#assignmentStatement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAssignmentStatement(SimpleJavaParser.AssignmentStatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#ifStatement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIfStatement(SimpleJavaParser.IfStatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#whileStatement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitWhileStatement(SimpleJavaParser.WhileStatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#returnStatement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitReturnStatement(SimpleJavaParser.ReturnStatementContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#block}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBlock(SimpleJavaParser.BlockContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitExpression(SimpleJavaParser.ExpressionContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#literal}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLiteral(SimpleJavaParser.LiteralContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#booleanLiteral}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBooleanLiteral(SimpleJavaParser.BooleanLiteralContext ctx);
/**
* Visit a parse tree produced by {@link SimpleJavaParser#charLiteral}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitCharLiteral(SimpleJavaParser.CharLiteralContext ctx);
}

View File

@ -9,6 +9,11 @@ public class SimpleJavaFeatureTest {
this.b = b;
this.c = c;
}
private class InnerClass {
void innerMethod() {
System.out.println("Inner class method");
}
}
// Methode zur Demonstration von Kontrollstrukturen
void controlStructures() {