mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 08:38:03 +00:00
Parser can do Else-if
This commit is contained in:
parent
9f6fc527f3
commit
3a267180ba
@ -22,7 +22,7 @@ return: 'return' expr ';'
|
||||
;
|
||||
|
||||
|
||||
stmt : 'if' '(' expr ')' block ('else' block)? #If
|
||||
stmt : ifCall #If
|
||||
| 'for' '(' (assign | localVarWithInitialization) ';' expr ';' assign ')' block #For
|
||||
| 'while' '(' expr ')' block #While
|
||||
| 'do' block 'while' '(' expr ')' ';'? #DoWhile
|
||||
@ -58,7 +58,8 @@ recipient : methName | id;
|
||||
methName : id '(' args? ')';
|
||||
args : expr (',' expr)*;
|
||||
|
||||
|
||||
ifCall: IF '(' expr ')' block (elseIf)* (ELSE block)? ;
|
||||
elseIf: ELSE IF '('expr')' block;
|
||||
|
||||
literal : NUMBER | BOOLEANLITERAL | CHARLITERAL;
|
||||
|
||||
@ -70,6 +71,9 @@ NEW : 'new';
|
||||
NULL : 'null';
|
||||
THIS : 'this';
|
||||
|
||||
IF : 'if';
|
||||
ELSE: 'else';
|
||||
|
||||
SUB : '-';
|
||||
ADD : '+';
|
||||
MUL : '*';
|
||||
|
@ -27,13 +27,22 @@ import java.util.List;
|
||||
public class StatementGenerator extends DecafBaseVisitor<List<Statement>> {
|
||||
@Override
|
||||
public List<Statement> visitIf(DecafParser.IfContext ctx) {
|
||||
Expression expr = new ExpressionGenerator().visit(ctx.expr());
|
||||
Block ifBlock = new BlockGenerator().visit(ctx.block(0));
|
||||
if (ctx.block().size() == 2) {
|
||||
Block elseBlock = new BlockGenerator().visit(ctx.block(1));
|
||||
return List.of(new IfElse(expr, ifBlock, elseBlock));
|
||||
Expression expr = new ExpressionGenerator().visit(ctx.ifCall().expr());
|
||||
Block ifBlock = new BlockGenerator().visit(ctx.ifCall().block(0));
|
||||
Block elseBlock = null;
|
||||
if (ctx.ifCall().block().size() == 2) {
|
||||
elseBlock = new BlockGenerator().visit(ctx.ifCall().block(1));
|
||||
}
|
||||
return List.of(new IfElse(expr, ifBlock, null));
|
||||
if (ctx.ifCall().elseIf() != null){
|
||||
for (int i = ctx.ifCall().elseIf().size()-1; i >= 0; i--) {
|
||||
IfElse current = new IfElse(new ExpressionGenerator().visit(ctx.ifCall().elseIf(i).expr()),
|
||||
new BlockGenerator().visit(ctx.ifCall().elseIf(i).block()),
|
||||
elseBlock);
|
||||
elseBlock = new Block(List.of(current));
|
||||
}
|
||||
}
|
||||
|
||||
return List.of(new IfElse(expr, ifBlock, elseBlock));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
File diff suppressed because one or more lines are too long
@ -14,12 +14,12 @@ T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
PUBLIC=19
|
||||
NEW=20
|
||||
NULL=21
|
||||
THIS=22
|
||||
PUBLIC=17
|
||||
NEW=18
|
||||
NULL=19
|
||||
THIS=20
|
||||
IF=21
|
||||
ELSE=22
|
||||
SUB=23
|
||||
ADD=24
|
||||
MUL=25
|
||||
@ -58,17 +58,17 @@ LINE_COMMENT=49
|
||||
'String[] args'=9
|
||||
','=10
|
||||
'return'=11
|
||||
'if'=12
|
||||
'else'=13
|
||||
'for'=14
|
||||
'while'=15
|
||||
'do'=16
|
||||
'break'=17
|
||||
'.'=18
|
||||
'public'=19
|
||||
'new'=20
|
||||
'null'=21
|
||||
'this'=22
|
||||
'for'=12
|
||||
'while'=13
|
||||
'do'=14
|
||||
'break'=15
|
||||
'.'=16
|
||||
'public'=17
|
||||
'new'=18
|
||||
'null'=19
|
||||
'this'=20
|
||||
'if'=21
|
||||
'else'=22
|
||||
'-'=23
|
||||
'+'=24
|
||||
'*'=25
|
||||
|
@ -492,6 +492,30 @@ public class DecafBaseListener implements DecafListener {
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitArgs(DecafParser.ArgsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIfCall(DecafParser.IfCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIfCall(DecafParser.IfCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterElseIf(DecafParser.ElseIfContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitElseIf(DecafParser.ElseIfContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -292,6 +292,20 @@ public class DecafBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitArgs(DecafParser.ArgsContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitIfCall(DecafParser.IfCallContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitElseIf(DecafParser.ElseIfContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
@ -18,9 +18,9 @@ public class DecafLexer extends Lexer {
|
||||
new PredictionContextCache();
|
||||
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, PUBLIC=19, NEW=20, NULL=21, THIS=22, SUB=23, ADD=24, MUL=25,
|
||||
GT=26, LT=27, GE=28, LE=29, EQ=30, NE=31, AND=32, OR=33, ASSIGN=34, ADD_ASSIGN=35,
|
||||
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, PUBLIC=17,
|
||||
NEW=18, NULL=19, THIS=20, IF=21, ELSE=22, SUB=23, ADD=24, MUL=25, GT=26,
|
||||
LT=27, GE=28, LE=29, EQ=30, NE=31, AND=32, OR=33, ASSIGN=34, ADD_ASSIGN=35,
|
||||
SUB_ASSIGN=36, MUL_ASSIGN=37, NOT=38, INT=39, BOOL=40, VOID=41, CHAR=42,
|
||||
BOOLEANLITERAL=43, CHARLITERAL=44, IDENTIFIER=45, NUMBER=46, WS=47, COMMENT=48,
|
||||
LINE_COMMENT=49;
|
||||
@ -35,9 +35,9 @@ public class DecafLexer extends Lexer {
|
||||
private static String[] makeRuleNames() {
|
||||
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", "PUBLIC", "NEW", "NULL", "THIS", "SUB", "ADD", "MUL", "GT",
|
||||
"LT", "GE", "LE", "EQ", "NE", "AND", "OR", "ASSIGN", "ADD_ASSIGN", "SUB_ASSIGN",
|
||||
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "PUBLIC",
|
||||
"NEW", "NULL", "THIS", "IF", "ELSE", "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", "COMMENT", "LINE_COMMENT"
|
||||
};
|
||||
@ -47,8 +47,8 @@ public class DecafLexer extends Lexer {
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'class'", "'{'", "'}'", "';'", "'('", "')'", "'static'", "'main'",
|
||||
"'String[] args'", "','", "'return'", "'if'", "'else'", "'for'", "'while'",
|
||||
"'do'", "'break'", "'.'", "'public'", "'new'", "'null'", "'this'", "'-'",
|
||||
"'String[] args'", "','", "'return'", "'for'", "'while'", "'do'", "'break'",
|
||||
"'.'", "'public'", "'new'", "'null'", "'this'", "'if'", "'else'", "'-'",
|
||||
"'+'", "'*'", "'>'", "'<'", "'>='", "'<='", "'=='", "'!='", "'&&'", "'||'",
|
||||
"'='", "'+='", "'-='", "'*='", "'!'", "'int'", "'boolean'", "'void'",
|
||||
"'char'"
|
||||
@ -58,11 +58,11 @@ public class DecafLexer extends Lexer {
|
||||
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, "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", "COMMENT", "LINE_COMMENT"
|
||||
null, null, null, null, null, "PUBLIC", "NEW", "NULL", "THIS", "IF",
|
||||
"ELSE", "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", "COMMENT", "LINE_COMMENT"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
@ -145,13 +145,13 @@ public class DecafLexer extends Lexer {
|
||||
"\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\n\u0001"+
|
||||
"\n\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"+
|
||||
"\n\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+
|
||||
"\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001"+
|
||||
"\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001"+
|
||||
"\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+
|
||||
"\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001"+
|
||||
"\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013\u0001"+
|
||||
"\u0013\u0001\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001"+
|
||||
"\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+
|
||||
"\u0011\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\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001"+
|
||||
"\u0015\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001\u0018\u0001"+
|
||||
"\u0018\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001b\u0001"+
|
||||
@ -201,10 +201,10 @@ public class DecafLexer extends Lexer {
|
||||
"\u0000\u0000\u0000\rs\u0001\u0000\u0000\u0000\u000fz\u0001\u0000\u0000"+
|
||||
"\u0000\u0011\u007f\u0001\u0000\u0000\u0000\u0013\u008d\u0001\u0000\u0000"+
|
||||
"\u0000\u0015\u008f\u0001\u0000\u0000\u0000\u0017\u0096\u0001\u0000\u0000"+
|
||||
"\u0000\u0019\u0099\u0001\u0000\u0000\u0000\u001b\u009e\u0001\u0000\u0000"+
|
||||
"\u0000\u001d\u00a2\u0001\u0000\u0000\u0000\u001f\u00a8\u0001\u0000\u0000"+
|
||||
"\u0000!\u00ab\u0001\u0000\u0000\u0000#\u00b1\u0001\u0000\u0000\u0000%"+
|
||||
"\u00b3\u0001\u0000\u0000\u0000\'\u00ba\u0001\u0000\u0000\u0000)\u00be"+
|
||||
"\u0000\u0019\u009a\u0001\u0000\u0000\u0000\u001b\u00a0\u0001\u0000\u0000"+
|
||||
"\u0000\u001d\u00a3\u0001\u0000\u0000\u0000\u001f\u00a9\u0001\u0000\u0000"+
|
||||
"\u0000!\u00ab\u0001\u0000\u0000\u0000#\u00b2\u0001\u0000\u0000\u0000%"+
|
||||
"\u00b6\u0001\u0000\u0000\u0000\'\u00bb\u0001\u0000\u0000\u0000)\u00c0"+
|
||||
"\u0001\u0000\u0000\u0000+\u00c3\u0001\u0000\u0000\u0000-\u00c8\u0001\u0000"+
|
||||
"\u0000\u0000/\u00ca\u0001\u0000\u0000\u00001\u00cc\u0001\u0000\u0000\u0000"+
|
||||
"3\u00ce\u0001\u0000\u0000\u00005\u00d0\u0001\u0000\u0000\u00007\u00d2"+
|
||||
@ -236,90 +236,90 @@ public class DecafLexer extends Lexer {
|
||||
"\u0014\u0001\u0000\u0000\u0000\u008f\u0090\u0005r\u0000\u0000\u0090\u0091"+
|
||||
"\u0005e\u0000\u0000\u0091\u0092\u0005t\u0000\u0000\u0092\u0093\u0005u"+
|
||||
"\u0000\u0000\u0093\u0094\u0005r\u0000\u0000\u0094\u0095\u0005n\u0000\u0000"+
|
||||
"\u0095\u0016\u0001\u0000\u0000\u0000\u0096\u0097\u0005i\u0000\u0000\u0097"+
|
||||
"\u0098\u0005f\u0000\u0000\u0098\u0018\u0001\u0000\u0000\u0000\u0099\u009a"+
|
||||
"\u0005e\u0000\u0000\u009a\u009b\u0005l\u0000\u0000\u009b\u009c\u0005s"+
|
||||
"\u0000\u0000\u009c\u009d\u0005e\u0000\u0000\u009d\u001a\u0001\u0000\u0000"+
|
||||
"\u0000\u009e\u009f\u0005f\u0000\u0000\u009f\u00a0\u0005o\u0000\u0000\u00a0"+
|
||||
"\u00a1\u0005r\u0000\u0000\u00a1\u001c\u0001\u0000\u0000\u0000\u00a2\u00a3"+
|
||||
"\u0005w\u0000\u0000\u00a3\u00a4\u0005h\u0000\u0000\u00a4\u00a5\u0005i"+
|
||||
"\u0000\u0000\u00a5\u00a6\u0005l\u0000\u0000\u00a6\u00a7\u0005e\u0000\u0000"+
|
||||
"\u00a7\u001e\u0001\u0000\u0000\u0000\u00a8\u00a9\u0005d\u0000\u0000\u00a9"+
|
||||
"\u00aa\u0005o\u0000\u0000\u00aa \u0001\u0000\u0000\u0000\u00ab\u00ac\u0005"+
|
||||
"b\u0000\u0000\u00ac\u00ad\u0005r\u0000\u0000\u00ad\u00ae\u0005e\u0000"+
|
||||
"\u0000\u00ae\u00af\u0005a\u0000\u0000\u00af\u00b0\u0005k\u0000\u0000\u00b0"+
|
||||
"\"\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005.\u0000\u0000\u00b2$\u0001"+
|
||||
"\u0000\u0000\u0000\u00b3\u00b4\u0005p\u0000\u0000\u00b4\u00b5\u0005u\u0000"+
|
||||
"\u0000\u00b5\u00b6\u0005b\u0000\u0000\u00b6\u00b7\u0005l\u0000\u0000\u00b7"+
|
||||
"\u00b8\u0005i\u0000\u0000\u00b8\u00b9\u0005c\u0000\u0000\u00b9&\u0001"+
|
||||
"\u0000\u0000\u0000\u00ba\u00bb\u0005n\u0000\u0000\u00bb\u00bc\u0005e\u0000"+
|
||||
"\u0000\u00bc\u00bd\u0005w\u0000\u0000\u00bd(\u0001\u0000\u0000\u0000\u00be"+
|
||||
"\u00bf\u0005n\u0000\u0000\u00bf\u00c0\u0005u\u0000\u0000\u00c0\u00c1\u0005"+
|
||||
"l\u0000\u0000\u00c1\u00c2\u0005l\u0000\u0000\u00c2*\u0001\u0000\u0000"+
|
||||
"\u0000\u00c3\u00c4\u0005t\u0000\u0000\u00c4\u00c5\u0005h\u0000\u0000\u00c5"+
|
||||
"\u00c6\u0005i\u0000\u0000\u00c6\u00c7\u0005s\u0000\u0000\u00c7,\u0001"+
|
||||
"\u0000\u0000\u0000\u00c8\u00c9\u0005-\u0000\u0000\u00c9.\u0001\u0000\u0000"+
|
||||
"\u0000\u00ca\u00cb\u0005+\u0000\u0000\u00cb0\u0001\u0000\u0000\u0000\u00cc"+
|
||||
"\u00cd\u0005*\u0000\u0000\u00cd2\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005"+
|
||||
">\u0000\u0000\u00cf4\u0001\u0000\u0000\u0000\u00d0\u00d1\u0005<\u0000"+
|
||||
"\u0000\u00d16\u0001\u0000\u0000\u0000\u00d2\u00d3\u0005>\u0000\u0000\u00d3"+
|
||||
"\u00d4\u0005=\u0000\u0000\u00d48\u0001\u0000\u0000\u0000\u00d5\u00d6\u0005"+
|
||||
"<\u0000\u0000\u00d6\u00d7\u0005=\u0000\u0000\u00d7:\u0001\u0000\u0000"+
|
||||
"\u0000\u00d8\u00d9\u0005=\u0000\u0000\u00d9\u00da\u0005=\u0000\u0000\u00da"+
|
||||
"<\u0001\u0000\u0000\u0000\u00db\u00dc\u0005!\u0000\u0000\u00dc\u00dd\u0005"+
|
||||
"=\u0000\u0000\u00dd>\u0001\u0000\u0000\u0000\u00de\u00df\u0005&\u0000"+
|
||||
"\u0000\u00df\u00e0\u0005&\u0000\u0000\u00e0@\u0001\u0000\u0000\u0000\u00e1"+
|
||||
"\u00e2\u0005|\u0000\u0000\u00e2\u00e3\u0005|\u0000\u0000\u00e3B\u0001"+
|
||||
"\u0000\u0000\u0000\u00e4\u00e5\u0005=\u0000\u0000\u00e5D\u0001\u0000\u0000"+
|
||||
"\u0000\u00e6\u00e7\u0005+\u0000\u0000\u00e7\u00e8\u0005=\u0000\u0000\u00e8"+
|
||||
"F\u0001\u0000\u0000\u0000\u00e9\u00ea\u0005-\u0000\u0000\u00ea\u00eb\u0005"+
|
||||
"=\u0000\u0000\u00ebH\u0001\u0000\u0000\u0000\u00ec\u00ed\u0005*\u0000"+
|
||||
"\u0000\u00ed\u00ee\u0005=\u0000\u0000\u00eeJ\u0001\u0000\u0000\u0000\u00ef"+
|
||||
"\u00f0\u0005!\u0000\u0000\u00f0L\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005"+
|
||||
"i\u0000\u0000\u00f2\u00f3\u0005n\u0000\u0000\u00f3\u00f4\u0005t\u0000"+
|
||||
"\u0000\u00f4N\u0001\u0000\u0000\u0000\u00f5\u00f6\u0005b\u0000\u0000\u00f6"+
|
||||
"\u00f7\u0005o\u0000\u0000\u00f7\u00f8\u0005o\u0000\u0000\u00f8\u00f9\u0005"+
|
||||
"l\u0000\u0000\u00f9\u00fa\u0005e\u0000\u0000\u00fa\u00fb\u0005a\u0000"+
|
||||
"\u0000\u00fb\u00fc\u0005n\u0000\u0000\u00fcP\u0001\u0000\u0000\u0000\u00fd"+
|
||||
"\u00fe\u0005v\u0000\u0000\u00fe\u00ff\u0005o\u0000\u0000\u00ff\u0100\u0005"+
|
||||
"i\u0000\u0000\u0100\u0101\u0005d\u0000\u0000\u0101R\u0001\u0000\u0000"+
|
||||
"\u0000\u0102\u0103\u0005c\u0000\u0000\u0103\u0104\u0005h\u0000\u0000\u0104"+
|
||||
"\u0105\u0005a\u0000\u0000\u0105\u0106\u0005r\u0000\u0000\u0106T\u0001"+
|
||||
"\u0000\u0000\u0000\u0107\u0108\u0005t\u0000\u0000\u0108\u0109\u0005r\u0000"+
|
||||
"\u0000\u0109\u010a\u0005u\u0000\u0000\u010a\u0111\u0005e\u0000\u0000\u010b"+
|
||||
"\u010c\u0005f\u0000\u0000\u010c\u010d\u0005a\u0000\u0000\u010d\u010e\u0005"+
|
||||
"l\u0000\u0000\u010e\u010f\u0005s\u0000\u0000\u010f\u0111\u0005e\u0000"+
|
||||
"\u0000\u0110\u0107\u0001\u0000\u0000\u0000\u0110\u010b\u0001\u0000\u0000"+
|
||||
"\u0000\u0111V\u0001\u0000\u0000\u0000\u0112\u0113\u0007\u0000\u0000\u0000"+
|
||||
"\u0113\u0114\u0007\u0001\u0000\u0000\u0114\u0115\u0007\u0000\u0000\u0000"+
|
||||
"\u0115X\u0001\u0000\u0000\u0000\u0116\u0118\u0007\u0001\u0000\u0000\u0117"+
|
||||
"\u0116\u0001\u0000\u0000\u0000\u0118\u0119\u0001\u0000\u0000\u0000\u0119"+
|
||||
"\u0117\u0001\u0000\u0000\u0000\u0119\u011a\u0001\u0000\u0000\u0000\u011a"+
|
||||
"\u011e\u0001\u0000\u0000\u0000\u011b\u011d\u0007\u0002\u0000\u0000\u011c"+
|
||||
"\u011b\u0001\u0000\u0000\u0000\u011d\u0120\u0001\u0000\u0000\u0000\u011e"+
|
||||
"\u011c\u0001\u0000\u0000\u0000\u011e\u011f\u0001\u0000\u0000\u0000\u011f"+
|
||||
"\u0122\u0001\u0000\u0000\u0000\u0120\u011e\u0001\u0000\u0000\u0000\u0121"+
|
||||
"\u0117\u0001\u0000\u0000\u0000\u0122\u0123\u0001\u0000\u0000\u0000\u0123"+
|
||||
"\u0121\u0001\u0000\u0000\u0000\u0123\u0124\u0001\u0000\u0000\u0000\u0124"+
|
||||
"Z\u0001\u0000\u0000\u0000\u0125\u0127\u0007\u0002\u0000\u0000\u0126\u0125"+
|
||||
"\u0001\u0000\u0000\u0000\u0127\u0128\u0001\u0000\u0000\u0000\u0128\u0126"+
|
||||
"\u0001\u0000\u0000\u0000\u0128\u0129\u0001\u0000\u0000\u0000\u0129\\\u0001"+
|
||||
"\u0000\u0000\u0000\u012a\u012b\u0007\u0003\u0000\u0000\u012b\u012c\u0001"+
|
||||
"\u0000\u0000\u0000\u012c\u012d\u0006.\u0000\u0000\u012d^\u0001\u0000\u0000"+
|
||||
"\u0000\u012e\u012f\u0005/\u0000\u0000\u012f\u0130\u0005*\u0000\u0000\u0130"+
|
||||
"\u0134\u0001\u0000\u0000\u0000\u0131\u0133\t\u0000\u0000\u0000\u0132\u0131"+
|
||||
"\u0001\u0000\u0000\u0000\u0133\u0136\u0001\u0000\u0000\u0000\u0134\u0135"+
|
||||
"\u0001\u0000\u0000\u0000\u0134\u0132\u0001\u0000\u0000\u0000\u0135\u0137"+
|
||||
"\u0001\u0000\u0000\u0000\u0136\u0134\u0001\u0000\u0000\u0000\u0137\u0138"+
|
||||
"\u0005*\u0000\u0000\u0138\u0139\u0005/\u0000\u0000\u0139\u013a\u0001\u0000"+
|
||||
"\u0000\u0000\u013a\u013b\u0006/\u0000\u0000\u013b`\u0001\u0000\u0000\u0000"+
|
||||
"\u013c\u013d\u0005/\u0000\u0000\u013d\u013e\u0005/\u0000\u0000\u013e\u0142"+
|
||||
"\u0001\u0000\u0000\u0000\u013f\u0141\b\u0004\u0000\u0000\u0140\u013f\u0001"+
|
||||
"\u0000\u0000\u0000\u0141\u0144\u0001\u0000\u0000\u0000\u0142\u0140\u0001"+
|
||||
"\u0000\u0000\u0000\u0142\u0143\u0001\u0000\u0000\u0000\u0143\u0145\u0001"+
|
||||
"\u0000\u0000\u0000\u0144\u0142\u0001\u0000\u0000\u0000\u0145\u0146\u0006"+
|
||||
"0\u0000\u0000\u0146b\u0001\u0000\u0000\u0000\b\u0000\u0110\u0119\u011e"+
|
||||
"\u0123\u0128\u0134\u0142\u0001\u0006\u0000\u0000";
|
||||
"\u0095\u0016\u0001\u0000\u0000\u0000\u0096\u0097\u0005f\u0000\u0000\u0097"+
|
||||
"\u0098\u0005o\u0000\u0000\u0098\u0099\u0005r\u0000\u0000\u0099\u0018\u0001"+
|
||||
"\u0000\u0000\u0000\u009a\u009b\u0005w\u0000\u0000\u009b\u009c\u0005h\u0000"+
|
||||
"\u0000\u009c\u009d\u0005i\u0000\u0000\u009d\u009e\u0005l\u0000\u0000\u009e"+
|
||||
"\u009f\u0005e\u0000\u0000\u009f\u001a\u0001\u0000\u0000\u0000\u00a0\u00a1"+
|
||||
"\u0005d\u0000\u0000\u00a1\u00a2\u0005o\u0000\u0000\u00a2\u001c\u0001\u0000"+
|
||||
"\u0000\u0000\u00a3\u00a4\u0005b\u0000\u0000\u00a4\u00a5\u0005r\u0000\u0000"+
|
||||
"\u00a5\u00a6\u0005e\u0000\u0000\u00a6\u00a7\u0005a\u0000\u0000\u00a7\u00a8"+
|
||||
"\u0005k\u0000\u0000\u00a8\u001e\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005"+
|
||||
".\u0000\u0000\u00aa \u0001\u0000\u0000\u0000\u00ab\u00ac\u0005p\u0000"+
|
||||
"\u0000\u00ac\u00ad\u0005u\u0000\u0000\u00ad\u00ae\u0005b\u0000\u0000\u00ae"+
|
||||
"\u00af\u0005l\u0000\u0000\u00af\u00b0\u0005i\u0000\u0000\u00b0\u00b1\u0005"+
|
||||
"c\u0000\u0000\u00b1\"\u0001\u0000\u0000\u0000\u00b2\u00b3\u0005n\u0000"+
|
||||
"\u0000\u00b3\u00b4\u0005e\u0000\u0000\u00b4\u00b5\u0005w\u0000\u0000\u00b5"+
|
||||
"$\u0001\u0000\u0000\u0000\u00b6\u00b7\u0005n\u0000\u0000\u00b7\u00b8\u0005"+
|
||||
"u\u0000\u0000\u00b8\u00b9\u0005l\u0000\u0000\u00b9\u00ba\u0005l\u0000"+
|
||||
"\u0000\u00ba&\u0001\u0000\u0000\u0000\u00bb\u00bc\u0005t\u0000\u0000\u00bc"+
|
||||
"\u00bd\u0005h\u0000\u0000\u00bd\u00be\u0005i\u0000\u0000\u00be\u00bf\u0005"+
|
||||
"s\u0000\u0000\u00bf(\u0001\u0000\u0000\u0000\u00c0\u00c1\u0005i\u0000"+
|
||||
"\u0000\u00c1\u00c2\u0005f\u0000\u0000\u00c2*\u0001\u0000\u0000\u0000\u00c3"+
|
||||
"\u00c4\u0005e\u0000\u0000\u00c4\u00c5\u0005l\u0000\u0000\u00c5\u00c6\u0005"+
|
||||
"s\u0000\u0000\u00c6\u00c7\u0005e\u0000\u0000\u00c7,\u0001\u0000\u0000"+
|
||||
"\u0000\u00c8\u00c9\u0005-\u0000\u0000\u00c9.\u0001\u0000\u0000\u0000\u00ca"+
|
||||
"\u00cb\u0005+\u0000\u0000\u00cb0\u0001\u0000\u0000\u0000\u00cc\u00cd\u0005"+
|
||||
"*\u0000\u0000\u00cd2\u0001\u0000\u0000\u0000\u00ce\u00cf\u0005>\u0000"+
|
||||
"\u0000\u00cf4\u0001\u0000\u0000\u0000\u00d0\u00d1\u0005<\u0000\u0000\u00d1"+
|
||||
"6\u0001\u0000\u0000\u0000\u00d2\u00d3\u0005>\u0000\u0000\u00d3\u00d4\u0005"+
|
||||
"=\u0000\u0000\u00d48\u0001\u0000\u0000\u0000\u00d5\u00d6\u0005<\u0000"+
|
||||
"\u0000\u00d6\u00d7\u0005=\u0000\u0000\u00d7:\u0001\u0000\u0000\u0000\u00d8"+
|
||||
"\u00d9\u0005=\u0000\u0000\u00d9\u00da\u0005=\u0000\u0000\u00da<\u0001"+
|
||||
"\u0000\u0000\u0000\u00db\u00dc\u0005!\u0000\u0000\u00dc\u00dd\u0005=\u0000"+
|
||||
"\u0000\u00dd>\u0001\u0000\u0000\u0000\u00de\u00df\u0005&\u0000\u0000\u00df"+
|
||||
"\u00e0\u0005&\u0000\u0000\u00e0@\u0001\u0000\u0000\u0000\u00e1\u00e2\u0005"+
|
||||
"|\u0000\u0000\u00e2\u00e3\u0005|\u0000\u0000\u00e3B\u0001\u0000\u0000"+
|
||||
"\u0000\u00e4\u00e5\u0005=\u0000\u0000\u00e5D\u0001\u0000\u0000\u0000\u00e6"+
|
||||
"\u00e7\u0005+\u0000\u0000\u00e7\u00e8\u0005=\u0000\u0000\u00e8F\u0001"+
|
||||
"\u0000\u0000\u0000\u00e9\u00ea\u0005-\u0000\u0000\u00ea\u00eb\u0005=\u0000"+
|
||||
"\u0000\u00ebH\u0001\u0000\u0000\u0000\u00ec\u00ed\u0005*\u0000\u0000\u00ed"+
|
||||
"\u00ee\u0005=\u0000\u0000\u00eeJ\u0001\u0000\u0000\u0000\u00ef\u00f0\u0005"+
|
||||
"!\u0000\u0000\u00f0L\u0001\u0000\u0000\u0000\u00f1\u00f2\u0005i\u0000"+
|
||||
"\u0000\u00f2\u00f3\u0005n\u0000\u0000\u00f3\u00f4\u0005t\u0000\u0000\u00f4"+
|
||||
"N\u0001\u0000\u0000\u0000\u00f5\u00f6\u0005b\u0000\u0000\u00f6\u00f7\u0005"+
|
||||
"o\u0000\u0000\u00f7\u00f8\u0005o\u0000\u0000\u00f8\u00f9\u0005l\u0000"+
|
||||
"\u0000\u00f9\u00fa\u0005e\u0000\u0000\u00fa\u00fb\u0005a\u0000\u0000\u00fb"+
|
||||
"\u00fc\u0005n\u0000\u0000\u00fcP\u0001\u0000\u0000\u0000\u00fd\u00fe\u0005"+
|
||||
"v\u0000\u0000\u00fe\u00ff\u0005o\u0000\u0000\u00ff\u0100\u0005i\u0000"+
|
||||
"\u0000\u0100\u0101\u0005d\u0000\u0000\u0101R\u0001\u0000\u0000\u0000\u0102"+
|
||||
"\u0103\u0005c\u0000\u0000\u0103\u0104\u0005h\u0000\u0000\u0104\u0105\u0005"+
|
||||
"a\u0000\u0000\u0105\u0106\u0005r\u0000\u0000\u0106T\u0001\u0000\u0000"+
|
||||
"\u0000\u0107\u0108\u0005t\u0000\u0000\u0108\u0109\u0005r\u0000\u0000\u0109"+
|
||||
"\u010a\u0005u\u0000\u0000\u010a\u0111\u0005e\u0000\u0000\u010b\u010c\u0005"+
|
||||
"f\u0000\u0000\u010c\u010d\u0005a\u0000\u0000\u010d\u010e\u0005l\u0000"+
|
||||
"\u0000\u010e\u010f\u0005s\u0000\u0000\u010f\u0111\u0005e\u0000\u0000\u0110"+
|
||||
"\u0107\u0001\u0000\u0000\u0000\u0110\u010b\u0001\u0000\u0000\u0000\u0111"+
|
||||
"V\u0001\u0000\u0000\u0000\u0112\u0113\u0007\u0000\u0000\u0000\u0113\u0114"+
|
||||
"\u0007\u0001\u0000\u0000\u0114\u0115\u0007\u0000\u0000\u0000\u0115X\u0001"+
|
||||
"\u0000\u0000\u0000\u0116\u0118\u0007\u0001\u0000\u0000\u0117\u0116\u0001"+
|
||||
"\u0000\u0000\u0000\u0118\u0119\u0001\u0000\u0000\u0000\u0119\u0117\u0001"+
|
||||
"\u0000\u0000\u0000\u0119\u011a\u0001\u0000\u0000\u0000\u011a\u011e\u0001"+
|
||||
"\u0000\u0000\u0000\u011b\u011d\u0007\u0002\u0000\u0000\u011c\u011b\u0001"+
|
||||
"\u0000\u0000\u0000\u011d\u0120\u0001\u0000\u0000\u0000\u011e\u011c\u0001"+
|
||||
"\u0000\u0000\u0000\u011e\u011f\u0001\u0000\u0000\u0000\u011f\u0122\u0001"+
|
||||
"\u0000\u0000\u0000\u0120\u011e\u0001\u0000\u0000\u0000\u0121\u0117\u0001"+
|
||||
"\u0000\u0000\u0000\u0122\u0123\u0001\u0000\u0000\u0000\u0123\u0121\u0001"+
|
||||
"\u0000\u0000\u0000\u0123\u0124\u0001\u0000\u0000\u0000\u0124Z\u0001\u0000"+
|
||||
"\u0000\u0000\u0125\u0127\u0007\u0002\u0000\u0000\u0126\u0125\u0001\u0000"+
|
||||
"\u0000\u0000\u0127\u0128\u0001\u0000\u0000\u0000\u0128\u0126\u0001\u0000"+
|
||||
"\u0000\u0000\u0128\u0129\u0001\u0000\u0000\u0000\u0129\\\u0001\u0000\u0000"+
|
||||
"\u0000\u012a\u012b\u0007\u0003\u0000\u0000\u012b\u012c\u0001\u0000\u0000"+
|
||||
"\u0000\u012c\u012d\u0006.\u0000\u0000\u012d^\u0001\u0000\u0000\u0000\u012e"+
|
||||
"\u012f\u0005/\u0000\u0000\u012f\u0130\u0005*\u0000\u0000\u0130\u0134\u0001"+
|
||||
"\u0000\u0000\u0000\u0131\u0133\t\u0000\u0000\u0000\u0132\u0131\u0001\u0000"+
|
||||
"\u0000\u0000\u0133\u0136\u0001\u0000\u0000\u0000\u0134\u0135\u0001\u0000"+
|
||||
"\u0000\u0000\u0134\u0132\u0001\u0000\u0000\u0000\u0135\u0137\u0001\u0000"+
|
||||
"\u0000\u0000\u0136\u0134\u0001\u0000\u0000\u0000\u0137\u0138\u0005*\u0000"+
|
||||
"\u0000\u0138\u0139\u0005/\u0000\u0000\u0139\u013a\u0001\u0000\u0000\u0000"+
|
||||
"\u013a\u013b\u0006/\u0000\u0000\u013b`\u0001\u0000\u0000\u0000\u013c\u013d"+
|
||||
"\u0005/\u0000\u0000\u013d\u013e\u0005/\u0000\u0000\u013e\u0142\u0001\u0000"+
|
||||
"\u0000\u0000\u013f\u0141\b\u0004\u0000\u0000\u0140\u013f\u0001\u0000\u0000"+
|
||||
"\u0000\u0141\u0144\u0001\u0000\u0000\u0000\u0142\u0140\u0001\u0000\u0000"+
|
||||
"\u0000\u0142\u0143\u0001\u0000\u0000\u0000\u0143\u0145\u0001\u0000\u0000"+
|
||||
"\u0000\u0144\u0142\u0001\u0000\u0000\u0000\u0145\u0146\u00060\u0000\u0000"+
|
||||
"\u0146b\u0001\u0000\u0000\u0000\b\u0000\u0110\u0119\u011e\u0123\u0128"+
|
||||
"\u0134\u0142\u0001\u0006\u0000\u0000";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@ -14,12 +14,12 @@ T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
PUBLIC=19
|
||||
NEW=20
|
||||
NULL=21
|
||||
THIS=22
|
||||
PUBLIC=17
|
||||
NEW=18
|
||||
NULL=19
|
||||
THIS=20
|
||||
IF=21
|
||||
ELSE=22
|
||||
SUB=23
|
||||
ADD=24
|
||||
MUL=25
|
||||
@ -58,17 +58,17 @@ LINE_COMMENT=49
|
||||
'String[] args'=9
|
||||
','=10
|
||||
'return'=11
|
||||
'if'=12
|
||||
'else'=13
|
||||
'for'=14
|
||||
'while'=15
|
||||
'do'=16
|
||||
'break'=17
|
||||
'.'=18
|
||||
'public'=19
|
||||
'new'=20
|
||||
'null'=21
|
||||
'this'=22
|
||||
'for'=12
|
||||
'while'=13
|
||||
'do'=14
|
||||
'break'=15
|
||||
'.'=16
|
||||
'public'=17
|
||||
'new'=18
|
||||
'null'=19
|
||||
'this'=20
|
||||
'if'=21
|
||||
'else'=22
|
||||
'-'=23
|
||||
'+'=24
|
||||
'*'=25
|
||||
|
@ -441,6 +441,26 @@ public interface DecafListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitArgs(DecafParser.ArgsContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link DecafParser#ifCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIfCall(DecafParser.IfCallContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link DecafParser#ifCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIfCall(DecafParser.IfCallContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link DecafParser#elseIf}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterElseIf(DecafParser.ElseIfContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link DecafParser#elseIf}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitElseIf(DecafParser.ElseIfContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link DecafParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -267,6 +267,18 @@ public interface DecafVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitArgs(DecafParser.ArgsContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link DecafParser#ifCall}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitIfCall(DecafParser.IfCallContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link DecafParser#elseIf}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitElseIf(DecafParser.ElseIfContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link DecafParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
|
@ -3,5 +3,28 @@ public class E2ETests {
|
||||
|
||||
public E2ETests() {
|
||||
this.ZZ = 'z';
|
||||
// if (stuff1) {
|
||||
// ifcontent
|
||||
// } else if (stuff2) {
|
||||
// content2
|
||||
// } else if (stuffs3) {
|
||||
// content3
|
||||
// } else {
|
||||
// contents4
|
||||
// }
|
||||
//
|
||||
// if (stuff1) {
|
||||
// ifcontent
|
||||
// } else {
|
||||
// if (stuff2) {
|
||||
// content2
|
||||
// } else {
|
||||
// if (stuff3) {
|
||||
// content3
|
||||
// } else {
|
||||
// content4
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user