From 2f0bcfacd79099e0348396644de7c79ebae073bf Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Fri, 1 Dec 2017 23:45:09 +0100 Subject: [PATCH] Rewrote syntax to separate declarations and statements. --- .../java/dk/camelot64/kickc/Compiler.java | 2 +- .../java/dk/camelot64/kickc/parser/KickC.g4 | 32 +- .../dk/camelot64/kickc/parser/KickC.tokens | 8 +- .../kickc/parser/KickCBaseListener.java | 84 +- .../kickc/parser/KickCBaseVisitor.java | 49 +- .../dk/camelot64/kickc/parser/KickCLexer.java | 6 +- .../camelot64/kickc/parser/KickCLexer.tokens | 8 +- .../camelot64/kickc/parser/KickCListener.java | 80 +- .../camelot64/kickc/parser/KickCParser.java | 1418 +++++++++-------- .../camelot64/kickc/parser/KickCVisitor.java | 47 +- .../Pass1GenerateStatementSequence.java | 152 +- 11 files changed, 1096 insertions(+), 790 deletions(-) diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index eb17d79f0..e5fafd67e 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -52,7 +52,7 @@ public class Compiler { int charPositionInLine, String msg, RecognitionException e) { - throw new RuntimeException("Error parsing file " + input.getSourceName() + "\n - Line: " + line + "\n - Message: " + msg); + throw new CompileError("Error parsing file " + input.getSourceName() + "\n - Line: " + line + "\n - Message: " + msg); } }); return parser.file(); diff --git a/src/main/java/dk/camelot64/kickc/parser/KickC.g4 b/src/main/java/dk/camelot64/kickc/parser/KickC.g4 index 86fb88342..52bfe1174 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickC.g4 +++ b/src/main/java/dk/camelot64/kickc/parser/KickC.g4 @@ -2,21 +2,39 @@ grammar KickC; file : - stmtSeq EOF + declSeq EOF ; asmFile : asmLines EOF ; +declSeq + : decl+ + ; + +decl + : typeDecl NAME '(' parameterListDecl? ')' '{' stmtSeq? '}' #declMethod + | declVar #declVariable + ; + +parameterListDecl + : parameterDecl (',' parameterDecl)* ; + +parameterDecl + : typeDecl NAME ; + +declVar + : ('const')? typeDecl NAME ('=' initializer)? ';' + ; + stmtSeq : stmt+ ; stmt - : '{' stmtSeq? '}' #stmtBlock - | typeDecl NAME '(' parameterListDecl? ')' '{' stmtSeq? '}' #stmtFunction - | ('const')? typeDecl NAME ('=' initializer)? ';' #stmtDeclaration + : declVar #stmtDeclVar + | '{' stmtSeq? '}' #stmtBlock | lvalue '=' expr ';' #stmtAssignment | expr ';' #stmtExpr | 'if' '(' expr ')' stmt ( 'else' stmt )? #stmtIfElse @@ -36,12 +54,6 @@ forIteration | ':' expr ( '..' ) expr #forRange ; -parameterListDecl - : parameterDecl (',' parameterDecl)* ; - -parameterDecl - : typeDecl NAME ; - typeDecl : SIMPLETYPE #typeSimple | 'signed' SIMPLETYPE #typeSignedSimple diff --git a/src/main/java/dk/camelot64/kickc/parser/KickC.tokens b/src/main/java/dk/camelot64/kickc/parser/KickC.tokens index 8daa77307..8f685bbbe 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickC.tokens +++ b/src/main/java/dk/camelot64/kickc/parser/KickC.tokens @@ -63,10 +63,10 @@ ASMREL=62 WS=63 COMMENT_LINE=64 COMMENT_BLOCK=65 -'{'=1 -'}'=2 -'('=3 -')'=4 +'('=1 +')'=2 +'{'=3 +'}'=4 'const'=5 '='=6 ';'=7 diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCBaseListener.java b/src/main/java/dk/camelot64/kickc/parser/KickCBaseListener.java index 9930e3bc4..e3ce45107 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCBaseListener.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCBaseListener.java @@ -35,6 +35,54 @@ public class KickCBaseListener implements KickCListener { *

The default implementation does nothing.

