update Generators

This commit is contained in:
Boolean-True 2024-05-07 11:32:03 +02:00
parent f87b014584
commit c2ce7ff80f
22 changed files with 1937 additions and 947 deletions

View File

@ -2,7 +2,7 @@ grammar Decaf;
program : (class)+;
class : PUBLIC? 'class' id '{' (field | meth)* '}';
class : PUBLIC? 'class' id '{' mainmeth (field | meth | constructor)* '}';
field : type id ';';
localVar : type id ';';
@ -10,7 +10,7 @@ assignSign : ASSIGN | ADD_ASSIGN | SUB_ASSIGN | MUL_ASSIGN;
returntype : type | VOID;
type : INT | BOOL | CHAR;
meth : PUBLIC? returntype id '(' params? ')' block | mainmeth | constructor;
meth : PUBLIC? returntype id '(' params? ')' block;
mainmeth : PUBLIC 'static' 'void' 'main' '(' 'String[] args' ')' block;
constructor: PUBLIC? id '(' params? ')' block;
params : param (',' param)*;
@ -43,12 +43,12 @@ expr : expr binaryOp expr #BinaryOperation
| NULL #Null
;
binaryOp : ADD | SUB | MUL | GT | LT | GE | LE | EQ | NE | AND | OR | NOT;
binaryOp : ADD | SUB | MUL | GT | LT | GE | LE | EQ | NE | AND | OR;
unaryOp : SUB | NOT;
fieldId : ('this' '.')? (recipient '.')* id;
fieldId : (THIS '.')? (recipient '.')* id;
methCall : ('this' '.')? (recipient '.')* methName;
methCall : (THIS '.')? (recipient '.')* methName;
recipient : methName | id;
methName : id '(' args? ')';
args : expr (',' expr)*;
@ -61,6 +61,7 @@ id : IDENTIFIER;
PUBLIC : 'public';
NEW : 'new';
NULL : 'null';
THIS : 'this';
SUB : '-';
ADD : '+';

View File