*/ @Override public void exitAsmFile(KickCParser.AsmFileContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclSeq(KickCParser.DeclSeqContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclSeq(KickCParser.DeclSeqContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclMethod(KickCParser.DeclMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclMethod(KickCParser.DeclMethodContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclVariable(KickCParser.DeclVariableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclVariable(KickCParser.DeclVariableContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclVar(KickCParser.DeclVarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclVar(KickCParser.DeclVarContext ctx) { } /** * {@inheritDoc} * @@ -47,6 +95,18 @@ public class KickCBaseListener implements KickCListener { *

The default implementation does nothing.

*/ @Override public void exitStmtSeq(KickCParser.StmtSeqContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStmtDeclVar(KickCParser.StmtDeclVarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStmtDeclVar(KickCParser.StmtDeclVarContext ctx) { } /** * {@inheritDoc} * @@ -59,30 +119,6 @@ public class KickCBaseListener implements KickCListener { *

The default implementation does nothing.

*/ @Override public void exitStmtBlock(KickCParser.StmtBlockContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStmtFunction(KickCParser.StmtFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStmtFunction(KickCParser.StmtFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStmtDeclaration(KickCParser.StmtDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStmtDeclaration(KickCParser.StmtDeclarationContext ctx) { } /** * {@inheritDoc} * diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCBaseVisitor.java b/src/main/java/dk/camelot64/kickc/parser/KickCBaseVisitor.java index d1b987225..83f5734ce 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCBaseVisitor.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCBaseVisitor.java @@ -25,6 +25,34 @@ public class KickCBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitAsmFile(KickCParser.AsmFileContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclSeq(KickCParser.DeclSeqContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclMethod(KickCParser.DeclMethodContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclVariable(KickCParser.DeclVariableContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclVar(KickCParser.DeclVarContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * @@ -32,6 +60,13 @@ public class KickCBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitStmtSeq(KickCParser.StmtSeqContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStmtDeclVar(KickCParser.StmtDeclVarContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * @@ -39,20 +74,6 @@ public class KickCBaseVisitor extends AbstractParseTreeVisitor implements * {@link #visitChildren} on {@code ctx}.

*/ @Override public T visitStmtBlock(KickCParser.StmtBlockContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStmtFunction(KickCParser.StmtFunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStmtDeclaration(KickCParser.StmtDeclarationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java index 0748075d1..9c9caa891 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java @@ -49,7 +49,7 @@ public class KickCLexer extends Lexer { }; private static final String[] _LITERAL_NAMES = { - null, "'{'", "'}'", "'('", "')'", "'const'", "'='", "';'", "'if'", "'else'", + null, "'('", "')'", "'{'", "'}'", "'const'", "'='", "';'", "'if'", "'else'", "'while'", "'do'", "'for'", "'return'", "'asm'", "':'", "'..'", "','", "'signed'", "'*'", "'['", "']'", "'<'", "'>'", "'--'", "'++'", "'+'", "'-'", "'!'", "'&'", "'~'", "'>>'", "'<<'", "'/'", "'%'", "'=='", "'!='", @@ -204,8 +204,8 @@ public class KickCLexer extends Lexer { "\2\2y\u027d\3\2\2\2{\u0284\3\2\2\2}\u0286\3\2\2\2\177\u0288\3\2\2\2\u0081"+ "\u028a\3\2\2\2\u0083\u0291\3\2\2\2\u0085\u0293\3\2\2\2\u0087\u0295\3\2"+ "\2\2\u0089\u029d\3\2\2\2\u008b\u02a3\3\2\2\2\u008d\u02ae\3\2\2\2\u008f"+ - "\u0090\7}\2\2\u0090\4\3\2\2\2\u0091\u0092\7\177\2\2\u0092\6\3\2\2\2\u0093"+ - "\u0094\7*\2\2\u0094\b\3\2\2\2\u0095\u0096\7+\2\2\u0096\n\3\2\2\2\u0097"+ + "\u0090\7*\2\2\u0090\4\3\2\2\2\u0091\u0092\7+\2\2\u0092\6\3\2\2\2\u0093"+ + "\u0094\7}\2\2\u0094\b\3\2\2\2\u0095\u0096\7\177\2\2\u0096\n\3\2\2\2\u0097"+ "\u0098\7e\2\2\u0098\u0099\7q\2\2\u0099\u009a\7p\2\2\u009a\u009b\7u\2\2"+ "\u009b\u009c\7v\2\2\u009c\f\3\2\2\2\u009d\u009e\7?\2\2\u009e\16\3\2\2"+ "\2\u009f\u00a0\7=\2\2\u00a0\20\3\2\2\2\u00a1\u00a2\7k\2\2\u00a2\u00a3"+ diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens index 8daa77307..8f685bbbe 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens +++ b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens @@ -63,10 +63,10 @@ ASMREL=62 WS=63 COMMENT_LINE=64 COMMENT_BLOCK=65 -'{'=1 -'}'=2 -'('=3 -')'=4 +'('=1 +')'=2 +'{'=3 +'}'=4 'const'=5 '='=6 ';'=7 diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCListener.java b/src/main/java/dk/camelot64/kickc/parser/KickCListener.java index 12a011535..b9c679874 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCListener.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCListener.java @@ -27,6 +27,50 @@ public interface KickCListener extends ParseTreeListener { * @param ctx the parse tree */ void exitAsmFile(KickCParser.AsmFileContext ctx); + /** + * Enter a parse tree produced by {@link KickCParser#declSeq}. + * @param ctx the parse tree + */ + void enterDeclSeq(KickCParser.DeclSeqContext ctx); + /** + * Exit a parse tree produced by {@link KickCParser#declSeq}. + * @param ctx the parse tree + */ + void exitDeclSeq(KickCParser.DeclSeqContext ctx); + /** + * Enter a parse tree produced by the {@code declMethod} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + */ + void enterDeclMethod(KickCParser.DeclMethodContext ctx); + /** + * Exit a parse tree produced by the {@code declMethod} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + */ + void exitDeclMethod(KickCParser.DeclMethodContext ctx); + /** + * Enter a parse tree produced by the {@code declVariable} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + */ + void enterDeclVariable(KickCParser.DeclVariableContext ctx); + /** + * Exit a parse tree produced by the {@code declVariable} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + */ + void exitDeclVariable(KickCParser.DeclVariableContext ctx); + /** + * Enter a parse tree produced by {@link KickCParser#declVar}. + * @param ctx the parse tree + */ + void enterDeclVar(KickCParser.DeclVarContext ctx); + /** + * Exit a parse tree produced by {@link KickCParser#declVar}. + * @param ctx the parse tree + */ + void exitDeclVar(KickCParser.DeclVarContext ctx); /** * Enter a parse tree produced by {@link KickCParser#stmtSeq}. * @param ctx the parse tree @@ -37,6 +81,18 @@ public interface KickCListener extends ParseTreeListener { * @param ctx the parse tree */ void exitStmtSeq(KickCParser.StmtSeqContext ctx); + /** + * Enter a parse tree produced by the {@code stmtDeclVar} + * labeled alternative in {@link KickCParser#stmt}. + * @param ctx the parse tree + */ + void enterStmtDeclVar(KickCParser.StmtDeclVarContext ctx); + /** + * Exit a parse tree produced by the {@code stmtDeclVar} + * labeled alternative in {@link KickCParser#stmt}. + * @param ctx the parse tree + */ + void exitStmtDeclVar(KickCParser.StmtDeclVarContext ctx); /** * Enter a parse tree produced by the {@code stmtBlock} * labeled alternative in {@link KickCParser#stmt}. @@ -49,30 +105,6 @@ public interface KickCListener extends ParseTreeListener { * @param ctx the parse tree */ void exitStmtBlock(KickCParser.StmtBlockContext ctx); - /** - * Enter a parse tree produced by the {@code stmtFunction} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - */ - void enterStmtFunction(KickCParser.StmtFunctionContext ctx); - /** - * Exit a parse tree produced by the {@code stmtFunction} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - */ - void exitStmtFunction(KickCParser.StmtFunctionContext ctx); - /** - * Enter a parse tree produced by the {@code stmtDeclaration} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - */ - void enterStmtDeclaration(KickCParser.StmtDeclarationContext ctx); - /** - * Exit a parse tree produced by the {@code stmtDeclaration} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - */ - void exitStmtDeclaration(KickCParser.StmtDeclarationContext ctx); /** * Enter a parse tree produced by the {@code stmtAssignment} * labeled alternative in {@link KickCParser#stmt}. diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCParser.java b/src/main/java/dk/camelot64/kickc/parser/KickCParser.java index b2c165853..cd9911d7d 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCParser.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCParser.java @@ -28,20 +28,21 @@ public class KickCParser extends Parser { BININTEGER=58, DECINTEGER=59, HEXINTEGER=60, NAME=61, ASMREL=62, WS=63, COMMENT_LINE=64, COMMENT_BLOCK=65; public static final int - RULE_file = 0, RULE_asmFile = 1, RULE_stmtSeq = 2, RULE_stmt = 3, RULE_forDeclaration = 4, - RULE_forIteration = 5, RULE_parameterListDecl = 6, RULE_parameterDecl = 7, - RULE_typeDecl = 8, RULE_initializer = 9, RULE_lvalue = 10, RULE_expr = 11, - RULE_parameterList = 12, RULE_asmLines = 13, RULE_asmLine = 14, RULE_asmLabel = 15, - RULE_asmInstruction = 16, RULE_asmParamMode = 17, RULE_asmExpr = 18; + RULE_file = 0, RULE_asmFile = 1, RULE_declSeq = 2, RULE_decl = 3, RULE_declVar = 4, + RULE_stmtSeq = 5, RULE_stmt = 6, RULE_forDeclaration = 7, RULE_forIteration = 8, + RULE_parameterListDecl = 9, RULE_parameterDecl = 10, RULE_typeDecl = 11, + RULE_initializer = 12, RULE_lvalue = 13, RULE_expr = 14, RULE_parameterList = 15, + RULE_asmLines = 16, RULE_asmLine = 17, RULE_asmLabel = 18, RULE_asmInstruction = 19, + RULE_asmParamMode = 20, RULE_asmExpr = 21; public static final String[] ruleNames = { - "file", "asmFile", "stmtSeq", "stmt", "forDeclaration", "forIteration", - "parameterListDecl", "parameterDecl", "typeDecl", "initializer", "lvalue", - "expr", "parameterList", "asmLines", "asmLine", "asmLabel", "asmInstruction", - "asmParamMode", "asmExpr" + "file", "asmFile", "declSeq", "decl", "declVar", "stmtSeq", "stmt", "forDeclaration", + "forIteration", "parameterListDecl", "parameterDecl", "typeDecl", "initializer", + "lvalue", "expr", "parameterList", "asmLines", "asmLine", "asmLabel", + "asmInstruction", "asmParamMode", "asmExpr" }; private static final String[] _LITERAL_NAMES = { - null, "'{'", "'}'", "'('", "')'", "'const'", "'='", "';'", "'if'", "'else'", + null, "'('", "')'", "'{'", "'}'", "'const'", "'='", "';'", "'if'", "'else'", "'while'", "'do'", "'for'", "'return'", "'asm'", "':'", "'..'", "','", "'signed'", "'*'", "'['", "']'", "'<'", "'>'", "'--'", "'++'", "'+'", "'-'", "'!'", "'&'", "'~'", "'>>'", "'<<'", "'/'", "'%'", "'=='", "'!='", @@ -107,8 +108,8 @@ public class KickCParser extends Parser { _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } public static class FileContext extends ParserRuleContext { - public StmtSeqContext stmtSeq() { - return getRuleContext(StmtSeqContext.class,0); + public DeclSeqContext declSeq() { + return getRuleContext(DeclSeqContext.class,0); } public TerminalNode EOF() { return getToken(KickCParser.EOF, 0); } public FileContext(ParserRuleContext parent, int invokingState) { @@ -136,9 +137,9 @@ public class KickCParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(38); - stmtSeq(); - setState(39); + setState(44); + declSeq(); + setState(45); match(EOF); } } @@ -183,9 +184,9 @@ public class KickCParser extends Parser { try { enterOuterAlt(_localctx, 1); { - setState(41); + setState(47); asmLines(); - setState(42); + setState(48); match(EOF); } } @@ -200,6 +201,265 @@ public class KickCParser extends Parser { return _localctx; } + public static class DeclSeqContext extends ParserRuleContext { + public List decl() { + return getRuleContexts(DeclContext.class); + } + public DeclContext decl(int i) { + return getRuleContext(DeclContext.class,i); + } + public DeclSeqContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_declSeq; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).enterDeclSeq(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).exitDeclSeq(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitDeclSeq(this); + else return visitor.visitChildren(this); + } + } + + public final DeclSeqContext declSeq() throws RecognitionException { + DeclSeqContext _localctx = new DeclSeqContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_declSeq); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(51); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + { + setState(50); + decl(); + } + } + setState(53); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__4) | (1L << T__17) | (1L << SIMPLETYPE))) != 0) ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class DeclContext extends ParserRuleContext { + public DeclContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_decl; } + + public DeclContext() { } + public void copyFrom(DeclContext ctx) { + super.copyFrom(ctx); + } + } + public static class DeclVariableContext extends DeclContext { + public DeclVarContext declVar() { + return getRuleContext(DeclVarContext.class,0); + } + public DeclVariableContext(DeclContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).enterDeclVariable(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).exitDeclVariable(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitDeclVariable(this); + else return visitor.visitChildren(this); + } + } + public static class DeclMethodContext extends DeclContext { + public TypeDeclContext typeDecl() { + return getRuleContext(TypeDeclContext.class,0); + } + public TerminalNode NAME() { return getToken(KickCParser.NAME, 0); } + public ParameterListDeclContext parameterListDecl() { + return getRuleContext(ParameterListDeclContext.class,0); + } + public StmtSeqContext stmtSeq() { + return getRuleContext(StmtSeqContext.class,0); + } + public DeclMethodContext(DeclContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).enterDeclMethod(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).exitDeclMethod(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitDeclMethod(this); + else return visitor.visitChildren(this); + } + } + + public final DeclContext decl() throws RecognitionException { + DeclContext _localctx = new DeclContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_decl); + int _la; + try { + setState(69); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + _localctx = new DeclMethodContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(55); + typeDecl(0); + setState(56); + match(NAME); + setState(57); + match(T__0); + setState(59); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__17 || _la==SIMPLETYPE) { + { + setState(58); + parameterListDecl(); + } + } + + setState(61); + match(T__1); + setState(62); + match(T__2); + setState(64); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__2) | (1L << T__4) | (1L << T__7) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__17) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << SIMPLETYPE) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { + { + setState(63); + stmtSeq(); + } + } + + setState(66); + match(T__3); + } + break; + case 2: + _localctx = new DeclVariableContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(68); + declVar(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class DeclVarContext extends ParserRuleContext { + public TypeDeclContext typeDecl() { + return getRuleContext(TypeDeclContext.class,0); + } + public TerminalNode NAME() { return getToken(KickCParser.NAME, 0); } + public InitializerContext initializer() { + return getRuleContext(InitializerContext.class,0); + } + public DeclVarContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_declVar; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).enterDeclVar(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).exitDeclVar(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitDeclVar(this); + else return visitor.visitChildren(this); + } + } + + public final DeclVarContext declVar() throws RecognitionException { + DeclVarContext _localctx = new DeclVarContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_declVar); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(72); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__4) { + { + setState(71); + match(T__4); + } + } + + setState(74); + typeDecl(0); + setState(75); + match(NAME); + setState(78); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__5) { + { + setState(76); + match(T__5); + setState(77); + initializer(); + } + } + + setState(80); + match(T__6); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + public static class StmtSeqContext extends ParserRuleContext { public List stmt() { return getRuleContexts(StmtContext.class); @@ -228,22 +488,22 @@ public class KickCParser extends Parser { public final StmtSeqContext stmtSeq() throws RecognitionException { StmtSeqContext _localctx = new StmtSeqContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_stmtSeq); + enterRule(_localctx, 10, RULE_stmtSeq); int _la; try { enterOuterAlt(_localctx, 1); { - setState(45); + setState(83); _errHandler.sync(this); _la = _input.LA(1); do { { { - setState(44); + setState(82); stmt(); } } - setState(47); + setState(85); _errHandler.sync(this); _la = _input.LA(1); } while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__2) | (1L << T__4) | (1L << T__7) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__17) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << SIMPLETYPE) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0) ); @@ -271,6 +531,25 @@ public class KickCParser extends Parser { super.copyFrom(ctx); } } + public static class StmtDeclVarContext extends StmtContext { + public DeclVarContext declVar() { + return getRuleContext(DeclVarContext.class,0); + } + public StmtDeclVarContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).enterStmtDeclVar(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KickCListener ) ((KickCListener)listener).exitStmtDeclVar(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitStmtDeclVar(this); + else return visitor.visitChildren(this); + } + } public static class StmtBlockContext extends StmtContext { public StmtSeqContext stmtSeq() { return getRuleContext(StmtSeqContext.class,0); @@ -419,29 +698,6 @@ public class KickCParser extends Parser { else return visitor.visitChildren(this); } } - public static class StmtDeclarationContext extends StmtContext { - public TypeDeclContext typeDecl() { - return getRuleContext(TypeDeclContext.class,0); - } - public TerminalNode NAME() { return getToken(KickCParser.NAME, 0); } - public InitializerContext initializer() { - return getRuleContext(InitializerContext.class,0); - } - public StmtDeclarationContext(StmtContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof KickCListener ) ((KickCListener)listener).enterStmtDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof KickCListener ) ((KickCListener)listener).exitStmtDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitStmtDeclaration(this); - else return visitor.visitChildren(this); - } - } public static class StmtIfElseContext extends StmtContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); @@ -486,279 +742,189 @@ public class KickCParser extends Parser { else return visitor.visitChildren(this); } } - public static class StmtFunctionContext extends StmtContext { - public TypeDeclContext typeDecl() { - return getRuleContext(TypeDeclContext.class,0); - } - public TerminalNode NAME() { return getToken(KickCParser.NAME, 0); } - public ParameterListDeclContext parameterListDecl() { - return getRuleContext(ParameterListDeclContext.class,0); - } - public StmtSeqContext stmtSeq() { - return getRuleContext(StmtSeqContext.class,0); - } - public StmtFunctionContext(StmtContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof KickCListener ) ((KickCListener)listener).enterStmtFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof KickCListener ) ((KickCListener)listener).exitStmtFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof KickCVisitor ) return ((KickCVisitor)visitor).visitStmtFunction(this); - else return visitor.visitChildren(this); - } - } public final StmtContext stmt() throws RecognitionException { StmtContext _localctx = new StmtContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_stmt); + enterRule(_localctx, 12, RULE_stmt); int _la; try { - setState(128); + setState(143); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,11,_ctx) ) { case 1: - _localctx = new StmtBlockContext(_localctx); + _localctx = new StmtDeclVarContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(49); - match(T__0); - setState(51); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__2) | (1L << T__4) | (1L << T__7) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__17) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << SIMPLETYPE) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { - { - setState(50); - stmtSeq(); - } - } - - setState(53); - match(T__1); + setState(87); + declVar(); } break; case 2: - _localctx = new StmtFunctionContext(_localctx); + _localctx = new StmtBlockContext(_localctx); enterOuterAlt(_localctx, 2); { - setState(54); - typeDecl(0); - setState(55); - match(NAME); - setState(56); + setState(88); match(T__2); - setState(58); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__17 || _la==SIMPLETYPE) { - { - setState(57); - parameterListDecl(); - } - } - - setState(60); - match(T__3); - setState(61); - match(T__0); - setState(63); + setState(90); _errHandler.sync(this); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__2) | (1L << T__4) | (1L << T__7) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__17) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << SIMPLETYPE) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { { - setState(62); + setState(89); stmtSeq(); } } - setState(65); - match(T__1); + setState(92); + match(T__3); } break; case 3: - _localctx = new StmtDeclarationContext(_localctx); + _localctx = new StmtAssignmentContext(_localctx); enterOuterAlt(_localctx, 3); { - setState(68); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__4) { - { - setState(67); - match(T__4); - } - } - - setState(70); - typeDecl(0); - setState(71); - match(NAME); - setState(74); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__5) { - { - setState(72); - match(T__5); - setState(73); - initializer(); - } - } - - setState(76); + setState(93); + lvalue(0); + setState(94); + match(T__5); + setState(95); + expr(0); + setState(96); match(T__6); } break; case 4: - _localctx = new StmtAssignmentContext(_localctx); + _localctx = new StmtExprContext(_localctx); enterOuterAlt(_localctx, 4); { - setState(78); - lvalue(0); - setState(79); - match(T__5); - setState(80); + setState(98); expr(0); - setState(81); + setState(99); match(T__6); } break; case 5: - _localctx = new StmtExprContext(_localctx); + _localctx = new StmtIfElseContext(_localctx); enterOuterAlt(_localctx, 5); { - setState(83); - expr(0); - setState(84); - match(T__6); - } - break; - case 6: - _localctx = new StmtIfElseContext(_localctx); - enterOuterAlt(_localctx, 6); - { - setState(86); + setState(101); match(T__7); - setState(87); - match(T__2); - setState(88); + setState(102); + match(T__0); + setState(103); expr(0); - setState(89); - match(T__3); - setState(90); + setState(104); + match(T__1); + setState(105); stmt(); - setState(93); + setState(108); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) { case 1: { - setState(91); + setState(106); match(T__8); - setState(92); + setState(107); stmt(); } break; } } break; - case 7: + case 6: _localctx = new StmtWhileContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(110); + match(T__9); + setState(111); + match(T__0); + setState(112); + expr(0); + setState(113); + match(T__1); + setState(114); + stmt(); + } + break; + case 7: + _localctx = new StmtDoWhileContext(_localctx); enterOuterAlt(_localctx, 7); { - setState(95); - match(T__9); - setState(96); - match(T__2); - setState(97); - expr(0); - setState(98); - match(T__3); - setState(99); - stmt(); - } - break; - case 8: - _localctx = new StmtDoWhileContext(_localctx); - enterOuterAlt(_localctx, 8); - { - setState(101); - match(T__10); - setState(102); - stmt(); - setState(103); - match(T__9); - setState(104); - match(T__2); - setState(105); - expr(0); - setState(106); - match(T__3); - setState(107); - match(T__6); - } - break; - case 9: - _localctx = new StmtForContext(_localctx); - enterOuterAlt(_localctx, 9); - { - setState(109); - match(T__11); - setState(110); - match(T__2); - setState(112); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__17) | (1L << SIMPLETYPE) | (1L << NAME))) != 0)) { - { - setState(111); - forDeclaration(); - } - } - - setState(114); - forIteration(); - setState(115); - match(T__3); setState(116); + match(T__10); + setState(117); stmt(); - } - break; - case 10: - _localctx = new StmtReturnContext(_localctx); - enterOuterAlt(_localctx, 10); - { setState(118); - match(T__12); + match(T__9); + setState(119); + match(T__0); setState(120); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { - { - setState(119); - expr(0); - } - } - + expr(0); + setState(121); + match(T__1); setState(122); match(T__6); } break; - case 11: - _localctx = new StmtAsmContext(_localctx); - enterOuterAlt(_localctx, 11); + case 8: + _localctx = new StmtForContext(_localctx); + enterOuterAlt(_localctx, 8); { - setState(123); - match(T__13); setState(124); - match(T__0); + match(T__11); setState(125); - asmLines(); - setState(126); + match(T__0); + setState(127); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__17) | (1L << SIMPLETYPE) | (1L << NAME))) != 0)) { + { + setState(126); + forDeclaration(); + } + } + + setState(129); + forIteration(); + setState(130); match(T__1); + setState(131); + stmt(); + } + break; + case 9: + _localctx = new StmtReturnContext(_localctx); + enterOuterAlt(_localctx, 9); + { + setState(133); + match(T__12); + setState(135); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { + { + setState(134); + expr(0); + } + } + + setState(137); + match(T__6); + } + break; + case 10: + _localctx = new StmtAsmContext(_localctx); + enterOuterAlt(_localctx, 10); + { + setState(138); + match(T__13); + setState(139); + match(T__2); + setState(140); + asmLines(); + setState(141); + match(T__3); } break; } @@ -811,32 +977,32 @@ public class KickCParser extends Parser { public final ForDeclarationContext forDeclaration() throws RecognitionException { ForDeclarationContext _localctx = new ForDeclarationContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_forDeclaration); + enterRule(_localctx, 14, RULE_forDeclaration); int _la; try { _localctx = new ForDeclContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(131); + setState(146); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__17 || _la==SIMPLETYPE) { { - setState(130); + setState(145); typeDecl(0); } } - setState(133); + setState(148); match(NAME); - setState(136); + setState(151); _errHandler.sync(this); _la = _input.LA(1); if (_la==T__5) { { - setState(134); + setState(149); match(T__5); - setState(135); + setState(150); initializer(); } } @@ -912,28 +1078,28 @@ public class KickCParser extends Parser { public final ForIterationContext forIteration() throws RecognitionException { ForIterationContext _localctx = new ForIterationContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_forIteration); + enterRule(_localctx, 16, RULE_forIteration); int _la; try { - setState(149); + setState(164); _errHandler.sync(this); switch (_input.LA(1)) { case T__6: _localctx = new ForClassicContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(138); + setState(153); match(T__6); - setState(139); + setState(154); expr(0); - setState(140); + setState(155); match(T__6); - setState(142); + setState(157); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { { - setState(141); + setState(156); expr(0); } } @@ -944,15 +1110,15 @@ public class KickCParser extends Parser { _localctx = new ForRangeContext(_localctx); enterOuterAlt(_localctx, 2); { - setState(144); + setState(159); match(T__14); - setState(145); + setState(160); expr(0); { - setState(146); + setState(161); match(T__15); } - setState(147); + setState(162); expr(0); } break; @@ -999,26 +1165,26 @@ public class KickCParser extends Parser { public final ParameterListDeclContext parameterListDecl() throws RecognitionException { ParameterListDeclContext _localctx = new ParameterListDeclContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_parameterListDecl); + enterRule(_localctx, 18, RULE_parameterListDecl); int _la; try { enterOuterAlt(_localctx, 1); { - setState(151); + setState(166); parameterDecl(); - setState(156); + setState(171); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__16) { { { - setState(152); + setState(167); match(T__16); - setState(153); + setState(168); parameterDecl(); } } - setState(158); + setState(173); _errHandler.sync(this); _la = _input.LA(1); } @@ -1061,13 +1227,13 @@ public class KickCParser extends Parser { public final ParameterDeclContext parameterDecl() throws RecognitionException { ParameterDeclContext _localctx = new ParameterDeclContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_parameterDecl); + enterRule(_localctx, 20, RULE_parameterDecl); try { enterOuterAlt(_localctx, 1); { - setState(159); + setState(174); typeDecl(0); - setState(160); + setState(175); match(NAME); } } @@ -1178,14 +1344,14 @@ public class KickCParser extends Parser { int _parentState = getState(); TypeDeclContext _localctx = new TypeDeclContext(_ctx, _parentState); TypeDeclContext _prevctx = _localctx; - int _startState = 16; - enterRecursionRule(_localctx, 16, RULE_typeDecl, _p); + int _startState = 22; + enterRecursionRule(_localctx, 22, RULE_typeDecl, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { - setState(166); + setState(181); _errHandler.sync(this); switch (_input.LA(1)) { case SIMPLETYPE: @@ -1194,7 +1360,7 @@ public class KickCParser extends Parser { _ctx = _localctx; _prevctx = _localctx; - setState(163); + setState(178); match(SIMPLETYPE); } break; @@ -1203,9 +1369,9 @@ public class KickCParser extends Parser { _localctx = new TypeSignedSimpleContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(164); + setState(179); match(T__17); - setState(165); + setState(180); match(SIMPLETYPE); } break; @@ -1213,24 +1379,24 @@ public class KickCParser extends Parser { throw new NoViableAltException(this); } _ctx.stop = _input.LT(-1); - setState(178); + setState(193); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,18,_ctx); + _alt = getInterpreter().adaptivePredict(_input,20,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { - setState(176); + setState(191); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,19,_ctx) ) { case 1: { _localctx = new TypePtrContext(new TypeDeclContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_typeDecl); - setState(168); + setState(183); if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(169); + setState(184); match(T__18); } break; @@ -1238,30 +1404,30 @@ public class KickCParser extends Parser { { _localctx = new TypeArrayContext(new TypeDeclContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_typeDecl); - setState(170); + setState(185); if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); - setState(171); + setState(186); match(T__19); - setState(173); + setState(188); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { { - setState(172); + setState(187); expr(0); } } - setState(175); + setState(190); match(T__20); } break; } } } - setState(180); + setState(195); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,18,_ctx); + _alt = getInterpreter().adaptivePredict(_input,20,_ctx); } } } @@ -1331,13 +1497,13 @@ public class KickCParser extends Parser { public final InitializerContext initializer() throws RecognitionException { InitializerContext _localctx = new InitializerContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_initializer); + enterRule(_localctx, 24, RULE_initializer); int _la; try { - setState(193); + setState(208); _errHandler.sync(this); switch (_input.LA(1)) { - case T__2: + case T__0: case T__18: case T__21: case T__22: @@ -1356,36 +1522,36 @@ public class KickCParser extends Parser { _localctx = new InitExprContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(181); + setState(196); expr(0); } break; - case T__0: + case T__2: _localctx = new InitListContext(_localctx); enterOuterAlt(_localctx, 2); { - setState(182); - match(T__0); - setState(183); + setState(197); + match(T__2); + setState(198); initializer(); - setState(188); + setState(203); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__16) { { { - setState(184); + setState(199); match(T__16); - setState(185); + setState(200); initializer(); } } - setState(190); + setState(205); _errHandler.sync(this); _la = _input.LA(1); } - setState(191); - match(T__1); + setState(206); + match(T__3); } break; default: @@ -1518,23 +1684,23 @@ public class KickCParser extends Parser { int _parentState = getState(); LvalueContext _localctx = new LvalueContext(_ctx, _parentState); LvalueContext _prevctx = _localctx; - int _startState = 20; - enterRecursionRule(_localctx, 20, RULE_lvalue, _p); + int _startState = 26; + enterRecursionRule(_localctx, 26, RULE_lvalue, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { - setState(206); + setState(221); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,23,_ctx) ) { case 1: { _localctx = new LvalueNameContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(196); + setState(211); match(NAME); } break; @@ -1543,9 +1709,9 @@ public class KickCParser extends Parser { _localctx = new LvaluePtrContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(197); + setState(212); match(T__18); - setState(198); + setState(213); match(NAME); } break; @@ -1554,14 +1720,14 @@ public class KickCParser extends Parser { _localctx = new LvaluePtrExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(199); + setState(214); match(T__18); - setState(200); - match(T__2); - setState(201); + setState(215); + match(T__0); + setState(216); expr(0); - setState(202); - match(T__3); + setState(217); + match(T__1); } break; case 4: @@ -1569,7 +1735,7 @@ public class KickCParser extends Parser { _localctx = new LvalueLoHiContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(204); + setState(219); _la = _input.LA(1); if ( !(_la==T__21 || _la==T__22) ) { _errHandler.recoverInline(this); @@ -1579,15 +1745,15 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(205); + setState(220); lvalue(2); } break; } _ctx.stop = _input.LT(-1); - setState(215); + setState(230); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,22,_ctx); + _alt = getInterpreter().adaptivePredict(_input,24,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); @@ -1596,20 +1762,20 @@ public class KickCParser extends Parser { { _localctx = new LvalueArrayContext(new LvalueContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_lvalue); - setState(208); + setState(223); if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); - setState(209); + setState(224); match(T__19); - setState(210); + setState(225); expr(0); - setState(211); + setState(226); match(T__20); } } } - setState(217); + setState(232); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,22,_ctx); + _alt = getInterpreter().adaptivePredict(_input,24,_ctx); } } } @@ -1892,28 +2058,28 @@ public class KickCParser extends Parser { int _parentState = getState(); ExprContext _localctx = new ExprContext(_ctx, _parentState); ExprContext _prevctx = _localctx; - int _startState = 22; - enterRecursionRule(_localctx, 22, RULE_expr, _p); + int _startState = 28; + enterRecursionRule(_localctx, 28, RULE_expr, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { - setState(243); + setState(258); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,26,_ctx) ) { case 1: { _localctx = new ExprParContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(219); - match(T__2); - setState(220); + setState(234); + match(T__0); + setState(235); expr(0); - setState(221); - match(T__3); + setState(236); + match(T__1); } break; case 2: @@ -1921,22 +2087,22 @@ public class KickCParser extends Parser { _localctx = new ExprCallContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(223); + setState(238); match(NAME); - setState(224); - match(T__2); - setState(226); + setState(239); + match(T__0); + setState(241); _errHandler.sync(this); _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__2) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__23) | (1L << T__24) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29) | (1L << STRING) | (1L << CHAR) | (1L << BOOLEAN) | (1L << NUMBER) | (1L << NAME))) != 0)) { { - setState(225); + setState(240); parameterList(); } } - setState(228); - match(T__3); + setState(243); + match(T__1); } break; case 3: @@ -1944,13 +2110,13 @@ public class KickCParser extends Parser { _localctx = new ExprCastContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(229); - match(T__2); - setState(230); + setState(244); + match(T__0); + setState(245); typeDecl(0); - setState(231); - match(T__3); - setState(232); + setState(246); + match(T__1); + setState(247); expr(19); } break; @@ -1959,7 +2125,7 @@ public class KickCParser extends Parser { _localctx = new ExprPreModContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(234); + setState(249); _la = _input.LA(1); if ( !(_la==T__23 || _la==T__24) ) { _errHandler.recoverInline(this); @@ -1969,7 +2135,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(235); + setState(250); expr(17); } break; @@ -1978,7 +2144,7 @@ public class KickCParser extends Parser { _localctx = new ExprUnaryContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(236); + setState(251); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__18) | (1L << T__21) | (1L << T__22) | (1L << T__25) | (1L << T__26) | (1L << T__27) | (1L << T__28) | (1L << T__29))) != 0)) ) { _errHandler.recoverInline(this); @@ -1988,7 +2154,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(237); + setState(252); expr(15); } break; @@ -1997,7 +2163,7 @@ public class KickCParser extends Parser { _localctx = new ExprIdContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(238); + setState(253); match(NAME); } break; @@ -2006,7 +2172,7 @@ public class KickCParser extends Parser { _localctx = new ExprNumberContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(239); + setState(254); match(NUMBER); } break; @@ -2015,7 +2181,7 @@ public class KickCParser extends Parser { _localctx = new ExprStringContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(240); + setState(255); match(STRING); } break; @@ -2024,7 +2190,7 @@ public class KickCParser extends Parser { _localctx = new ExprCharContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(241); + setState(256); match(CHAR); } break; @@ -2033,30 +2199,30 @@ public class KickCParser extends Parser { _localctx = new ExprBoolContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(242); + setState(257); match(BOOLEAN); } break; } _ctx.stop = _input.LT(-1); - setState(281); + setState(296); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,26,_ctx); + _alt = getInterpreter().adaptivePredict(_input,28,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { - setState(279); + setState(294); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { case 1: { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(245); + setState(260); if (!(precpred(_ctx, 14))) throw new FailedPredicateException(this, "precpred(_ctx, 14)"); - setState(246); + setState(261); _la = _input.LA(1); if ( !(_la==T__30 || _la==T__31) ) { _errHandler.recoverInline(this); @@ -2066,7 +2232,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(247); + setState(262); expr(15); } break; @@ -2074,9 +2240,9 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(248); + setState(263); if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); - setState(249); + setState(264); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__18) | (1L << T__32) | (1L << T__33))) != 0)) ) { _errHandler.recoverInline(this); @@ -2086,7 +2252,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(250); + setState(265); expr(14); } break; @@ -2094,9 +2260,9 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(251); + setState(266); if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); - setState(252); + setState(267); _la = _input.LA(1); if ( !(_la==T__25 || _la==T__26) ) { _errHandler.recoverInline(this); @@ -2106,7 +2272,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(253); + setState(268); expr(13); } break; @@ -2114,9 +2280,9 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(254); + setState(269); if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); - setState(255); + setState(270); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__21) | (1L << T__22) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << T__37) | (1L << T__38) | (1L << T__39) | (1L << T__40))) != 0)) ) { _errHandler.recoverInline(this); @@ -2126,7 +2292,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(256); + setState(271); expr(12); } break; @@ -2134,13 +2300,13 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(257); + setState(272); if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); { - setState(258); + setState(273); match(T__28); } - setState(259); + setState(274); expr(11); } break; @@ -2148,13 +2314,13 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(260); + setState(275); if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); { - setState(261); + setState(276); match(T__41); } - setState(262); + setState(277); expr(10); } break; @@ -2162,13 +2328,13 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(263); + setState(278); if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); { - setState(264); + setState(279); match(T__42); } - setState(265); + setState(280); expr(9); } break; @@ -2176,13 +2342,13 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(266); + setState(281); if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); { - setState(267); + setState(282); match(T__43); } - setState(268); + setState(283); expr(8); } break; @@ -2190,13 +2356,13 @@ public class KickCParser extends Parser { { _localctx = new ExprBinaryContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(269); + setState(284); if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); { - setState(270); + setState(285); match(T__44); } - setState(271); + setState(286); expr(7); } break; @@ -2204,13 +2370,13 @@ public class KickCParser extends Parser { { _localctx = new ExprArrayContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(272); + setState(287); if (!(precpred(_ctx, 18))) throw new FailedPredicateException(this, "precpred(_ctx, 18)"); - setState(273); + setState(288); match(T__19); - setState(274); + setState(289); expr(0); - setState(275); + setState(290); match(T__20); } break; @@ -2218,9 +2384,9 @@ public class KickCParser extends Parser { { _localctx = new ExprPostModContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); - setState(277); + setState(292); if (!(precpred(_ctx, 16))) throw new FailedPredicateException(this, "precpred(_ctx, 16)"); - setState(278); + setState(293); _la = _input.LA(1); if ( !(_la==T__23 || _la==T__24) ) { _errHandler.recoverInline(this); @@ -2235,9 +2401,9 @@ public class KickCParser extends Parser { } } } - setState(283); + setState(298); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,26,_ctx); + _alt = getInterpreter().adaptivePredict(_input,28,_ctx); } } } @@ -2280,26 +2446,26 @@ public class KickCParser extends Parser { public final ParameterListContext parameterList() throws RecognitionException { ParameterListContext _localctx = new ParameterListContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_parameterList); + enterRule(_localctx, 30, RULE_parameterList); int _la; try { enterOuterAlt(_localctx, 1); { - setState(284); + setState(299); expr(0); - setState(289); + setState(304); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__16) { { { - setState(285); + setState(300); match(T__16); - setState(286); + setState(301); expr(0); } } - setState(291); + setState(306); _errHandler.sync(this); _la = _input.LA(1); } @@ -2344,22 +2510,22 @@ public class KickCParser extends Parser { public final AsmLinesContext asmLines() throws RecognitionException { AsmLinesContext _localctx = new AsmLinesContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_asmLines); + enterRule(_localctx, 32, RULE_asmLines); int _la; try { enterOuterAlt(_localctx, 1); { - setState(295); + setState(310); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__27) | (1L << MNEMONIC) | (1L << NAME))) != 0)) { { { - setState(292); + setState(307); asmLine(); } } - setState(297); + setState(312); _errHandler.sync(this); _la = _input.LA(1); } @@ -2404,23 +2570,23 @@ public class KickCParser extends Parser { public final AsmLineContext asmLine() throws RecognitionException { AsmLineContext _localctx = new AsmLineContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_asmLine); + enterRule(_localctx, 34, RULE_asmLine); try { - setState(300); + setState(315); _errHandler.sync(this); switch (_input.LA(1)) { case T__27: case NAME: enterOuterAlt(_localctx, 1); { - setState(298); + setState(313); asmLabel(); } break; case MNEMONIC: enterOuterAlt(_localctx, 2); { - setState(299); + setState(314); asmInstruction(); } break; @@ -2462,26 +2628,26 @@ public class KickCParser extends Parser { public final AsmLabelContext asmLabel() throws RecognitionException { AsmLabelContext _localctx = new AsmLabelContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_asmLabel); + enterRule(_localctx, 36, RULE_asmLabel); try { - setState(306); + setState(321); _errHandler.sync(this); switch (_input.LA(1)) { case NAME: enterOuterAlt(_localctx, 1); { - setState(302); + setState(317); match(NAME); - setState(303); + setState(318); match(T__14); } break; case T__27: enterOuterAlt(_localctx, 2); { - setState(304); + setState(319); match(T__27); - setState(305); + setState(320); match(T__14); } break; @@ -2526,18 +2692,18 @@ public class KickCParser extends Parser { public final AsmInstructionContext asmInstruction() throws RecognitionException { AsmInstructionContext _localctx = new AsmInstructionContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_asmInstruction); + enterRule(_localctx, 38, RULE_asmInstruction); try { enterOuterAlt(_localctx, 1); { - setState(308); + setState(323); match(MNEMONIC); - setState(310); + setState(325); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,31,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,33,_ctx) ) { case 1: { - setState(309); + setState(324); asmParamMode(); } break; @@ -2686,16 +2852,16 @@ public class KickCParser extends Parser { public final AsmParamModeContext asmParamMode() throws RecognitionException { AsmParamModeContext _localctx = new AsmParamModeContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_asmParamMode); + enterRule(_localctx, 40, RULE_asmParamMode); try { - setState(335); + setState(350); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,32,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,34,_ctx) ) { case 1: _localctx = new AsmModeAbsContext(_localctx); enterOuterAlt(_localctx, 1); { - setState(312); + setState(327); asmExpr(0); } break; @@ -2703,9 +2869,9 @@ public class KickCParser extends Parser { _localctx = new AsmModeImmContext(_localctx); enterOuterAlt(_localctx, 2); { - setState(313); + setState(328); match(T__45); - setState(314); + setState(329); asmExpr(0); } break; @@ -2713,11 +2879,11 @@ public class KickCParser extends Parser { _localctx = new AsmModeAbsXYContext(_localctx); enterOuterAlt(_localctx, 3); { - setState(315); + setState(330); asmExpr(0); - setState(316); + setState(331); match(T__16); - setState(317); + setState(332); match(NAME); } break; @@ -2725,15 +2891,15 @@ public class KickCParser extends Parser { _localctx = new AsmModeIndIdxXYContext(_localctx); enterOuterAlt(_localctx, 4); { - setState(319); - match(T__2); - setState(320); + setState(334); + match(T__0); + setState(335); asmExpr(0); - setState(321); - match(T__3); - setState(322); + setState(336); + match(T__1); + setState(337); match(T__16); - setState(323); + setState(338); match(NAME); } break; @@ -2741,28 +2907,28 @@ public class KickCParser extends Parser { _localctx = new AsmModeIdxIndXYContext(_localctx); enterOuterAlt(_localctx, 5); { - setState(325); - match(T__2); - setState(326); + setState(340); + match(T__0); + setState(341); asmExpr(0); - setState(327); + setState(342); match(T__16); - setState(328); + setState(343); match(NAME); - setState(329); - match(T__3); + setState(344); + match(T__1); } break; case 6: _localctx = new AsmModeIndContext(_localctx); enterOuterAlt(_localctx, 6); { - setState(331); - match(T__2); - setState(332); + setState(346); + match(T__0); + setState(347); asmExpr(0); - setState(333); - match(T__3); + setState(348); + match(T__1); } break; } @@ -2925,14 +3091,14 @@ public class KickCParser extends Parser { int _parentState = getState(); AsmExprContext _localctx = new AsmExprContext(_ctx, _parentState); AsmExprContext _prevctx = _localctx; - int _startState = 36; - enterRecursionRule(_localctx, 36, RULE_asmExpr, _p); + int _startState = 42; + enterRecursionRule(_localctx, 42, RULE_asmExpr, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { - setState(347); + setState(362); _errHandler.sync(this); switch (_input.LA(1)) { case T__21: @@ -2944,7 +3110,7 @@ public class KickCParser extends Parser { _ctx = _localctx; _prevctx = _localctx; - setState(338); + setState(353); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__21) | (1L << T__22) | (1L << T__25) | (1L << T__26))) != 0)) ) { _errHandler.recoverInline(this); @@ -2954,7 +3120,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(339); + setState(354); asmExpr(8); } break; @@ -2963,7 +3129,7 @@ public class KickCParser extends Parser { _localctx = new AsmExprLabelContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(340); + setState(355); match(NAME); } break; @@ -2972,21 +3138,21 @@ public class KickCParser extends Parser { _localctx = new AsmExprLabelRelContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(341); + setState(356); match(ASMREL); } break; - case T__0: + case T__2: { _localctx = new AsmExprReplaceContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(342); - match(T__0); - setState(343); + setState(357); + match(T__2); + setState(358); match(NAME); - setState(344); - match(T__1); + setState(359); + match(T__3); } break; case NUMBER: @@ -2994,7 +3160,7 @@ public class KickCParser extends Parser { _localctx = new AsmExprIntContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(345); + setState(360); match(NUMBER); } break; @@ -3003,7 +3169,7 @@ public class KickCParser extends Parser { _localctx = new AsmExprCharContext(_localctx); _ctx = _localctx; _prevctx = _localctx; - setState(346); + setState(361); match(CHAR); } break; @@ -3011,24 +3177,24 @@ public class KickCParser extends Parser { throw new NoViableAltException(this); } _ctx.stop = _input.LT(-1); - setState(357); + setState(372); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,35,_ctx); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { - setState(355); + setState(370); _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,34,_ctx) ) { + switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { case 1: { _localctx = new AsmExprBinaryContext(new AsmExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_asmExpr); - setState(349); + setState(364); if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); - setState(350); + setState(365); _la = _input.LA(1); if ( !(_la==T__18 || _la==T__32) ) { _errHandler.recoverInline(this); @@ -3038,7 +3204,7 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(351); + setState(366); asmExpr(8); } break; @@ -3046,9 +3212,9 @@ public class KickCParser extends Parser { { _localctx = new AsmExprBinaryContext(new AsmExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_asmExpr); - setState(352); + setState(367); if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); - setState(353); + setState(368); _la = _input.LA(1); if ( !(_la==T__25 || _la==T__26) ) { _errHandler.recoverInline(this); @@ -3058,16 +3224,16 @@ public class KickCParser extends Parser { _errHandler.reportMatch(this); consume(); } - setState(354); + setState(369); asmExpr(7); } break; } } } - setState(359); + setState(374); _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,35,_ctx); + _alt = getInterpreter().adaptivePredict(_input,37,_ctx); } } } @@ -3084,13 +3250,13 @@ public class KickCParser extends Parser { public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { - case 8: - return typeDecl_sempred((TypeDeclContext)_localctx, predIndex); - case 10: - return lvalue_sempred((LvalueContext)_localctx, predIndex); case 11: + return typeDecl_sempred((TypeDeclContext)_localctx, predIndex); + case 13: + return lvalue_sempred((LvalueContext)_localctx, predIndex); + case 14: return expr_sempred((ExprContext)_localctx, predIndex); - case 18: + case 21: return asmExpr_sempred((AsmExprContext)_localctx, predIndex); } return true; @@ -3149,141 +3315,149 @@ public class KickCParser extends Parser { } public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3C\u016b\4\2\t\2\4"+ + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3C\u017a\4\2\t\2\4"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\3\2\3\2\3\2\3\3\3\3\3\3\3\4\6\4\60\n\4\r\4\16\4\61"+ - "\3\5\3\5\5\5\66\n\5\3\5\3\5\3\5\3\5\3\5\5\5=\n\5\3\5\3\5\3\5\5\5B\n\5"+ - "\3\5\3\5\3\5\5\5G\n\5\3\5\3\5\3\5\3\5\5\5M\n\5\3\5\3\5\3\5\3\5\3\5\3\5"+ - "\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5`\n\5\3\5\3\5\3\5\3\5"+ - "\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5s\n\5\3\5\3\5"+ - "\3\5\3\5\3\5\3\5\5\5{\n\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5\u0083\n\5\3\6\5"+ - "\6\u0086\n\6\3\6\3\6\3\6\5\6\u008b\n\6\3\7\3\7\3\7\3\7\5\7\u0091\n\7\3"+ - "\7\3\7\3\7\3\7\3\7\5\7\u0098\n\7\3\b\3\b\3\b\7\b\u009d\n\b\f\b\16\b\u00a0"+ - "\13\b\3\t\3\t\3\t\3\n\3\n\3\n\3\n\5\n\u00a9\n\n\3\n\3\n\3\n\3\n\3\n\5"+ - "\n\u00b0\n\n\3\n\7\n\u00b3\n\n\f\n\16\n\u00b6\13\n\3\13\3\13\3\13\3\13"+ - "\3\13\7\13\u00bd\n\13\f\13\16\13\u00c0\13\13\3\13\3\13\5\13\u00c4\n\13"+ - "\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\5\f\u00d1\n\f\3\f\3\f\3\f"+ - "\3\f\3\f\7\f\u00d8\n\f\f\f\16\f\u00db\13\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+ - "\3\r\5\r\u00e5\n\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+ - "\3\r\3\r\5\r\u00f6\n\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r"+ - "\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3"+ - "\r\3\r\3\r\3\r\3\r\7\r\u011a\n\r\f\r\16\r\u011d\13\r\3\16\3\16\3\16\7"+ - "\16\u0122\n\16\f\16\16\16\u0125\13\16\3\17\7\17\u0128\n\17\f\17\16\17"+ - "\u012b\13\17\3\20\3\20\5\20\u012f\n\20\3\21\3\21\3\21\3\21\5\21\u0135"+ - "\n\21\3\22\3\22\5\22\u0139\n\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ - "\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ - "\3\23\5\23\u0152\n\23\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24"+ - "\5\24\u015e\n\24\3\24\3\24\3\24\3\24\3\24\3\24\7\24\u0166\n\24\f\24\16"+ - "\24\u0169\13\24\3\24\2\6\22\26\30&\25\2\4\6\b\n\f\16\20\22\24\26\30\32"+ - "\34\36 \"$&\2\13\3\2\30\31\3\2\32\33\5\2\25\25\30\31\34 \3\2!\"\4\2\25"+ - "\25#$\3\2\34\35\4\2\30\31%+\4\2\30\31\34\35\4\2\25\25##\2\u019f\2(\3\2"+ - "\2\2\4+\3\2\2\2\6/\3\2\2\2\b\u0082\3\2\2\2\n\u0085\3\2\2\2\f\u0097\3\2"+ - "\2\2\16\u0099\3\2\2\2\20\u00a1\3\2\2\2\22\u00a8\3\2\2\2\24\u00c3\3\2\2"+ - "\2\26\u00d0\3\2\2\2\30\u00f5\3\2\2\2\32\u011e\3\2\2\2\34\u0129\3\2\2\2"+ - "\36\u012e\3\2\2\2 \u0134\3\2\2\2\"\u0136\3\2\2\2$\u0151\3\2\2\2&\u015d"+ - "\3\2\2\2()\5\6\4\2)*\7\2\2\3*\3\3\2\2\2+,\5\34\17\2,-\7\2\2\3-\5\3\2\2"+ - "\2.\60\5\b\5\2/.\3\2\2\2\60\61\3\2\2\2\61/\3\2\2\2\61\62\3\2\2\2\62\7"+ - "\3\2\2\2\63\65\7\3\2\2\64\66\5\6\4\2\65\64\3\2\2\2\65\66\3\2\2\2\66\67"+ - "\3\2\2\2\67\u0083\7\4\2\289\5\22\n\29:\7?\2\2:<\7\5\2\2;=\5\16\b\2<;\3"+ - "\2\2\2<=\3\2\2\2=>\3\2\2\2>?\7\6\2\2?A\7\3\2\2@B\5\6\4\2A@\3\2\2\2AB\3"+ - "\2\2\2BC\3\2\2\2CD\7\4\2\2D\u0083\3\2\2\2EG\7\7\2\2FE\3\2\2\2FG\3\2\2"+ - "\2GH\3\2\2\2HI\5\22\n\2IL\7?\2\2JK\7\b\2\2KM\5\24\13\2LJ\3\2\2\2LM\3\2"+ - "\2\2MN\3\2\2\2NO\7\t\2\2O\u0083\3\2\2\2PQ\5\26\f\2QR\7\b\2\2RS\5\30\r"+ - "\2ST\7\t\2\2T\u0083\3\2\2\2UV\5\30\r\2VW\7\t\2\2W\u0083\3\2\2\2XY\7\n"+ - "\2\2YZ\7\5\2\2Z[\5\30\r\2[\\\7\6\2\2\\_\5\b\5\2]^\7\13\2\2^`\5\b\5\2_"+ - "]\3\2\2\2_`\3\2\2\2`\u0083\3\2\2\2ab\7\f\2\2bc\7\5\2\2cd\5\30\r\2de\7"+ - "\6\2\2ef\5\b\5\2f\u0083\3\2\2\2gh\7\r\2\2hi\5\b\5\2ij\7\f\2\2jk\7\5\2"+ - "\2kl\5\30\r\2lm\7\6\2\2mn\7\t\2\2n\u0083\3\2\2\2op\7\16\2\2pr\7\5\2\2"+ - "qs\5\n\6\2rq\3\2\2\2rs\3\2\2\2st\3\2\2\2tu\5\f\7\2uv\7\6\2\2vw\5\b\5\2"+ - "w\u0083\3\2\2\2xz\7\17\2\2y{\5\30\r\2zy\3\2\2\2z{\3\2\2\2{|\3\2\2\2|\u0083"+ - "\7\t\2\2}~\7\20\2\2~\177\7\3\2\2\177\u0080\5\34\17\2\u0080\u0081\7\4\2"+ - "\2\u0081\u0083\3\2\2\2\u0082\63\3\2\2\2\u00828\3\2\2\2\u0082F\3\2\2\2"+ - "\u0082P\3\2\2\2\u0082U\3\2\2\2\u0082X\3\2\2\2\u0082a\3\2\2\2\u0082g\3"+ - "\2\2\2\u0082o\3\2\2\2\u0082x\3\2\2\2\u0082}\3\2\2\2\u0083\t\3\2\2\2\u0084"+ - "\u0086\5\22\n\2\u0085\u0084\3\2\2\2\u0085\u0086\3\2\2\2\u0086\u0087\3"+ - "\2\2\2\u0087\u008a\7?\2\2\u0088\u0089\7\b\2\2\u0089\u008b\5\24\13\2\u008a"+ - "\u0088\3\2\2\2\u008a\u008b\3\2\2\2\u008b\13\3\2\2\2\u008c\u008d\7\t\2"+ - "\2\u008d\u008e\5\30\r\2\u008e\u0090\7\t\2\2\u008f\u0091\5\30\r\2\u0090"+ - "\u008f\3\2\2\2\u0090\u0091\3\2\2\2\u0091\u0098\3\2\2\2\u0092\u0093\7\21"+ - "\2\2\u0093\u0094\5\30\r\2\u0094\u0095\7\22\2\2\u0095\u0096\5\30\r\2\u0096"+ - "\u0098\3\2\2\2\u0097\u008c\3\2\2\2\u0097\u0092\3\2\2\2\u0098\r\3\2\2\2"+ - "\u0099\u009e\5\20\t\2\u009a\u009b\7\23\2\2\u009b\u009d\5\20\t\2\u009c"+ - "\u009a\3\2\2\2\u009d\u00a0\3\2\2\2\u009e\u009c\3\2\2\2\u009e\u009f\3\2"+ - "\2\2\u009f\17\3\2\2\2\u00a0\u009e\3\2\2\2\u00a1\u00a2\5\22\n\2\u00a2\u00a3"+ - "\7?\2\2\u00a3\21\3\2\2\2\u00a4\u00a5\b\n\1\2\u00a5\u00a9\7\62\2\2\u00a6"+ - "\u00a7\7\24\2\2\u00a7\u00a9\7\62\2\2\u00a8\u00a4\3\2\2\2\u00a8\u00a6\3"+ - "\2\2\2\u00a9\u00b4\3\2\2\2\u00aa\u00ab\f\4\2\2\u00ab\u00b3\7\25\2\2\u00ac"+ - "\u00ad\f\3\2\2\u00ad\u00af\7\26\2\2\u00ae\u00b0\5\30\r\2\u00af\u00ae\3"+ - "\2\2\2\u00af\u00b0\3\2\2\2\u00b0\u00b1\3\2\2\2\u00b1\u00b3\7\27\2\2\u00b2"+ - "\u00aa\3\2\2\2\u00b2\u00ac\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4\u00b2\3\2"+ - "\2\2\u00b4\u00b5\3\2\2\2\u00b5\23\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b7\u00c4"+ - "\5\30\r\2\u00b8\u00b9\7\3\2\2\u00b9\u00be\5\24\13\2\u00ba\u00bb\7\23\2"+ - "\2\u00bb\u00bd\5\24\13\2\u00bc\u00ba\3\2\2\2\u00bd\u00c0\3\2\2\2\u00be"+ - "\u00bc\3\2\2\2\u00be\u00bf\3\2\2\2\u00bf\u00c1\3\2\2\2\u00c0\u00be\3\2"+ - "\2\2\u00c1\u00c2\7\4\2\2\u00c2\u00c4\3\2\2\2\u00c3\u00b7\3\2\2\2\u00c3"+ - "\u00b8\3\2\2\2\u00c4\25\3\2\2\2\u00c5\u00c6\b\f\1\2\u00c6\u00d1\7?\2\2"+ - "\u00c7\u00c8\7\25\2\2\u00c8\u00d1\7?\2\2\u00c9\u00ca\7\25\2\2\u00ca\u00cb"+ - "\7\5\2\2\u00cb\u00cc\5\30\r\2\u00cc\u00cd\7\6\2\2\u00cd\u00d1\3\2\2\2"+ - "\u00ce\u00cf\t\2\2\2\u00cf\u00d1\5\26\f\4\u00d0\u00c5\3\2\2\2\u00d0\u00c7"+ - "\3\2\2\2\u00d0\u00c9\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d1\u00d9\3\2\2\2\u00d2"+ - "\u00d3\f\3\2\2\u00d3\u00d4\7\26\2\2\u00d4\u00d5\5\30\r\2\u00d5\u00d6\7"+ - "\27\2\2\u00d6\u00d8\3\2\2\2\u00d7\u00d2\3\2\2\2\u00d8\u00db\3\2\2\2\u00d9"+ - "\u00d7\3\2\2\2\u00d9\u00da\3\2\2\2\u00da\27\3\2\2\2\u00db\u00d9\3\2\2"+ - "\2\u00dc\u00dd\b\r\1\2\u00dd\u00de\7\5\2\2\u00de\u00df\5\30\r\2\u00df"+ - "\u00e0\7\6\2\2\u00e0\u00f6\3\2\2\2\u00e1\u00e2\7?\2\2\u00e2\u00e4\7\5"+ - "\2\2\u00e3\u00e5\5\32\16\2\u00e4\u00e3\3\2\2\2\u00e4\u00e5\3\2\2\2\u00e5"+ - "\u00e6\3\2\2\2\u00e6\u00f6\7\6\2\2\u00e7\u00e8\7\5\2\2\u00e8\u00e9\5\22"+ - "\n\2\u00e9\u00ea\7\6\2\2\u00ea\u00eb\5\30\r\25\u00eb\u00f6\3\2\2\2\u00ec"+ - "\u00ed\t\3\2\2\u00ed\u00f6\5\30\r\23\u00ee\u00ef\t\4\2\2\u00ef\u00f6\5"+ - "\30\r\21\u00f0\u00f6\7?\2\2\u00f1\u00f6\7\66\2\2\u00f2\u00f6\7\63\2\2"+ - "\u00f3\u00f6\7\64\2\2\u00f4\u00f6\7\65\2\2\u00f5\u00dc\3\2\2\2\u00f5\u00e1"+ - "\3\2\2\2\u00f5\u00e7\3\2\2\2\u00f5\u00ec\3\2\2\2\u00f5\u00ee\3\2\2\2\u00f5"+ - "\u00f0\3\2\2\2\u00f5\u00f1\3\2\2\2\u00f5\u00f2\3\2\2\2\u00f5\u00f3\3\2"+ - "\2\2\u00f5\u00f4\3\2\2\2\u00f6\u011b\3\2\2\2\u00f7\u00f8\f\20\2\2\u00f8"+ - "\u00f9\t\5\2\2\u00f9\u011a\5\30\r\21\u00fa\u00fb\f\17\2\2\u00fb\u00fc"+ - "\t\6\2\2\u00fc\u011a\5\30\r\20\u00fd\u00fe\f\16\2\2\u00fe\u00ff\t\7\2"+ - "\2\u00ff\u011a\5\30\r\17\u0100\u0101\f\r\2\2\u0101\u0102\t\b\2\2\u0102"+ - "\u011a\5\30\r\16\u0103\u0104\f\f\2\2\u0104\u0105\7\37\2\2\u0105\u011a"+ - "\5\30\r\r\u0106\u0107\f\13\2\2\u0107\u0108\7,\2\2\u0108\u011a\5\30\r\f"+ - "\u0109\u010a\f\n\2\2\u010a\u010b\7-\2\2\u010b\u011a\5\30\r\13\u010c\u010d"+ - "\f\t\2\2\u010d\u010e\7.\2\2\u010e\u011a\5\30\r\n\u010f\u0110\f\b\2\2\u0110"+ - "\u0111\7/\2\2\u0111\u011a\5\30\r\t\u0112\u0113\f\24\2\2\u0113\u0114\7"+ - "\26\2\2\u0114\u0115\5\30\r\2\u0115\u0116\7\27\2\2\u0116\u011a\3\2\2\2"+ - "\u0117\u0118\f\22\2\2\u0118\u011a\t\3\2\2\u0119\u00f7\3\2\2\2\u0119\u00fa"+ - "\3\2\2\2\u0119\u00fd\3\2\2\2\u0119\u0100\3\2\2\2\u0119\u0103\3\2\2\2\u0119"+ - "\u0106\3\2\2\2\u0119\u0109\3\2\2\2\u0119\u010c\3\2\2\2\u0119\u010f\3\2"+ - "\2\2\u0119\u0112\3\2\2\2\u0119\u0117\3\2\2\2\u011a\u011d\3\2\2\2\u011b"+ - "\u0119\3\2\2\2\u011b\u011c\3\2\2\2\u011c\31\3\2\2\2\u011d\u011b\3\2\2"+ - "\2\u011e\u0123\5\30\r\2\u011f\u0120\7\23\2\2\u0120\u0122\5\30\r\2\u0121"+ - "\u011f\3\2\2\2\u0122\u0125\3\2\2\2\u0123\u0121\3\2\2\2\u0123\u0124\3\2"+ - "\2\2\u0124\33\3\2\2\2\u0125\u0123\3\2\2\2\u0126\u0128\5\36\20\2\u0127"+ - "\u0126\3\2\2\2\u0128\u012b\3\2\2\2\u0129\u0127\3\2\2\2\u0129\u012a\3\2"+ - "\2\2\u012a\35\3\2\2\2\u012b\u0129\3\2\2\2\u012c\u012f\5 \21\2\u012d\u012f"+ - "\5\"\22\2\u012e\u012c\3\2\2\2\u012e\u012d\3\2\2\2\u012f\37\3\2\2\2\u0130"+ - "\u0131\7?\2\2\u0131\u0135\7\21\2\2\u0132\u0133\7\36\2\2\u0133\u0135\7"+ - "\21\2\2\u0134\u0130\3\2\2\2\u0134\u0132\3\2\2\2\u0135!\3\2\2\2\u0136\u0138"+ - "\7\61\2\2\u0137\u0139\5$\23\2\u0138\u0137\3\2\2\2\u0138\u0139\3\2\2\2"+ - "\u0139#\3\2\2\2\u013a\u0152\5&\24\2\u013b\u013c\7\60\2\2\u013c\u0152\5"+ - "&\24\2\u013d\u013e\5&\24\2\u013e\u013f\7\23\2\2\u013f\u0140\7?\2\2\u0140"+ - "\u0152\3\2\2\2\u0141\u0142\7\5\2\2\u0142\u0143\5&\24\2\u0143\u0144\7\6"+ - "\2\2\u0144\u0145\7\23\2\2\u0145\u0146\7?\2\2\u0146\u0152\3\2\2\2\u0147"+ - "\u0148\7\5\2\2\u0148\u0149\5&\24\2\u0149\u014a\7\23\2\2\u014a\u014b\7"+ - "?\2\2\u014b\u014c\7\6\2\2\u014c\u0152\3\2\2\2\u014d\u014e\7\5\2\2\u014e"+ - "\u014f\5&\24\2\u014f\u0150\7\6\2\2\u0150\u0152\3\2\2\2\u0151\u013a\3\2"+ - "\2\2\u0151\u013b\3\2\2\2\u0151\u013d\3\2\2\2\u0151\u0141\3\2\2\2\u0151"+ - "\u0147\3\2\2\2\u0151\u014d\3\2\2\2\u0152%\3\2\2\2\u0153\u0154\b\24\1\2"+ - "\u0154\u0155\t\t\2\2\u0155\u015e\5&\24\n\u0156\u015e\7?\2\2\u0157\u015e"+ - "\7@\2\2\u0158\u0159\7\3\2\2\u0159\u015a\7?\2\2\u015a\u015e\7\4\2\2\u015b"+ - "\u015e\7\66\2\2\u015c\u015e\7\64\2\2\u015d\u0153\3\2\2\2\u015d\u0156\3"+ - "\2\2\2\u015d\u0157\3\2\2\2\u015d\u0158\3\2\2\2\u015d\u015b\3\2\2\2\u015d"+ - "\u015c\3\2\2\2\u015e\u0167\3\2\2\2\u015f\u0160\f\t\2\2\u0160\u0161\t\n"+ - "\2\2\u0161\u0166\5&\24\n\u0162\u0163\f\b\2\2\u0163\u0164\t\7\2\2\u0164"+ - "\u0166\5&\24\t\u0165\u015f\3\2\2\2\u0165\u0162\3\2\2\2\u0166\u0169\3\2"+ - "\2\2\u0167\u0165\3\2\2\2\u0167\u0168\3\2\2\2\u0168\'\3\2\2\2\u0169\u0167"+ - "\3\2\2\2&\61\65\n\5\3\5\3\5\3\5\5"+ + "\5C\n\5\3\5\3\5\3\5\5\5H\n\5\3\6\5\6K\n\6\3\6\3\6\3\6\3\6\5\6Q\n\6\3\6"+ + "\3\6\3\7\6\7V\n\7\r\7\16\7W\3\b\3\b\3\b\5\b]\n\b\3\b\3\b\3\b\3\b\3\b\3"+ + "\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\5\bo\n\b\3\b\3\b\3\b\3\b\3"+ + "\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\5\b\u0082\n\b\3\b\3"+ + "\b\3\b\3\b\3\b\3\b\5\b\u008a\n\b\3\b\3\b\3\b\3\b\3\b\3\b\5\b\u0092\n\b"+ + "\3\t\5\t\u0095\n\t\3\t\3\t\3\t\5\t\u009a\n\t\3\n\3\n\3\n\3\n\5\n\u00a0"+ + "\n\n\3\n\3\n\3\n\3\n\3\n\5\n\u00a7\n\n\3\13\3\13\3\13\7\13\u00ac\n\13"+ + "\f\13\16\13\u00af\13\13\3\f\3\f\3\f\3\r\3\r\3\r\3\r\5\r\u00b8\n\r\3\r"+ + "\3\r\3\r\3\r\3\r\5\r\u00bf\n\r\3\r\7\r\u00c2\n\r\f\r\16\r\u00c5\13\r\3"+ + "\16\3\16\3\16\3\16\3\16\7\16\u00cc\n\16\f\16\16\16\u00cf\13\16\3\16\3"+ + "\16\5\16\u00d3\n\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17"+ + "\3\17\5\17\u00e0\n\17\3\17\3\17\3\17\3\17\3\17\7\17\u00e7\n\17\f\17\16"+ + "\17\u00ea\13\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\5\20\u00f4\n\20"+ + "\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20"+ + "\3\20\5\20\u0105\n\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20"+ + "\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20"+ + "\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\7\20\u0129\n\20\f\20"+ + "\16\20\u012c\13\20\3\21\3\21\3\21\7\21\u0131\n\21\f\21\16\21\u0134\13"+ + "\21\3\22\7\22\u0137\n\22\f\22\16\22\u013a\13\22\3\23\3\23\5\23\u013e\n"+ + "\23\3\24\3\24\3\24\3\24\5\24\u0144\n\24\3\25\3\25\5\25\u0148\n\25\3\26"+ + "\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26"+ + "\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u0161\n\26\3\27\3\27\3\27"+ + "\3\27\3\27\3\27\3\27\3\27\3\27\3\27\5\27\u016d\n\27\3\27\3\27\3\27\3\27"+ + "\3\27\3\27\7\27\u0175\n\27\f\27\16\27\u0178\13\27\3\27\2\6\30\34\36,\30"+ + "\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,\2\13\3\2\30\31\3\2\32"+ + "\33\5\2\25\25\30\31\34 \3\2!\"\4\2\25\25#$\3\2\34\35\4\2\30\31%+\4\2\30"+ + "\31\34\35\4\2\25\25##\2\u01ac\2.\3\2\2\2\4\61\3\2\2\2\6\65\3\2\2\2\bG"+ + "\3\2\2\2\nJ\3\2\2\2\fU\3\2\2\2\16\u0091\3\2\2\2\20\u0094\3\2\2\2\22\u00a6"+ + "\3\2\2\2\24\u00a8\3\2\2\2\26\u00b0\3\2\2\2\30\u00b7\3\2\2\2\32\u00d2\3"+ + "\2\2\2\34\u00df\3\2\2\2\36\u0104\3\2\2\2 \u012d\3\2\2\2\"\u0138\3\2\2"+ + "\2$\u013d\3\2\2\2&\u0143\3\2\2\2(\u0145\3\2\2\2*\u0160\3\2\2\2,\u016c"+ + "\3\2\2\2./\5\6\4\2/\60\7\2\2\3\60\3\3\2\2\2\61\62\5\"\22\2\62\63\7\2\2"+ + "\3\63\5\3\2\2\2\64\66\5\b\5\2\65\64\3\2\2\2\66\67\3\2\2\2\67\65\3\2\2"+ + "\2\678\3\2\2\28\7\3\2\2\29:\5\30\r\2:;\7?\2\2;=\7\3\2\2<>\5\24\13\2=<"+ + "\3\2\2\2=>\3\2\2\2>?\3\2\2\2?@\7\4\2\2@B\7\5\2\2AC\5\f\7\2BA\3\2\2\2B"+ + "C\3\2\2\2CD\3\2\2\2DE\7\6\2\2EH\3\2\2\2FH\5\n\6\2G9\3\2\2\2GF\3\2\2\2"+ + "H\t\3\2\2\2IK\7\7\2\2JI\3\2\2\2JK\3\2\2\2KL\3\2\2\2LM\5\30\r\2MP\7?\2"+ + "\2NO\7\b\2\2OQ\5\32\16\2PN\3\2\2\2PQ\3\2\2\2QR\3\2\2\2RS\7\t\2\2S\13\3"+ + "\2\2\2TV\5\16\b\2UT\3\2\2\2VW\3\2\2\2WU\3\2\2\2WX\3\2\2\2X\r\3\2\2\2Y"+ + "\u0092\5\n\6\2Z\\\7\5\2\2[]\5\f\7\2\\[\3\2\2\2\\]\3\2\2\2]^\3\2\2\2^\u0092"+ + "\7\6\2\2_`\5\34\17\2`a\7\b\2\2ab\5\36\20\2bc\7\t\2\2c\u0092\3\2\2\2de"+ + "\5\36\20\2ef\7\t\2\2f\u0092\3\2\2\2gh\7\n\2\2hi\7\3\2\2ij\5\36\20\2jk"+ + "\7\4\2\2kn\5\16\b\2lm\7\13\2\2mo\5\16\b\2nl\3\2\2\2no\3\2\2\2o\u0092\3"+ + "\2\2\2pq\7\f\2\2qr\7\3\2\2rs\5\36\20\2st\7\4\2\2tu\5\16\b\2u\u0092\3\2"+ + "\2\2vw\7\r\2\2wx\5\16\b\2xy\7\f\2\2yz\7\3\2\2z{\5\36\20\2{|\7\4\2\2|}"+ + "\7\t\2\2}\u0092\3\2\2\2~\177\7\16\2\2\177\u0081\7\3\2\2\u0080\u0082\5"+ + "\20\t\2\u0081\u0080\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0083\3\2\2\2\u0083"+ + "\u0084\5\22\n\2\u0084\u0085\7\4\2\2\u0085\u0086\5\16\b\2\u0086\u0092\3"+ + "\2\2\2\u0087\u0089\7\17\2\2\u0088\u008a\5\36\20\2\u0089\u0088\3\2\2\2"+ + "\u0089\u008a\3\2\2\2\u008a\u008b\3\2\2\2\u008b\u0092\7\t\2\2\u008c\u008d"+ + "\7\20\2\2\u008d\u008e\7\5\2\2\u008e\u008f\5\"\22\2\u008f\u0090\7\6\2\2"+ + "\u0090\u0092\3\2\2\2\u0091Y\3\2\2\2\u0091Z\3\2\2\2\u0091_\3\2\2\2\u0091"+ + "d\3\2\2\2\u0091g\3\2\2\2\u0091p\3\2\2\2\u0091v\3\2\2\2\u0091~\3\2\2\2"+ + "\u0091\u0087\3\2\2\2\u0091\u008c\3\2\2\2\u0092\17\3\2\2\2\u0093\u0095"+ + "\5\30\r\2\u0094\u0093\3\2\2\2\u0094\u0095\3\2\2\2\u0095\u0096\3\2\2\2"+ + "\u0096\u0099\7?\2\2\u0097\u0098\7\b\2\2\u0098\u009a\5\32\16\2\u0099\u0097"+ + "\3\2\2\2\u0099\u009a\3\2\2\2\u009a\21\3\2\2\2\u009b\u009c\7\t\2\2\u009c"+ + "\u009d\5\36\20\2\u009d\u009f\7\t\2\2\u009e\u00a0\5\36\20\2\u009f\u009e"+ + "\3\2\2\2\u009f\u00a0\3\2\2\2\u00a0\u00a7\3\2\2\2\u00a1\u00a2\7\21\2\2"+ + "\u00a2\u00a3\5\36\20\2\u00a3\u00a4\7\22\2\2\u00a4\u00a5\5\36\20\2\u00a5"+ + "\u00a7\3\2\2\2\u00a6\u009b\3\2\2\2\u00a6\u00a1\3\2\2\2\u00a7\23\3\2\2"+ + "\2\u00a8\u00ad\5\26\f\2\u00a9\u00aa\7\23\2\2\u00aa\u00ac\5\26\f\2\u00ab"+ + "\u00a9\3\2\2\2\u00ac\u00af\3\2\2\2\u00ad\u00ab\3\2\2\2\u00ad\u00ae\3\2"+ + "\2\2\u00ae\25\3\2\2\2\u00af\u00ad\3\2\2\2\u00b0\u00b1\5\30\r\2\u00b1\u00b2"+ + "\7?\2\2\u00b2\27\3\2\2\2\u00b3\u00b4\b\r\1\2\u00b4\u00b8\7\62\2\2\u00b5"+ + "\u00b6\7\24\2\2\u00b6\u00b8\7\62\2\2\u00b7\u00b3\3\2\2\2\u00b7\u00b5\3"+ + "\2\2\2\u00b8\u00c3\3\2\2\2\u00b9\u00ba\f\4\2\2\u00ba\u00c2\7\25\2\2\u00bb"+ + "\u00bc\f\3\2\2\u00bc\u00be\7\26\2\2\u00bd\u00bf\5\36\20\2\u00be\u00bd"+ + "\3\2\2\2\u00be\u00bf\3\2\2\2\u00bf\u00c0\3\2\2\2\u00c0\u00c2\7\27\2\2"+ + "\u00c1\u00b9\3\2\2\2\u00c1\u00bb\3\2\2\2\u00c2\u00c5\3\2\2\2\u00c3\u00c1"+ + "\3\2\2\2\u00c3\u00c4\3\2\2\2\u00c4\31\3\2\2\2\u00c5\u00c3\3\2\2\2\u00c6"+ + "\u00d3\5\36\20\2\u00c7\u00c8\7\5\2\2\u00c8\u00cd\5\32\16\2\u00c9\u00ca"+ + "\7\23\2\2\u00ca\u00cc\5\32\16\2\u00cb\u00c9\3\2\2\2\u00cc\u00cf\3\2\2"+ + "\2\u00cd\u00cb\3\2\2\2\u00cd\u00ce\3\2\2\2\u00ce\u00d0\3\2\2\2\u00cf\u00cd"+ + "\3\2\2\2\u00d0\u00d1\7\6\2\2\u00d1\u00d3\3\2\2\2\u00d2\u00c6\3\2\2\2\u00d2"+ + "\u00c7\3\2\2\2\u00d3\33\3\2\2\2\u00d4\u00d5\b\17\1\2\u00d5\u00e0\7?\2"+ + "\2\u00d6\u00d7\7\25\2\2\u00d7\u00e0\7?\2\2\u00d8\u00d9\7\25\2\2\u00d9"+ + "\u00da\7\3\2\2\u00da\u00db\5\36\20\2\u00db\u00dc\7\4\2\2\u00dc\u00e0\3"+ + "\2\2\2\u00dd\u00de\t\2\2\2\u00de\u00e0\5\34\17\4\u00df\u00d4\3\2\2\2\u00df"+ + "\u00d6\3\2\2\2\u00df\u00d8\3\2\2\2\u00df\u00dd\3\2\2\2\u00e0\u00e8\3\2"+ + "\2\2\u00e1\u00e2\f\3\2\2\u00e2\u00e3\7\26\2\2\u00e3\u00e4\5\36\20\2\u00e4"+ + "\u00e5\7\27\2\2\u00e5\u00e7\3\2\2\2\u00e6\u00e1\3\2\2\2\u00e7\u00ea\3"+ + "\2\2\2\u00e8\u00e6\3\2\2\2\u00e8\u00e9\3\2\2\2\u00e9\35\3\2\2\2\u00ea"+ + "\u00e8\3\2\2\2\u00eb\u00ec\b\20\1\2\u00ec\u00ed\7\3\2\2\u00ed\u00ee\5"+ + "\36\20\2\u00ee\u00ef\7\4\2\2\u00ef\u0105\3\2\2\2\u00f0\u00f1\7?\2\2\u00f1"+ + "\u00f3\7\3\2\2\u00f2\u00f4\5 \21\2\u00f3\u00f2\3\2\2\2\u00f3\u00f4\3\2"+ + "\2\2\u00f4\u00f5\3\2\2\2\u00f5\u0105\7\4\2\2\u00f6\u00f7\7\3\2\2\u00f7"+ + "\u00f8\5\30\r\2\u00f8\u00f9\7\4\2\2\u00f9\u00fa\5\36\20\25\u00fa\u0105"+ + "\3\2\2\2\u00fb\u00fc\t\3\2\2\u00fc\u0105\5\36\20\23\u00fd\u00fe\t\4\2"+ + "\2\u00fe\u0105\5\36\20\21\u00ff\u0105\7?\2\2\u0100\u0105\7\66\2\2\u0101"+ + "\u0105\7\63\2\2\u0102\u0105\7\64\2\2\u0103\u0105\7\65\2\2\u0104\u00eb"+ + "\3\2\2\2\u0104\u00f0\3\2\2\2\u0104\u00f6\3\2\2\2\u0104\u00fb\3\2\2\2\u0104"+ + "\u00fd\3\2\2\2\u0104\u00ff\3\2\2\2\u0104\u0100\3\2\2\2\u0104\u0101\3\2"+ + "\2\2\u0104\u0102\3\2\2\2\u0104\u0103\3\2\2\2\u0105\u012a\3\2\2\2\u0106"+ + "\u0107\f\20\2\2\u0107\u0108\t\5\2\2\u0108\u0129\5\36\20\21\u0109\u010a"+ + "\f\17\2\2\u010a\u010b\t\6\2\2\u010b\u0129\5\36\20\20\u010c\u010d\f\16"+ + "\2\2\u010d\u010e\t\7\2\2\u010e\u0129\5\36\20\17\u010f\u0110\f\r\2\2\u0110"+ + "\u0111\t\b\2\2\u0111\u0129\5\36\20\16\u0112\u0113\f\f\2\2\u0113\u0114"+ + "\7\37\2\2\u0114\u0129\5\36\20\r\u0115\u0116\f\13\2\2\u0116\u0117\7,\2"+ + "\2\u0117\u0129\5\36\20\f\u0118\u0119\f\n\2\2\u0119\u011a\7-\2\2\u011a"+ + "\u0129\5\36\20\13\u011b\u011c\f\t\2\2\u011c\u011d\7.\2\2\u011d\u0129\5"+ + "\36\20\n\u011e\u011f\f\b\2\2\u011f\u0120\7/\2\2\u0120\u0129\5\36\20\t"+ + "\u0121\u0122\f\24\2\2\u0122\u0123\7\26\2\2\u0123\u0124\5\36\20\2\u0124"+ + "\u0125\7\27\2\2\u0125\u0129\3\2\2\2\u0126\u0127\f\22\2\2\u0127\u0129\t"+ + "\3\2\2\u0128\u0106\3\2\2\2\u0128\u0109\3\2\2\2\u0128\u010c\3\2\2\2\u0128"+ + "\u010f\3\2\2\2\u0128\u0112\3\2\2\2\u0128\u0115\3\2\2\2\u0128\u0118\3\2"+ + "\2\2\u0128\u011b\3\2\2\2\u0128\u011e\3\2\2\2\u0128\u0121\3\2\2\2\u0128"+ + "\u0126\3\2\2\2\u0129\u012c\3\2\2\2\u012a\u0128\3\2\2\2\u012a\u012b\3\2"+ + "\2\2\u012b\37\3\2\2\2\u012c\u012a\3\2\2\2\u012d\u0132\5\36\20\2\u012e"+ + "\u012f\7\23\2\2\u012f\u0131\5\36\20\2\u0130\u012e\3\2\2\2\u0131\u0134"+ + "\3\2\2\2\u0132\u0130\3\2\2\2\u0132\u0133\3\2\2\2\u0133!\3\2\2\2\u0134"+ + "\u0132\3\2\2\2\u0135\u0137\5$\23\2\u0136\u0135\3\2\2\2\u0137\u013a\3\2"+ + "\2\2\u0138\u0136\3\2\2\2\u0138\u0139\3\2\2\2\u0139#\3\2\2\2\u013a\u0138"+ + "\3\2\2\2\u013b\u013e\5&\24\2\u013c\u013e\5(\25\2\u013d\u013b\3\2\2\2\u013d"+ + "\u013c\3\2\2\2\u013e%\3\2\2\2\u013f\u0140\7?\2\2\u0140\u0144\7\21\2\2"+ + "\u0141\u0142\7\36\2\2\u0142\u0144\7\21\2\2\u0143\u013f\3\2\2\2\u0143\u0141"+ + "\3\2\2\2\u0144\'\3\2\2\2\u0145\u0147\7\61\2\2\u0146\u0148\5*\26\2\u0147"+ + "\u0146\3\2\2\2\u0147\u0148\3\2\2\2\u0148)\3\2\2\2\u0149\u0161\5,\27\2"+ + "\u014a\u014b\7\60\2\2\u014b\u0161\5,\27\2\u014c\u014d\5,\27\2\u014d\u014e"+ + "\7\23\2\2\u014e\u014f\7?\2\2\u014f\u0161\3\2\2\2\u0150\u0151\7\3\2\2\u0151"+ + "\u0152\5,\27\2\u0152\u0153\7\4\2\2\u0153\u0154\7\23\2\2\u0154\u0155\7"+ + "?\2\2\u0155\u0161\3\2\2\2\u0156\u0157\7\3\2\2\u0157\u0158\5,\27\2\u0158"+ + "\u0159\7\23\2\2\u0159\u015a\7?\2\2\u015a\u015b\7\4\2\2\u015b\u0161\3\2"+ + "\2\2\u015c\u015d\7\3\2\2\u015d\u015e\5,\27\2\u015e\u015f\7\4\2\2\u015f"+ + "\u0161\3\2\2\2\u0160\u0149\3\2\2\2\u0160\u014a\3\2\2\2\u0160\u014c\3\2"+ + "\2\2\u0160\u0150\3\2\2\2\u0160\u0156\3\2\2\2\u0160\u015c\3\2\2\2\u0161"+ + "+\3\2\2\2\u0162\u0163\b\27\1\2\u0163\u0164\t\t\2\2\u0164\u016d\5,\27\n"+ + "\u0165\u016d\7?\2\2\u0166\u016d\7@\2\2\u0167\u0168\7\5\2\2\u0168\u0169"+ + "\7?\2\2\u0169\u016d\7\6\2\2\u016a\u016d\7\66\2\2\u016b\u016d\7\64\2\2"+ + "\u016c\u0162\3\2\2\2\u016c\u0165\3\2\2\2\u016c\u0166\3\2\2\2\u016c\u0167"+ + "\3\2\2\2\u016c\u016a\3\2\2\2\u016c\u016b\3\2\2\2\u016d\u0176\3\2\2\2\u016e"+ + "\u016f\f\t\2\2\u016f\u0170\t\n\2\2\u0170\u0175\5,\27\n\u0171\u0172\f\b"+ + "\2\2\u0172\u0173\t\7\2\2\u0173\u0175\5,\27\t\u0174\u016e\3\2\2\2\u0174"+ + "\u0171\3\2\2\2\u0175\u0178\3\2\2\2\u0176\u0174\3\2\2\2\u0176\u0177\3\2"+ + "\2\2\u0177-\3\2\2\2\u0178\u0176\3\2\2\2(\67=BGJPW\\n\u0081\u0089\u0091"+ + "\u0094\u0099\u009f\u00a6\u00ad\u00b7\u00be\u00c1\u00c3\u00cd\u00d2\u00df"+ + "\u00e8\u00f3\u0104\u0128\u012a\u0132\u0138\u013d\u0143\u0147\u0160\u016c"+ + "\u0174\u0176"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCVisitor.java b/src/main/java/dk/camelot64/kickc/parser/KickCVisitor.java index eda5152ed..abe57c72f 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCVisitor.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCVisitor.java @@ -22,12 +22,45 @@ public interface KickCVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitAsmFile(KickCParser.AsmFileContext ctx); + /** + * Visit a parse tree produced by {@link KickCParser#declSeq}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclSeq(KickCParser.DeclSeqContext ctx); + /** + * Visit a parse tree produced by the {@code declMethod} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclMethod(KickCParser.DeclMethodContext ctx); + /** + * Visit a parse tree produced by the {@code declVariable} + * labeled alternative in {@link KickCParser#decl}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclVariable(KickCParser.DeclVariableContext ctx); + /** + * Visit a parse tree produced by {@link KickCParser#declVar}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclVar(KickCParser.DeclVarContext ctx); /** * Visit a parse tree produced by {@link KickCParser#stmtSeq}. * @param ctx the parse tree * @return the visitor result */ T visitStmtSeq(KickCParser.StmtSeqContext ctx); + /** + * Visit a parse tree produced by the {@code stmtDeclVar} + * labeled alternative in {@link KickCParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStmtDeclVar(KickCParser.StmtDeclVarContext ctx); /** * Visit a parse tree produced by the {@code stmtBlock} * labeled alternative in {@link KickCParser#stmt}. @@ -35,20 +68,6 @@ public interface KickCVisitor extends ParseTreeVisitor { * @return the visitor result */ T visitStmtBlock(KickCParser.StmtBlockContext ctx); - /** - * Visit a parse tree produced by the {@code stmtFunction} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStmtFunction(KickCParser.StmtFunctionContext ctx); - /** - * Visit a parse tree produced by the {@code stmtDeclaration} - * labeled alternative in {@link KickCParser#stmt}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStmtDeclaration(KickCParser.StmtDeclarationContext ctx); /** * Visit a parse tree produced by the {@code stmtAssignment} * labeled alternative in {@link KickCParser#stmt}. diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java index 85308f804..423e97042 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateStatementSequence.java @@ -52,15 +52,86 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { @Override public Void visitFile(KickCParser.FileContext ctx) { - List stmts = ctx.stmtSeq().stmt(); - for (KickCParser.StmtContext stmt : stmts) { - if (stmt instanceof KickCParser.StmtDeclarationContext || stmt instanceof KickCParser.StmtFunctionContext) { - this.visit(stmt); - } else { - program.getLog().append("Statement not allowed outside method. " + stmt.getText()); - throw new CompileError("Statement not allowed outside method. " + stmt.getText()); - } + this.visit(ctx.declSeq()); + return null; + } + @Override + public Object visitDeclSeq(KickCParser.DeclSeqContext ctx) { + for (KickCParser.DeclContext declContext : ctx.decl()) { + this.visit(declContext); + } + return null; + } + + @Override + public Object visitDeclMethod(KickCParser.DeclMethodContext ctx) { + SymbolType type = (SymbolType) visit(ctx.typeDecl()); + String name = ctx.NAME().getText(); + Procedure procedure = getCurrentSymbols().addProcedure(name, type); + scopeStack.push(procedure); + Label procExit = procedure.addLabel(SymbolRef.PROCEXIT_BLOCK_NAME); + VariableUnversioned returnVar = null; + if (!SymbolType.VOID.equals(type)) { + returnVar = procedure.addVariable("return", type); + } + List parameterList = new ArrayList<>(); + if (ctx.parameterListDecl() != null) { + parameterList = (List) this.visit(ctx.parameterListDecl()); + } + procedure.setParameters(parameterList); + sequence.addStatement(new StatementProcedureBegin(procedure.getRef())); + if (ctx.stmtSeq() != null) { + this.visit(ctx.stmtSeq()); + } + sequence.addStatement(new StatementLabel(procExit.getRef())); + if (returnVar != null) { + sequence.addStatement(new StatementAssignment(returnVar, returnVar)); + } + VariableRef returnVarRef = null; + if (returnVar != null) { + returnVarRef = returnVar.getRef(); + } + sequence.addStatement(new StatementReturn(returnVarRef)); + scopeStack.pop(); + sequence.addStatement(new StatementProcedureEnd(procedure.getRef())); + return null; + } + + @Override + public List visitParameterListDecl(KickCParser.ParameterListDeclContext ctx) { + ArrayList parameterDecls = new ArrayList<>(); + for (KickCParser.ParameterDeclContext parameterDeclCtx : ctx.parameterDecl()) { + Variable parameterDecl = (Variable) this.visit(parameterDeclCtx); + parameterDecls.add(parameterDecl); + } + return parameterDecls; + } + + @Override + public Variable visitParameterDecl(KickCParser.ParameterDeclContext ctx) { + SymbolType type = (SymbolType) this.visit(ctx.typeDecl()); + VariableUnversioned param = new VariableUnversioned(ctx.NAME().getText(), getCurrentSymbols(), type); + return param; + } + + @Override + public Object visitDeclVariable(KickCParser.DeclVariableContext ctx) { + this.visit(ctx.declVar()); + return null; + } + + @Override + public Object visitDeclVar(KickCParser.DeclVarContext ctx) { + SymbolType type = (SymbolType) visit(ctx.typeDecl()); + String varName = ctx.NAME().getText(); + KickCParser.InitializerContext initializer = ctx.initializer(); + VariableUnversioned lValue = getCurrentSymbols().addVariable(varName, type); + if (ctx.getChild(0).getText().equals("const")) { + lValue.setDeclaredConstant(true); + } + if (initializer != null) { + addInitialAssignment(initializer, lValue); } return null; } @@ -274,39 +345,6 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { return null; } - @Override - public Void visitStmtFunction(KickCParser.StmtFunctionContext ctx) { - SymbolType type = (SymbolType) visit(ctx.typeDecl()); - String name = ctx.NAME().getText(); - Procedure procedure = getCurrentSymbols().addProcedure(name, type); - scopeStack.push(procedure); - Label procExit = procedure.addLabel(SymbolRef.PROCEXIT_BLOCK_NAME); - VariableUnversioned returnVar = null; - if (!SymbolType.VOID.equals(type)) { - returnVar = procedure.addVariable("return", type); - } - List parameterList = new ArrayList<>(); - if (ctx.parameterListDecl() != null) { - parameterList = (List) this.visit(ctx.parameterListDecl()); - } - procedure.setParameters(parameterList); - sequence.addStatement(new StatementProcedureBegin(procedure.getRef())); - if (ctx.stmtSeq() != null) { - this.visit(ctx.stmtSeq()); - } - sequence.addStatement(new StatementLabel(procExit.getRef())); - if (returnVar != null) { - sequence.addStatement(new StatementAssignment(returnVar, returnVar)); - } - VariableRef returnVarRef = null; - if (returnVar != null) { - returnVarRef = returnVar.getRef(); - } - sequence.addStatement(new StatementReturn(returnVarRef)); - scopeStack.pop(); - sequence.addStatement(new StatementProcedureEnd(procedure.getRef())); - return null; - } @Override public Object visitStmtAsm(KickCParser.StmtAsmContext ctx) { @@ -314,28 +352,11 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { return null; } - @Override - public List visitParameterListDecl(KickCParser.ParameterListDeclContext ctx) { - ArrayList parameterDecls = new ArrayList<>(); - for (KickCParser.ParameterDeclContext parameterDeclCtx : ctx.parameterDecl()) { - Variable parameterDecl = (Variable) this.visit(parameterDeclCtx); - parameterDecls.add(parameterDecl); - } - return parameterDecls; - } - - @Override - public Variable visitParameterDecl(KickCParser.ParameterDeclContext ctx) { - SymbolType type = (SymbolType) this.visit(ctx.typeDecl()); - VariableUnversioned param = new VariableUnversioned(ctx.NAME().getText(), getCurrentSymbols(), type); - return param; - } - @Override public Void visitStmtReturn(KickCParser.StmtReturnContext ctx) { Procedure procedure = getCurrentProcedure(); KickCParser.ExprContext exprCtx = ctx.expr(); - RValue rValue = null; + RValue rValue; if (exprCtx != null) { PrePostModifierHandler.addPreModifiers(this, exprCtx); rValue = (RValue) this.visit(exprCtx); @@ -349,17 +370,8 @@ public class Pass1GenerateStatementSequence extends KickCBaseVisitor { } @Override - public Void visitStmtDeclaration(KickCParser.StmtDeclarationContext ctx) { - SymbolType type = (SymbolType) visit(ctx.typeDecl()); - String varName = ctx.NAME().getText(); - KickCParser.InitializerContext initializer = ctx.initializer(); - VariableUnversioned lValue = getCurrentSymbols().addVariable(varName, type); - if (ctx.getChild(0).getText().equals("const")) { - lValue.setDeclaredConstant(true); - } - if (initializer != null) { - addInitialAssignment(initializer, lValue); - } + public Object visitStmtDeclVar(KickCParser.StmtDeclVarContext ctx) { + this.visit(ctx.declVar()); return null; }