@ -20,20 +20,28 @@ public class ASTGenerator {
}
public static Class generateClass(DecafParser.ClassContext ctx) {
List<LocalVariable> vars = new ArrayList<>();
if(ctx.var() != null){
vars = ctx.var().stream().map(ASTGenerator::generateVariable).toList();
Boolean isPublic = ctx.PUBLIC() != null;
List<Field> fields = new ArrayList<>();
if(ctx.field() != null){
fields = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList();
}
MainMethod mainMethod = generateMainMethod(ctx.mainmeth());
List<Constructor> constructors = new ArrayList<>();
if(ctx.constructor() != null){
constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList();
}
List<Method> meths = new ArrayList<>();
if(ctx.meth() != null){
meths = ctx.meth().stream().map(ASTGenerator::generateMethod).toList();
}
Id classId = new Id(ctx.id().getText());
return new Class(classId, vars, meths);
return new Class(isPublic, classId, fields, meths, mainMethod, constructors);
}
public static LocalVariable generateVariable(DecafParser.VarContext ctx) {
return new VariableGenerator().visitVar(ctx);
public static Field generateFieldVariable(DecafParser.FieldContext ctx) {
Id id = new Id(ctx.id().getText());
Type type = ASTGenerator.getType(ctx.type());
return new Field(id, type);
}
public static Parameter generateParameter(DecafParser.ParamContext ctx) {
@ -41,13 +49,25 @@ public class ASTGenerator {
}
public static Method generateMethod(DecafParser.MethContext ctx) {
Boolean isPublic = ctx.PUBLIC() != null;
List<Parameter> params = new ArrayList<>();
if(ctx.params() != null){
params = ctx.params().param().stream().map(ASTGenerator::generateParameter).toList();
}
Block block = new BlockGenerator().visit(ctx.block());
Id methId = new Id(ctx.id().getText());
return new Method(getReturnType(ctx.returntype()), methId, params, block);
return new Method(isPublic, getReturnType(ctx.returntype()), methId, params, block);
}
public static Constructor generateConstructor(DecafParser.ConstructorContext ctx) {
Boolean isPublic = ctx.PUBLIC() != null;
List<Parameter> params = new ArrayList<>();
if(ctx.params() != null){
params = ctx.params().param().stream().map(ASTGenerator::generateParameter).toList();
}
Block block = new BlockGenerator().visit(ctx.block());
Id constructorId = new Id(ctx.id().getText());
return new Constructor(isPublic, constructorId, params, block);
}
public static MainMethod generateMainMethod(DecafParser.MainmethContext ctx) {

View File

@ -11,7 +11,7 @@ import java.util.List;
public class BlockGenerator extends DecafBaseVisitor<Block> {
@Override
public Block visitBlock(DecafParser.BlockContext ctx) {
List<LocalVariable> vars = ctx.var().stream().map(var -> new VariableGenerator().visit(var)).toList();
List<LocalVariable> vars = ctx.localVar().stream().map(var -> new VariableGenerator().visit(var)).toList();
List<Statement> statements = ctx.stmt().stream().map(stmt -> new StatementGenerator().visit(stmt)).toList();
return new Block(vars, statements);
}

View File

@ -2,6 +2,7 @@ package de.maishai;
import de.maishai.antlr.DecafBaseVisitor;
import de.maishai.antlr.DecafParser;
import de.maishai.ast.UnaryOperator;
import de.maishai.ast.records.Expression;
import de.maishai.ast.Operator;
import de.maishai.ast.Type;
@ -16,6 +17,18 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
return generateBinary(ctx);
}
@Override
public Expression visitUnaryOperation(DecafParser.UnaryOperationContext ctx) {
Expression expr = this.visit(ctx.expr());
if(ctx.unaryOp().NOT() != null){
return new Unary(UnaryOperator.NOT, expr);
}
if(ctx.unaryOp().SUB() != null){
return new Unary(UnaryOperator.SUB, expr);
}
throw new RuntimeException();
}
@Override
public Expression visitConstant(DecafParser.ConstantContext ctx) {
return generateConstant(ctx.literal());
@ -29,26 +42,26 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
}
@Override
public Expression visitMethodCallExpression(DecafParser.MethodCallExpressionContext ctx) {
Id id = new Id(ctx.methCall().id().getText());
List<Expression> args = new ArrayList<>();
for(var expr : ctx.methCall().args().expr()){
Expression astExpr = expr.accept(this);
args.add(astExpr);
public Expression visitIdentifier(DecafParser.IdentifierContext ctx){
Boolean isField = false;
if(ctx.fieldId().THIS() != null){
isField = true;
}
return new MethodCall(id, args);
Expression recipient = null;
if(ctx.fieldId().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.fieldId().recipient();
recipient = generateRecipient(recipientList, null);
}
@Override
public Id visitIdentifier(DecafParser.IdentifierContext ctx){
return new Id(ctx.getText());
return new FieldId(isField, recipient, new Id(ctx.getText()));
}
public static Expression generateConstant(DecafParser.LiteralContext ctx){
if(ctx.NUMBER() != null)
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
if(ctx.boolean_() != null)
return new BoolLiteral(Boolean.valueOf(ctx.boolean_().getText()));
if(ctx.BOOLEANLITERAL() != null)
return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText()));
if(ctx.CHARLITERAL() != null)
return new CharLiteral(ctx.CHARLITERAL().getText().charAt(0));
throw new RuntimeException();
}
@ -63,26 +76,35 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
if(ctx.ADD() != null)return Operator.ADD;
if(ctx.SUB() != null)return Operator.SUB;
if(ctx.MUL() != null)return Operator.MUL;
if(ctx.GT() != null)return Operator.GT;
if(ctx.LT() != null)return Operator.LT;
if(ctx.GE() != null)return Operator.GE;
if(ctx.LE() != null)return Operator.LE;
if(ctx.EQ() != null)return Operator.EQ;
if(ctx.NE() != null)return Operator.NE;
if(ctx.AND() != null)return Operator.AND;
if(ctx.OR() != null)return Operator.OR;
throw new RuntimeException();
}
//StatementExpression
@Override
public Expression visitAssign(DecafParser.AssignContext ctx) {
Id id = new Id(ctx.id().getText());
Expression expr = this.visit(ctx.expr());
return new Assignment(id, expr);
}
@Override
public Expression visitMethodCall(DecafParser.MethodCallContext ctx) {
Id id = new Id(ctx.methCall().id().getText());
Boolean isField = false;
if(ctx.methCall().THIS() != null){
isField = true;
}
Expression recipient = null;
if(ctx.methCall().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient();
recipient = generateRecipient(recipientList, null);
}
Id id = new Id(ctx.methCall().methName().id().getText());
List<Expression> args = new ArrayList<>();
for(var expr : ctx.methCall().args().expr()){
for(var expr : ctx.methCall().methName().args().expr()){
Expression astExpr = expr.accept(this);
args.add(astExpr);
}
return new MethodCall(id, args);
return new MethodCall(isField, recipient, id, args);
}
@Override
@ -95,4 +117,19 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
}
return new New(type, args);
}
public static Expression generateRecipient(List<DecafParser.RecipientContext> ctxList, Expression recipient){
if(ctxList.isEmpty()){
return recipient;
}
DecafParser.RecipientContext ctx = ctxList.get(0);
ctxList.remove(0);
Id id = new Id(ctx.methName().id().getText());
List<Expression> args = new ArrayList<>();
for(var expr : ctx.methName().args().expr()){
Expression astExpr = expr.accept(new ExpressionGenerator());
args.add(astExpr);
}
return new MethodCall(null, generateRecipient(ctxList, recipient), id, args);
}
}

View File

@ -2,6 +2,7 @@ package de.maishai;
import de.maishai.antlr.DecafBaseVisitor;
import de.maishai.antlr.DecafParser;
import de.maishai.ast.AssignSign;
import de.maishai.ast.records.Expression;
import de.maishai.ast.records.Statement;
import de.maishai.ast.Type;
@ -65,23 +66,33 @@ public class StatementGenerator extends DecafBaseVisitor<Statement> {
return new Continue();
}
//StatementExpression
@Override
public Statement visitAssign(DecafParser.AssignContext ctx) {
public Statement visitAssignment(DecafParser.AssignmentContext ctx) {
Id id = new Id(ctx.id().getText());
AssignSign sign = getAssignSign(ctx.assignSign());
Expression expr = new ExpressionGenerator().visit(ctx.expr());
return new Assignment(id, expr);
return new Assignment(id, sign, expr);
}
//StatementExpression
@Override
public Statement visitMethodCall(DecafParser.MethodCallContext ctx) {
Id id = new Id(ctx.methCall().id().getText());
Boolean isField = false;
if(ctx.methCall().THIS() != null){
isField = true;
}
Expression recipient = null;
if(ctx.methCall().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient();
recipient = new ExpressionGenerator().generateRecipient(recipientList, null);
}
Id id = new Id(ctx.methCall().methName().id().getText());
List<Expression> args = new ArrayList<>();
for(var expr : ctx.methCall().args().expr()){
for(var expr : ctx.methCall().methName().args().expr()){
Expression astExpr = expr.accept(new ExpressionGenerator());
args.add(astExpr);
}
return new MethodCall(id, args);
return new MethodCall(isField, recipient, id, args);
}
@Override
@ -94,4 +105,16 @@ public class StatementGenerator extends DecafBaseVisitor<Statement> {
}
return new New(type, args);
}
public static AssignSign getAssignSign(DecafParser.AssignSignContext ctx){
if(ctx.ASSIGN() != null)
return AssignSign.ASSIGN;
if(ctx.ADD_ASSIGN() != null)
return AssignSign.ADD_ASSIGN;
if(ctx.SUB_ASSIGN() != null)
return AssignSign.SUB_ASSIGN;
if(ctx.MUL_ASSIGN() != null)
return AssignSign.MUL_ASSIGN;
throw new RuntimeException();
}
}

View File

@ -10,11 +10,9 @@ import de.maishai.ast.records.LocalVariable;
public class VariableGenerator extends DecafBaseVisitor<LocalVariable> {
@Override
public LocalVariable visitVar(DecafParser.VarContext ctx) {
public LocalVariable visitLocalVar(DecafParser.LocalVarContext ctx) {
Id id = new Id(ctx.id().getText());
Type type = ASTGenerator.getType(ctx.type());
if(ctx.expr() != null)
return new LocalVariable(id, type, new ExpressionGenerator().visit(ctx.expr()));
return new LocalVariable(id, type, null);
return new LocalVariable(id, type);
}
}

File diff suppressed because one or more lines are too long

View File

@ -17,46 +17,75 @@ T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
PUBLIC=22
NEW=23
PUBLIC=20
NEW=21
NULL=22
THIS=23
SUB=24
ADD=25
MUL=26
INT=27
BOOL=28
VOID=29
CHAR=30
IDENTIFIER=31
NUMBER=32
WS=33
GT=27
LT=28
GE=29
LE=30
EQ=31
NE=32
AND=33
OR=34
ASSIGN=35
ADD_ASSIGN=36
SUB_ASSIGN=37
MUL_ASSIGN=38
NOT=39
INT=40
BOOL=41
VOID=42
CHAR=43
BOOLEANLITERAL=44
CHARLITERAL=45
IDENTIFIER=46
NUMBER=47
WS=48
'class'=1
'{'=2
'}'=3
';'=4
'='=5
'('=6
')'=7
'static'=8
'main'=9
'String[] args'=10
','=11
'if'=12
'else'=13
'for'=14
'while'=15
'do'=16
'return'=17
'break'=18
'continue'=19
'true'=20
'false'=21
'public'=22
'new'=23
'('=5
')'=6
'static'=7
'main'=8
'String[] args'=9
','=10
'if'=11
'else'=12
'for'=13
'while'=14
'do'=15
'return'=16
'break'=17
'continue'=18
'.'=19
'public'=20
'new'=21
'null'=22
'this'=23
'-'=24
'+'=25
'*'=26
'int'=27
'boolean'=28
'void'=29
'>'=27
'<'=28
'>='=29
'<='=30
'=='=31
'!='=32
'&&'=33
'||'=34
'='=35
'+='=36
'-='=37
'*='=38
'!'=39
'int'=40
'boolean'=41
'void'=42
'char'=43

View File

@ -41,13 +41,37 @@ public class DecafBaseListener implements DecafListener {
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVar(DecafParser.VarContext ctx) { }
@Override public void enterField(DecafParser.FieldContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVar(DecafParser.VarContext ctx) { }
@Override public void exitField(DecafParser.FieldContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLocalVar(DecafParser.LocalVarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLocalVar(DecafParser.LocalVarContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignSign(DecafParser.AssignSignContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignSign(DecafParser.AssignSignContext ctx) { }
/**
* {@inheritDoc}
*
@ -96,6 +120,18 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMainmeth(DecafParser.MainmethContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterConstructor(DecafParser.ConstructorContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitConstructor(DecafParser.ConstructorContext ctx) { }
/**
* {@inheritDoc}
*
@ -228,6 +264,18 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitContinue(DecafParser.ContinueContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignment(DecafParser.AssignmentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignment(DecafParser.AssignmentContext ctx) { }
/**
* {@inheritDoc}
*
@ -240,18 +288,6 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssign(DecafParser.AssignContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssign(DecafParser.AssignContext ctx) { }
/**
* {@inheritDoc}
*
@ -276,6 +312,30 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitNew(DecafParser.NewContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterNull(DecafParser.NullContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitNull(DecafParser.NullContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterUnaryOperation(DecafParser.UnaryOperationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitUnaryOperation(DecafParser.UnaryOperationContext ctx) { }
/**
* {@inheritDoc}
*
@ -288,18 +348,6 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIdentifier(DecafParser.IdentifierContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethodCallExpression(DecafParser.MethodCallExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethodCallExpression(DecafParser.MethodCallExpressionContext ctx) { }
/**
* {@inheritDoc}
*
@ -360,6 +408,30 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBinaryOp(DecafParser.BinaryOpContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterUnaryOp(DecafParser.UnaryOpContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitUnaryOp(DecafParser.UnaryOpContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFieldId(DecafParser.FieldIdContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFieldId(DecafParser.FieldIdContext ctx) { }
/**
* {@inheritDoc}
*
@ -372,6 +444,30 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethCall(DecafParser.MethCallContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterRecipient(DecafParser.RecipientContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitRecipient(DecafParser.RecipientContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMethName(DecafParser.MethNameContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMethName(DecafParser.MethNameContext ctx) { }
/**
* {@inheritDoc}
*
@ -396,18 +492,6 @@ public class DecafBaseListener implements DecafListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLiteral(DecafParser.LiteralContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBoolean(DecafParser.BooleanContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBoolean(DecafParser.BooleanContext ctx) { }
/**
* {@inheritDoc}
*

View File

@ -32,7 +32,21 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVar(DecafParser.VarContext ctx) { return visitChildren(ctx); }
@Override public T visitField(DecafParser.FieldContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLocalVar(DecafParser.LocalVarContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssignSign(DecafParser.AssignSignContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -61,6 +75,13 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMainmeth(DecafParser.MainmethContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConstructor(DecafParser.ConstructorContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -144,14 +165,14 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx) { return visitChildren(ctx); }
@Override public T visitAssignment(DecafParser.AssignmentContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAssign(DecafParser.AssignContext ctx) { return visitChildren(ctx); }
@Override public T visitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -172,14 +193,21 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIdentifier(DecafParser.IdentifierContext ctx) { return visitChildren(ctx); }
@Override public T visitNull(DecafParser.NullContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethodCallExpression(DecafParser.MethodCallExpressionContext ctx) { return visitChildren(ctx); }
@Override public T visitUnaryOperation(DecafParser.UnaryOperationContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIdentifier(DecafParser.IdentifierContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -215,6 +243,20 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBinaryOp(DecafParser.BinaryOpContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitUnaryOp(DecafParser.UnaryOpContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFieldId(DecafParser.FieldIdContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -222,6 +264,20 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethCall(DecafParser.MethCallContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitRecipient(DecafParser.RecipientContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitMethName(DecafParser.MethNameContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
@ -236,13 +292,6 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLiteral(DecafParser.LiteralContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBoolean(DecafParser.BooleanContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*

File diff suppressed because one or more lines are too long

View File

@ -19,8 +19,11 @@ public class DecafLexer extends Lexer {
public static final int
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, PUBLIC=22, NEW=23, SUB=24, ADD=25,
MUL=26, INT=27, BOOL=28, VOID=29, CHAR=30, IDENTIFIER=31, NUMBER=32, WS=33;
T__17=18, T__18=19, PUBLIC=20, NEW=21, NULL=22, THIS=23, SUB=24, ADD=25,
MUL=26, GT=27, LT=28, GE=29, LE=30, EQ=31, NE=32, AND=33, OR=34, ASSIGN=35,
ADD_ASSIGN=36, SUB_ASSIGN=37, MUL_ASSIGN=38, NOT=39, INT=40, BOOL=41,
VOID=42, CHAR=43, BOOLEANLITERAL=44, CHARLITERAL=45, IDENTIFIER=46, NUMBER=47,
WS=48;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@ -33,26 +36,32 @@ public class DecafLexer extends Lexer {
return new String[] {
"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", "PUBLIC", "NEW", "SUB", "ADD", "MUL",
"INT", "BOOL", "VOID", "CHAR", "IDENTIFIER", "NUMBER", "WS"
"T__17", "T__18", "PUBLIC", "NEW", "NULL", "THIS", "SUB", "ADD", "MUL",
"GT", "LT", "GE", "LE", "EQ", "NE", "AND", "OR", "ASSIGN", "ADD_ASSIGN",
"SUB_ASSIGN", "MUL_ASSIGN", "NOT", "INT", "BOOL", "VOID", "CHAR", "BOOLEANLITERAL",
"CHARLITERAL", "IDENTIFIER", "NUMBER", "WS"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'class'", "'{'", "'}'", "';'", "'='", "'('", "')'", "'static'",
"'main'", "'String[] args'", "','", "'if'", "'else'", "'for'", "'while'",
"'do'", "'return'", "'break'", "'continue'", "'true'", "'false'", "'public'",
"'new'", "'-'", "'+'", "'*'", "'int'", "'boolean'", "'void'"
null, "'class'", "'{'", "'}'", "';'", "'('", "')'", "'static'", "'main'",
"'String[] args'", "','", "'if'", "'else'", "'for'", "'while'", "'do'",
"'return'", "'break'", "'continue'", "'.'", "'public'", "'new'", "'null'",
"'this'", "'-'", "'+'", "'*'", "'>'", "'<'", "'>='", "'<='", "'=='",
"'!='", "'&&'", "'||'", "'='", "'+='", "'-='", "'*='", "'!'", "'int'",
"'boolean'", "'void'", "'char'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, "PUBLIC",
"NEW", "SUB", "ADD", "MUL", "INT", "BOOL", "VOID", "CHAR", "IDENTIFIER",
null, null, null, null, null, null, null, null, "PUBLIC", "NEW", "NULL",
"THIS", "SUB", "ADD", "MUL", "GT", "LT", "GE", "LE", "EQ", "NE", "AND",
"OR", "ASSIGN", "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "NOT", "INT",
"BOOL", "VOID", "CHAR", "BOOLEANLITERAL", "CHARLITERAL", "IDENTIFIER",
"NUMBER", "WS"
};
}
@ -115,7 +124,7 @@ public class DecafLexer extends Lexer {
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\u0004\u0000!\u00db\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
"\u0004\u00000\u012b\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
"\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"+
@ -125,127 +134,173 @@ public class DecafLexer extends Lexer {
"\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 \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\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001"+
"\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+
"\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+
"\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+
"\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001\f"+
"\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001"+
"\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+
"\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+
"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+
"&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\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\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007"+
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0001"+
"\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001"+
"\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001"+
"\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r"+
"\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001"+
"\u000e\u0001\u000f\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"+
"\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001"+
"\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001"+
"\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001"+
"\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001"+
"\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001"+
"\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+
"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0012\u0001"+
"\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001"+
"\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001"+
"\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+
"\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001"+
"\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001"+
"\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001"+
"\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001"+
"\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001\u001d\u0001"+
"\u001d\u0001\u001e\u0004\u001e\u00cf\b\u001e\u000b\u001e\f\u001e\u00d0"+
"\u0001\u001f\u0004\u001f\u00d4\b\u001f\u000b\u001f\f\u001f\u00d5\u0001"+
" \u0001 \u0001 \u0001 \u0000\u0000!\u0001\u0001\u0003\u0002\u0005\u0003"+
"\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001"+
"\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001f\u0001"+
"\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001!\u0001!\u0001!\u0001\"\u0001"+
"\"\u0001#\u0001#\u0001#\u0001$\u0001$\u0001$\u0001%\u0001%\u0001%\u0001"+
"&\u0001&\u0001\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001"+
"(\u0001(\u0001(\u0001(\u0001)\u0001)\u0001)\u0001)\u0001)\u0001*\u0001"+
"*\u0001*\u0001*\u0001*\u0001+\u0001+\u0001+\u0001+\u0001+\u0001+\u0001"+
"+\u0001+\u0001+\u0003+\u0118\b+\u0001,\u0001,\u0001,\u0001,\u0001-\u0004"+
"-\u011f\b-\u000b-\f-\u0120\u0001.\u0004.\u0124\b.\u000b.\f.\u0125\u0001"+
"/\u0001/\u0001/\u0001/\u0000\u00000\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\u001c"+
"9\u001d;\u001e=\u001f? A!\u0001\u0000\u0004\u0001\u0000\'\'\u0002\u0000"+
"AZaz\u0001\u000009\u0003\u0000\t\n\r\r \u00dc\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\u0000"+
"1\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\u0001C\u0001"+
"\u0000\u0000\u0000\u0003I\u0001\u0000\u0000\u0000\u0005K\u0001\u0000\u0000"+
"\u0000\u0007M\u0001\u0000\u0000\u0000\tO\u0001\u0000\u0000\u0000\u000b"+
"Q\u0001\u0000\u0000\u0000\rS\u0001\u0000\u0000\u0000\u000fU\u0001\u0000"+
"\u0000\u0000\u0011\\\u0001\u0000\u0000\u0000\u0013a\u0001\u0000\u0000"+
"\u0000\u0015o\u0001\u0000\u0000\u0000\u0017q\u0001\u0000\u0000\u0000\u0019"+
"t\u0001\u0000\u0000\u0000\u001by\u0001\u0000\u0000\u0000\u001d}\u0001"+
"\u0000\u0000\u0000\u001f\u0083\u0001\u0000\u0000\u0000!\u0086\u0001\u0000"+
"\u0000\u0000#\u008d\u0001\u0000\u0000\u0000%\u0093\u0001\u0000\u0000\u0000"+
"\'\u009c\u0001\u0000\u0000\u0000)\u00a1\u0001\u0000\u0000\u0000+\u00a7"+
"\u0001\u0000\u0000\u0000-\u00ae\u0001\u0000\u0000\u0000/\u00b2\u0001\u0000"+
"\u0000\u00001\u00b4\u0001\u0000\u0000\u00003\u00b6\u0001\u0000\u0000\u0000"+
"5\u00b8\u0001\u0000\u0000\u00007\u00bc\u0001\u0000\u0000\u00009\u00c4"+
"\u0001\u0000\u0000\u0000;\u00c9\u0001\u0000\u0000\u0000=\u00ce\u0001\u0000"+
"\u0000\u0000?\u00d3\u0001\u0000\u0000\u0000A\u00d7\u0001\u0000\u0000\u0000"+
"CD\u0005c\u0000\u0000DE\u0005l\u0000\u0000EF\u0005a\u0000\u0000FG\u0005"+
"s\u0000\u0000GH\u0005s\u0000\u0000H\u0002\u0001\u0000\u0000\u0000IJ\u0005"+
"{\u0000\u0000J\u0004\u0001\u0000\u0000\u0000KL\u0005}\u0000\u0000L\u0006"+
"\u0001\u0000\u0000\u0000MN\u0005;\u0000\u0000N\b\u0001\u0000\u0000\u0000"+
"OP\u0005=\u0000\u0000P\n\u0001\u0000\u0000\u0000QR\u0005(\u0000\u0000"+
"R\f\u0001\u0000\u0000\u0000ST\u0005)\u0000\u0000T\u000e\u0001\u0000\u0000"+
"\u0000UV\u0005s\u0000\u0000VW\u0005t\u0000\u0000WX\u0005a\u0000\u0000"+
"XY\u0005t\u0000\u0000YZ\u0005i\u0000\u0000Z[\u0005c\u0000\u0000[\u0010"+
"\u0001\u0000\u0000\u0000\\]\u0005m\u0000\u0000]^\u0005a\u0000\u0000^_"+
"\u0005i\u0000\u0000_`\u0005n\u0000\u0000`\u0012\u0001\u0000\u0000\u0000"+
"ab\u0005S\u0000\u0000bc\u0005t\u0000\u0000cd\u0005r\u0000\u0000de\u0005"+
"i\u0000\u0000ef\u0005n\u0000\u0000fg\u0005g\u0000\u0000gh\u0005[\u0000"+
"\u0000hi\u0005]\u0000\u0000ij\u0005 \u0000\u0000jk\u0005a\u0000\u0000"+
"kl\u0005r\u0000\u0000lm\u0005g\u0000\u0000mn\u0005s\u0000\u0000n\u0014"+
"\u0001\u0000\u0000\u0000op\u0005,\u0000\u0000p\u0016\u0001\u0000\u0000"+
"\u0000qr\u0005i\u0000\u0000rs\u0005f\u0000\u0000s\u0018\u0001\u0000\u0000"+
"\u0000tu\u0005e\u0000\u0000uv\u0005l\u0000\u0000vw\u0005s\u0000\u0000"+
"wx\u0005e\u0000\u0000x\u001a\u0001\u0000\u0000\u0000yz\u0005f\u0000\u0000"+
"z{\u0005o\u0000\u0000{|\u0005r\u0000\u0000|\u001c\u0001\u0000\u0000\u0000"+
"}~\u0005w\u0000\u0000~\u007f\u0005h\u0000\u0000\u007f\u0080\u0005i\u0000"+
"\u0000\u0080\u0081\u0005l\u0000\u0000\u0081\u0082\u0005e\u0000\u0000\u0082"+
"\u001e\u0001\u0000\u0000\u0000\u0083\u0084\u0005d\u0000\u0000\u0084\u0085"+
"\u0005o\u0000\u0000\u0085 \u0001\u0000\u0000\u0000\u0086\u0087\u0005r"+
"\u0000\u0000\u0087\u0088\u0005e\u0000\u0000\u0088\u0089\u0005t\u0000\u0000"+
"\u0089\u008a\u0005u\u0000\u0000\u008a\u008b\u0005r\u0000\u0000\u008b\u008c"+
"\u0005n\u0000\u0000\u008c\"\u0001\u0000\u0000\u0000\u008d\u008e\u0005"+
"b\u0000\u0000\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005e\u0000"+
"\u0000\u0090\u0091\u0005a\u0000\u0000\u0091\u0092\u0005k\u0000\u0000\u0092"+
"$\u0001\u0000\u0000\u0000\u0093\u0094\u0005c\u0000\u0000\u0094\u0095\u0005"+
"o\u0000\u0000\u0095\u0096\u0005n\u0000\u0000\u0096\u0097\u0005t\u0000"+
"\u0000\u0097\u0098\u0005i\u0000\u0000\u0098\u0099\u0005n\u0000\u0000\u0099"+
"\u009a\u0005u\u0000\u0000\u009a\u009b\u0005e\u0000\u0000\u009b&\u0001"+
"\u0000\u0000\u0000\u009c\u009d\u0005t\u0000\u0000\u009d\u009e\u0005r\u0000"+
"\u0000\u009e\u009f\u0005u\u0000\u0000\u009f\u00a0\u0005e\u0000\u0000\u00a0"+
"(\u0001\u0000\u0000\u0000\u00a1\u00a2\u0005f\u0000\u0000\u00a2\u00a3\u0005"+
"a\u0000\u0000\u00a3\u00a4\u0005l\u0000\u0000\u00a4\u00a5\u0005s\u0000"+
"\u0000\u00a5\u00a6\u0005e\u0000\u0000\u00a6*\u0001\u0000\u0000\u0000\u00a7"+
"\u00a8\u0005p\u0000\u0000\u00a8\u00a9\u0005u\u0000\u0000\u00a9\u00aa\u0005"+
"b\u0000\u0000\u00aa\u00ab\u0005l\u0000\u0000\u00ab\u00ac\u0005i\u0000"+
"\u0000\u00ac\u00ad\u0005c\u0000\u0000\u00ad,\u0001\u0000\u0000\u0000\u00ae"+
"\u00af\u0005n\u0000\u0000\u00af\u00b0\u0005e\u0000\u0000\u00b0\u00b1\u0005"+
"w\u0000\u0000\u00b1.\u0001\u0000\u0000\u0000\u00b2\u00b3\u0005-\u0000"+
"\u0000\u00b30\u0001\u0000\u0000\u0000\u00b4\u00b5\u0005+\u0000\u0000\u00b5"+
"2\u0001\u0000\u0000\u0000\u00b6\u00b7\u0005*\u0000\u0000\u00b74\u0001"+
"\u0000\u0000\u0000\u00b8\u00b9\u0005i\u0000\u0000\u00b9\u00ba\u0005n\u0000"+
"\u0000\u00ba\u00bb\u0005t\u0000\u0000\u00bb6\u0001\u0000\u0000\u0000\u00bc"+
"\u00bd\u0005b\u0000\u0000\u00bd\u00be\u0005o\u0000\u0000\u00be\u00bf\u0005"+
"o\u0000\u0000\u00bf\u00c0\u0005l\u0000\u0000\u00c0\u00c1\u0005e\u0000"+
"\u0000\u00c1\u00c2\u0005a\u0000\u0000\u00c2\u00c3\u0005n\u0000\u0000\u00c3"+
"8\u0001\u0000\u0000\u0000\u00c4\u00c5\u0005v\u0000\u0000\u00c5\u00c6\u0005"+
"o\u0000\u0000\u00c6\u00c7\u0005i\u0000\u0000\u00c7\u00c8\u0005d\u0000"+
"\u0000\u00c8:\u0001\u0000\u0000\u0000\u00c9\u00ca\u0007\u0000\u0000\u0000"+
"\u00ca\u00cb\u0007\u0001\u0000\u0000\u00cb\u00cc\u0007\u0000\u0000\u0000"+
"\u00cc<\u0001\u0000\u0000\u0000\u00cd\u00cf\u0007\u0001\u0000\u0000\u00ce"+
"\u00cd\u0001\u0000\u0000\u0000\u00cf\u00d0\u0001\u0000\u0000\u0000\u00d0"+
"\u00ce\u0001\u0000\u0000\u0000\u00d0\u00d1\u0001\u0000\u0000\u0000\u00d1"+
">\u0001\u0000\u0000\u0000\u00d2\u00d4\u0007\u0002\u0000\u0000\u00d3\u00d2"+
"\u0001\u0000\u0000\u0000\u00d4\u00d5\u0001\u0000\u0000\u0000\u00d5\u00d3"+
"\u0001\u0000\u0000\u0000\u00d5\u00d6\u0001\u0000\u0000\u0000\u00d6@\u0001"+
"\u0000\u0000\u0000\u00d7\u00d8\u0007\u0003\u0000\u0000\u00d8\u00d9\u0001"+
"\u0000\u0000\u0000\u00d9\u00da\u0006 \u0000\u0000\u00daB\u0001\u0000\u0000"+
"\u0000\u0003\u0000\u00d0\u00d5\u0001\u0006\u0000\u0000";
"9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\'O(Q)S*U+W,Y-[.]/_0\u0001\u0000"+
"\u0004\u0001\u0000\'\'\u0002\u0000AZaz\u0001\u000009\u0003\u0000\t\n\r"+
"\r \u012d\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\u0000"+
"3\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\u0000"+
"A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000\u0000\u0000E\u0001"+
"\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000I\u0001\u0000\u0000"+
"\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001\u0000\u0000\u0000\u0000"+
"O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000\u0000\u0000S\u0001"+
"\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000W\u0001\u0000\u0000"+
"\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001\u0000\u0000\u0000\u0000"+
"]\u0001\u0000\u0000\u0000\u0000_\u0001\u0000\u0000\u0000\u0001a\u0001"+
"\u0000\u0000\u0000\u0003g\u0001\u0000\u0000\u0000\u0005i\u0001\u0000\u0000"+
"\u0000\u0007k\u0001\u0000\u0000\u0000\tm\u0001\u0000\u0000\u0000\u000b"+
"o\u0001\u0000\u0000\u0000\rq\u0001\u0000\u0000\u0000\u000fx\u0001\u0000"+
"\u0000\u0000\u0011}\u0001\u0000\u0000\u0000\u0013\u008b\u0001\u0000\u0000"+
"\u0000\u0015\u008d\u0001\u0000\u0000\u0000\u0017\u0090\u0001\u0000\u0000"+
"\u0000\u0019\u0095\u0001\u0000\u0000\u0000\u001b\u0099\u0001\u0000\u0000"+
"\u0000\u001d\u009f\u0001\u0000\u0000\u0000\u001f\u00a2\u0001\u0000\u0000"+
"\u0000!\u00a9\u0001\u0000\u0000\u0000#\u00af\u0001\u0000\u0000\u0000%"+
"\u00b8\u0001\u0000\u0000\u0000\'\u00ba\u0001\u0000\u0000\u0000)\u00c1"+
"\u0001\u0000\u0000\u0000+\u00c5\u0001\u0000\u0000\u0000-\u00ca\u0001\u0000"+
"\u0000\u0000/\u00cf\u0001\u0000\u0000\u00001\u00d1\u0001\u0000\u0000\u0000"+
"3\u00d3\u0001\u0000\u0000\u00005\u00d5\u0001\u0000\u0000\u00007\u00d7"+
"\u0001\u0000\u0000\u00009\u00d9\u0001\u0000\u0000\u0000;\u00dc\u0001\u0000"+
"\u0000\u0000=\u00df\u0001\u0000\u0000\u0000?\u00e2\u0001\u0000\u0000\u0000"+
"A\u00e5\u0001\u0000\u0000\u0000C\u00e8\u0001\u0000\u0000\u0000E\u00eb"+
"\u0001\u0000\u0000\u0000G\u00ed\u0001\u0000\u0000\u0000I\u00f0\u0001\u0000"+
"\u0000\u0000K\u00f3\u0001\u0000\u0000\u0000M\u00f6\u0001\u0000\u0000\u0000"+
"O\u00f8\u0001\u0000\u0000\u0000Q\u00fc\u0001\u0000\u0000\u0000S\u0104"+
"\u0001\u0000\u0000\u0000U\u0109\u0001\u0000\u0000\u0000W\u0117\u0001\u0000"+
"\u0000\u0000Y\u0119\u0001\u0000\u0000\u0000[\u011e\u0001\u0000\u0000\u0000"+
"]\u0123\u0001\u0000\u0000\u0000_\u0127\u0001\u0000\u0000\u0000ab\u0005"+
"c\u0000\u0000bc\u0005l\u0000\u0000cd\u0005a\u0000\u0000de\u0005s\u0000"+
"\u0000ef\u0005s\u0000\u0000f\u0002\u0001\u0000\u0000\u0000gh\u0005{\u0000"+
"\u0000h\u0004\u0001\u0000\u0000\u0000ij\u0005}\u0000\u0000j\u0006\u0001"+
"\u0000\u0000\u0000kl\u0005;\u0000\u0000l\b\u0001\u0000\u0000\u0000mn\u0005"+
"(\u0000\u0000n\n\u0001\u0000\u0000\u0000op\u0005)\u0000\u0000p\f\u0001"+
"\u0000\u0000\u0000qr\u0005s\u0000\u0000rs\u0005t\u0000\u0000st\u0005a"+
"\u0000\u0000tu\u0005t\u0000\u0000uv\u0005i\u0000\u0000vw\u0005c\u0000"+
"\u0000w\u000e\u0001\u0000\u0000\u0000xy\u0005m\u0000\u0000yz\u0005a\u0000"+
"\u0000z{\u0005i\u0000\u0000{|\u0005n\u0000\u0000|\u0010\u0001\u0000\u0000"+
"\u0000}~\u0005S\u0000\u0000~\u007f\u0005t\u0000\u0000\u007f\u0080\u0005"+
"r\u0000\u0000\u0080\u0081\u0005i\u0000\u0000\u0081\u0082\u0005n\u0000"+
"\u0000\u0082\u0083\u0005g\u0000\u0000\u0083\u0084\u0005[\u0000\u0000\u0084"+
"\u0085\u0005]\u0000\u0000\u0085\u0086\u0005 \u0000\u0000\u0086\u0087\u0005"+
"a\u0000\u0000\u0087\u0088\u0005r\u0000\u0000\u0088\u0089\u0005g\u0000"+
"\u0000\u0089\u008a\u0005s\u0000\u0000\u008a\u0012\u0001\u0000\u0000\u0000"+
"\u008b\u008c\u0005,\u0000\u0000\u008c\u0014\u0001\u0000\u0000\u0000\u008d"+
"\u008e\u0005i\u0000\u0000\u008e\u008f\u0005f\u0000\u0000\u008f\u0016\u0001"+
"\u0000\u0000\u0000\u0090\u0091\u0005e\u0000\u0000\u0091\u0092\u0005l\u0000"+
"\u0000\u0092\u0093\u0005s\u0000\u0000\u0093\u0094\u0005e\u0000\u0000\u0094"+
"\u0018\u0001\u0000\u0000\u0000\u0095\u0096\u0005f\u0000\u0000\u0096\u0097"+
"\u0005o\u0000\u0000\u0097\u0098\u0005r\u0000\u0000\u0098\u001a\u0001\u0000"+
"\u0000\u0000\u0099\u009a\u0005w\u0000\u0000\u009a\u009b\u0005h\u0000\u0000"+
"\u009b\u009c\u0005i\u0000\u0000\u009c\u009d\u0005l\u0000\u0000\u009d\u009e"+
"\u0005e\u0000\u0000\u009e\u001c\u0001\u0000\u0000\u0000\u009f\u00a0\u0005"+
"d\u0000\u0000\u00a0\u00a1\u0005o\u0000\u0000\u00a1\u001e\u0001\u0000\u0000"+
"\u0000\u00a2\u00a3\u0005r\u0000\u0000\u00a3\u00a4\u0005e\u0000\u0000\u00a4"+
"\u00a5\u0005t\u0000\u0000\u00a5\u00a6\u0005u\u0000\u0000\u00a6\u00a7\u0005"+
"r\u0000\u0000\u00a7\u00a8\u0005n\u0000\u0000\u00a8 \u0001\u0000\u0000"+
"\u0000\u00a9\u00aa\u0005b\u0000\u0000\u00aa\u00ab\u0005r\u0000\u0000\u00ab"+
"\u00ac\u0005e\u0000\u0000\u00ac\u00ad\u0005a\u0000\u0000\u00ad\u00ae\u0005"+
"k\u0000\u0000\u00ae\"\u0001\u0000\u0000\u0000\u00af\u00b0\u0005c\u0000"+
"\u0000\u00b0\u00b1\u0005o\u0000\u0000\u00b1\u00b2\u0005n\u0000\u0000\u00b2"+
"\u00b3\u0005t\u0000\u0000\u00b3\u00b4\u0005i\u0000\u0000\u00b4\u00b5\u0005"+
"n\u0000\u0000\u00b5\u00b6\u0005u\u0000\u0000\u00b6\u00b7\u0005e\u0000"+
"\u0000\u00b7$\u0001\u0000\u0000\u0000\u00b8\u00b9\u0005.\u0000\u0000\u00b9"+
"&\u0001\u0000\u0000\u0000\u00ba\u00bb\u0005p\u0000\u0000\u00bb\u00bc\u0005"+
"u\u0000\u0000\u00bc\u00bd\u0005b\u0000\u0000\u00bd\u00be\u0005l\u0000"+
"\u0000\u00be\u00bf\u0005i\u0000\u0000\u00bf\u00c0\u0005c\u0000\u0000\u00c0"+
"(\u0001\u0000\u0000\u0000\u00c1\u00c2\u0005n\u0000\u0000\u00c2\u00c3\u0005"+
"e\u0000\u0000\u00c3\u00c4\u0005w\u0000\u0000\u00c4*\u0001\u0000\u0000"+
"\u0000\u00c5\u00c6\u0005n\u0000\u0000\u00c6\u00c7\u0005u\u0000\u0000\u00c7"+
"\u00c8\u0005l\u0000\u0000\u00c8\u00c9\u0005l\u0000\u0000\u00c9,\u0001"+
"\u0000\u0000\u0000\u00ca\u00cb\u0005t\u0000\u0000\u00cb\u00cc\u0005h\u0000"+
"\u0000\u00cc\u00cd\u0005i\u0000\u0000\u00cd\u00ce\u0005s\u0000\u0000\u00ce"+
".\u0001\u0000\u0000\u0000\u00cf\u00d0\u0005-\u0000\u0000\u00d00\u0001"+
"\u0000\u0000\u0000\u00d1\u00d2\u0005+\u0000\u0000\u00d22\u0001\u0000\u0000"+
"\u0000\u00d3\u00d4\u0005*\u0000\u0000\u00d44\u0001\u0000\u0000\u0000\u00d5"+
"\u00d6\u0005>\u0000\u0000\u00d66\u0001\u0000\u0000\u0000\u00d7\u00d8\u0005"+
"<\u0000\u0000\u00d88\u0001\u0000\u0000\u0000\u00d9\u00da\u0005>\u0000"+
"\u0000\u00da\u00db\u0005=\u0000\u0000\u00db:\u0001\u0000\u0000\u0000\u00dc"+
"\u00dd\u0005<\u0000\u0000\u00dd\u00de\u0005=\u0000\u0000\u00de<\u0001"+
"\u0000\u0000\u0000\u00df\u00e0\u0005=\u0000\u0000\u00e0\u00e1\u0005=\u0000"+
"\u0000\u00e1>\u0001\u0000\u0000\u0000\u00e2\u00e3\u0005!\u0000\u0000\u00e3"+
"\u00e4\u0005=\u0000\u0000\u00e4@\u0001\u0000\u0000\u0000\u00e5\u00e6\u0005"+
"&\u0000\u0000\u00e6\u00e7\u0005&\u0000\u0000\u00e7B\u0001\u0000\u0000"+
"\u0000\u00e8\u00e9\u0005|\u0000\u0000\u00e9\u00ea\u0005|\u0000\u0000\u00ea"+
"D\u0001\u0000\u0000\u0000\u00eb\u00ec\u0005=\u0000\u0000\u00ecF\u0001"+
"\u0000\u0000\u0000\u00ed\u00ee\u0005+\u0000\u0000\u00ee\u00ef\u0005=\u0000"+
"\u0000\u00efH\u0001\u0000\u0000\u0000\u00f0\u00f1\u0005-\u0000\u0000\u00f1"+
"\u00f2\u0005=\u0000\u0000\u00f2J\u0001\u0000\u0000\u0000\u00f3\u00f4\u0005"+
"*\u0000\u0000\u00f4\u00f5\u0005=\u0000\u0000\u00f5L\u0001\u0000\u0000"+
"\u0000\u00f6\u00f7\u0005!\u0000\u0000\u00f7N\u0001\u0000\u0000\u0000\u00f8"+
"\u00f9\u0005i\u0000\u0000\u00f9\u00fa\u0005n\u0000\u0000\u00fa\u00fb\u0005"+
"t\u0000\u0000\u00fbP\u0001\u0000\u0000\u0000\u00fc\u00fd\u0005b\u0000"+
"\u0000\u00fd\u00fe\u0005o\u0000\u0000\u00fe\u00ff\u0005o\u0000\u0000\u00ff"+
"\u0100\u0005l\u0000\u0000\u0100\u0101\u0005e\u0000\u0000\u0101\u0102\u0005"+
"a\u0000\u0000\u0102\u0103\u0005n\u0000\u0000\u0103R\u0001\u0000\u0000"+
"\u0000\u0104\u0105\u0005v\u0000\u0000\u0105\u0106\u0005o\u0000\u0000\u0106"+
"\u0107\u0005i\u0000\u0000\u0107\u0108\u0005d\u0000\u0000\u0108T\u0001"+
"\u0000\u0000\u0000\u0109\u010a\u0005c\u0000\u0000\u010a\u010b\u0005h\u0000"+
"\u0000\u010b\u010c\u0005a\u0000\u0000\u010c\u010d\u0005r\u0000\u0000\u010d"+
"V\u0001\u0000\u0000\u0000\u010e\u010f\u0005t\u0000\u0000\u010f\u0110\u0005"+
"r\u0000\u0000\u0110\u0111\u0005u\u0000\u0000\u0111\u0118\u0005e\u0000"+
"\u0000\u0112\u0113\u0005f\u0000\u0000\u0113\u0114\u0005a\u0000\u0000\u0114"+
"\u0115\u0005l\u0000\u0000\u0115\u0116\u0005s\u0000\u0000\u0116\u0118\u0005"+
"e\u0000\u0000\u0117\u010e\u0001\u0000\u0000\u0000\u0117\u0112\u0001\u0000"+
"\u0000\u0000\u0118X\u0001\u0000\u0000\u0000\u0119\u011a\u0007\u0000\u0000"+
"\u0000\u011a\u011b\u0007\u0001\u0000\u0000\u011b\u011c\u0007\u0000\u0000"+
"\u0000\u011cZ\u0001\u0000\u0000\u0000\u011d\u011f\u0007\u0001\u0000\u0000"+
"\u011e\u011d\u0001\u0000\u0000\u0000\u011f\u0120\u0001\u0000\u0000\u0000"+
"\u0120\u011e\u0001\u0000\u0000\u0000\u0120\u0121\u0001\u0000\u0000\u0000"+
"\u0121\\\u0001\u0000\u0000\u0000\u0122\u0124\u0007\u0002\u0000\u0000\u0123"+
"\u0122\u0001\u0000\u0000\u0000\u0124\u0125\u0001\u0000\u0000\u0000\u0125"+
"\u0123\u0001\u0000\u0000\u0000\u0125\u0126\u0001\u0000\u0000\u0000\u0126"+
"^\u0001\u0000\u0000\u0000\u0127\u0128\u0007\u0003\u0000\u0000\u0128\u0129"+
"\u0001\u0000\u0000\u0000\u0129\u012a\u0006/\u0000\u0000\u012a`\u0001\u0000"+
"\u0000\u0000\u0004\u0000\u0117\u0120\u0125\u0001\u0006\u0000\u0000";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {

View File

@ -17,46 +17,75 @@ T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
PUBLIC=22
NEW=23
PUBLIC=20
NEW=21
NULL=22
THIS=23
SUB=24
ADD=25
MUL=26
INT=27
BOOL=28
VOID=29
CHAR=30
IDENTIFIER=31
NUMBER=32
WS=33
GT=27
LT=28
GE=29
LE=30
EQ=31
NE=32
AND=33
OR=34
ASSIGN=35
ADD_ASSIGN=36
SUB_ASSIGN=37
MUL_ASSIGN=38
NOT=39
INT=40
BOOL=41
VOID=42
CHAR=43
BOOLEANLITERAL=44
CHARLITERAL=45
IDENTIFIER=46
NUMBER=47
WS=48
'class'=1
'{'=2
'}'=3
';'=4
'='=5
'('=6
')'=7
'static'=8
'main'=9
'String[] args'=10
','=11
'if'=12
'else'=13
'for'=14
'while'=15
'do'=16
'return'=17
'break'=18
'continue'=19
'true'=20
'false'=21
'public'=22
'new'=23
'('=5
')'=6
'static'=7
'main'=8
'String[] args'=9
','=10
'if'=11
'else'=12
'for'=13
'while'=14
'do'=15
'return'=16
'break'=17
'continue'=18
'.'=19
'public'=20
'new'=21
'null'=22
'this'=23
'-'=24
'+'=25
'*'=26
'int'=27
'boolean'=28
'void'=29
'>'=27
'<'=28
'>='=29
'<='=30
'=='=31
'!='=32
'&&'=33
'||'=34
'='=35
'+='=36
'-='=37
'*='=38
'!'=39
'int'=40
'boolean'=41
'void'=42
'char'=43

View File

@ -28,15 +28,35 @@ public interface DecafListener extends ParseTreeListener {
*/
void exitClass(DecafParser.ClassContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#var}.
* Enter a parse tree produced by {@link DecafParser#field}.
* @param ctx the parse tree
*/
void enterVar(DecafParser.VarContext ctx);
void enterField(DecafParser.FieldContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#var}.
* Exit a parse tree produced by {@link DecafParser#field}.
* @param ctx the parse tree
*/
void exitVar(DecafParser.VarContext ctx);
void exitField(DecafParser.FieldContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#localVar}.
* @param ctx the parse tree
*/
void enterLocalVar(DecafParser.LocalVarContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#localVar}.
* @param ctx the parse tree
*/
void exitLocalVar(DecafParser.LocalVarContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#assignSign}.
* @param ctx the parse tree
*/
void enterAssignSign(DecafParser.AssignSignContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#assignSign}.
* @param ctx the parse tree
*/
void exitAssignSign(DecafParser.AssignSignContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#returntype}.
* @param ctx the parse tree
@ -77,6 +97,16 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitMainmeth(DecafParser.MainmethContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#constructor}.
* @param ctx the parse tree
*/
void enterConstructor(DecafParser.ConstructorContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#constructor}.
* @param ctx the parse tree
*/
void exitConstructor(DecafParser.ConstructorContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#params}.
* @param ctx the parse tree
@ -203,6 +233,18 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitContinue(DecafParser.ContinueContext ctx);
/**
* Enter a parse tree produced by the {@code Assignment}
* labeled alternative in {@link DecafParser#stmt}.
* @param ctx the parse tree
*/
void enterAssignment(DecafParser.AssignmentContext ctx);
/**
* Exit a parse tree produced by the {@code Assignment}
* labeled alternative in {@link DecafParser#stmt}.
* @param ctx the parse tree
*/
void exitAssignment(DecafParser.AssignmentContext ctx);
/**
* Enter a parse tree produced by the {@code StatementExpressionstmt}
* labeled alternative in {@link DecafParser#stmt}.
@ -215,18 +257,6 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx);
/**
* Enter a parse tree produced by the {@code Assign}
* labeled alternative in {@link DecafParser#stmtexpr}.
* @param ctx the parse tree
*/
void enterAssign(DecafParser.AssignContext ctx);
/**
* Exit a parse tree produced by the {@code Assign}
* labeled alternative in {@link DecafParser#stmtexpr}.
* @param ctx the parse tree
*/
void exitAssign(DecafParser.AssignContext ctx);
/**
* Enter a parse tree produced by the {@code MethodCall}
* labeled alternative in {@link DecafParser#stmtexpr}.
@ -251,6 +281,30 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitNew(DecafParser.NewContext ctx);
/**
* Enter a parse tree produced by the {@code Null}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void enterNull(DecafParser.NullContext ctx);
/**
* Exit a parse tree produced by the {@code Null}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void exitNull(DecafParser.NullContext ctx);
/**
* Enter a parse tree produced by the {@code UnaryOperation}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void enterUnaryOperation(DecafParser.UnaryOperationContext ctx);
/**
* Exit a parse tree produced by the {@code UnaryOperation}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void exitUnaryOperation(DecafParser.UnaryOperationContext ctx);
/**
* Enter a parse tree produced by the {@code Identifier}
* labeled alternative in {@link DecafParser#expr}.
@ -263,18 +317,6 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitIdentifier(DecafParser.IdentifierContext ctx);
/**
* Enter a parse tree produced by the {@code MethodCallExpression}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void enterMethodCallExpression(DecafParser.MethodCallExpressionContext ctx);
/**
* Exit a parse tree produced by the {@code MethodCallExpression}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
*/
void exitMethodCallExpression(DecafParser.MethodCallExpressionContext ctx);
/**
* Enter a parse tree produced by the {@code Expression}
* labeled alternative in {@link DecafParser#expr}.
@ -333,6 +375,26 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitBinaryOp(DecafParser.BinaryOpContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#unaryOp}.
* @param ctx the parse tree
*/
void enterUnaryOp(DecafParser.UnaryOpContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#unaryOp}.
* @param ctx the parse tree
*/
void exitUnaryOp(DecafParser.UnaryOpContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#fieldId}.
* @param ctx the parse tree
*/
void enterFieldId(DecafParser.FieldIdContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#fieldId}.
* @param ctx the parse tree
*/
void exitFieldId(DecafParser.FieldIdContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#methCall}.
* @param ctx the parse tree
@ -343,6 +405,26 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitMethCall(DecafParser.MethCallContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#recipient}.
* @param ctx the parse tree
*/
void enterRecipient(DecafParser.RecipientContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#recipient}.
* @param ctx the parse tree
*/
void exitRecipient(DecafParser.RecipientContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#methName}.
* @param ctx the parse tree
*/
void enterMethName(DecafParser.MethNameContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#methName}.
* @param ctx the parse tree
*/
void exitMethName(DecafParser.MethNameContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#args}.
* @param ctx the parse tree
@ -363,16 +445,6 @@ public interface DecafListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitLiteral(DecafParser.LiteralContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#boolean}.
* @param ctx the parse tree
*/
void enterBoolean(DecafParser.BooleanContext ctx);
/**
* Exit a parse tree produced by {@link DecafParser#boolean}.
* @param ctx the parse tree
*/
void exitBoolean(DecafParser.BooleanContext ctx);
/**
* Enter a parse tree produced by {@link DecafParser#id}.
* @param ctx the parse tree

File diff suppressed because it is too large Load Diff

View File

@ -23,11 +23,23 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
*/
T visitClass(DecafParser.ClassContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#var}.
* Visit a parse tree produced by {@link DecafParser#field}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitVar(DecafParser.VarContext ctx);
T visitField(DecafParser.FieldContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#localVar}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLocalVar(DecafParser.LocalVarContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#assignSign}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAssignSign(DecafParser.AssignSignContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#returntype}.
* @param ctx the parse tree
@ -52,6 +64,12 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitMainmeth(DecafParser.MainmethContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#constructor}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitConstructor(DecafParser.ConstructorContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#params}.
* @param ctx the parse tree
@ -126,6 +144,13 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitContinue(DecafParser.ContinueContext ctx);
/**
* Visit a parse tree produced by the {@code Assignment}
* labeled alternative in {@link DecafParser#stmt}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAssignment(DecafParser.AssignmentContext ctx);
/**
* Visit a parse tree produced by the {@code StatementExpressionstmt}
* labeled alternative in {@link DecafParser#stmt}.
@ -133,13 +158,6 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx);
/**
* Visit a parse tree produced by the {@code Assign}
* labeled alternative in {@link DecafParser#stmtexpr}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAssign(DecafParser.AssignContext ctx);
/**
* Visit a parse tree produced by the {@code MethodCall}
* labeled alternative in {@link DecafParser#stmtexpr}.
@ -154,6 +172,20 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitNew(DecafParser.NewContext ctx);
/**
* Visit a parse tree produced by the {@code Null}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitNull(DecafParser.NullContext ctx);
/**
* Visit a parse tree produced by the {@code UnaryOperation}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitUnaryOperation(DecafParser.UnaryOperationContext ctx);
/**
* Visit a parse tree produced by the {@code Identifier}
* labeled alternative in {@link DecafParser#expr}.
@ -161,13 +193,6 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitIdentifier(DecafParser.IdentifierContext ctx);
/**
* Visit a parse tree produced by the {@code MethodCallExpression}
* labeled alternative in {@link DecafParser#expr}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitMethodCallExpression(DecafParser.MethodCallExpressionContext ctx);
/**
* Visit a parse tree produced by the {@code Expression}
* labeled alternative in {@link DecafParser#expr}.
@ -202,12 +227,36 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitBinaryOp(DecafParser.BinaryOpContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#unaryOp}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitUnaryOp(DecafParser.UnaryOpContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#fieldId}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFieldId(DecafParser.FieldIdContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#methCall}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitMethCall(DecafParser.MethCallContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#recipient}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitRecipient(DecafParser.RecipientContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#methName}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitMethName(DecafParser.MethNameContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#args}.
* @param ctx the parse tree
@ -220,12 +269,6 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitLiteral(DecafParser.LiteralContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#boolean}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBoolean(DecafParser.BooleanContext ctx);
/**
* Visit a parse tree produced by {@link DecafParser#id}.
* @param ctx the parse tree

View File

@ -2,5 +2,5 @@ package de.maishai.ast.records;
import java.util.List;
public record Class(Id id , List<Field> fields, List<Method> methods) implements Node {
public record Class(Boolean isPublic, Id id , List<Field> fields, List<Method> methods, MainMethod mainMethod, List<Constructor> constructors) implements Node {
}

View File

@ -2,5 +2,5 @@ package de.maishai.ast.records;
import java.util.List;
public record Constructor(Id id, List<Parameter> params, Block block) implements Node {
public record Constructor(Boolean isPublic, Id id, List<Parameter> params, Block block) implements Node {
}

View File

@ -1,5 +1,5 @@
package de.maishai.ast.records;
public sealed interface Expression extends Node permits Binary, BoolLiteral, CharLiteral, Id, IntLiteral, MethodCall, New, Unary {
public sealed interface Expression extends Node permits Binary, BoolLiteral, CharLiteral, FieldId, Id, IntLiteral, MethodCall, New, Unary {
}

View File

@ -1,4 +1,4 @@
package de.maishai.ast.records;
public record FieldId(Boolean field, Expression recipient, Id id) implements Node {
public record FieldId(Boolean field, Expression recipient, Id id) implements Expression {
}

View File

@ -6,5 +6,5 @@ import de.maishai.ast.ReturnType;
import java.util.List;
public record Method(ReturnType type, Id id, List<Parameter> params, Block block) implements Node {
public record Method(Boolean isPublic, ReturnType type, Id id, List<Parameter> params, Block block) implements Node {
}

View File

@ -1,4 +1,4 @@
package de.maishai.ast.records;
public sealed interface Node permits Block, Class, Constructor, Expression, Field, FieldId, LocalVariable, MainMethod, Method, Parameter, Program, Statement {
public sealed interface Node permits Block, Class, Constructor, Expression, Field, LocalVariable, MainMethod, Method, Parameter, Program, Statement {
}