// Generated from D:/Guillermo Arce/Desktop/lab_project/src/parser\Cmm.g4 by ANTLR 4.9.1 package parser; import ast.*; import ast.definition.*; import ast.definition.classes.*; import ast.expression.*; import ast.expression.classes.*; import ast.statement.*; import ast.statement.classes.*; import ast.type.*; import ast.type.classes.*; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; import org.antlr.v4.runtime.*; import org.antlr.v4.runtime.misc.*; import org.antlr.v4.runtime.tree.*; import java.util.List; import java.util.Iterator; import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class CmmParser extends Parser { static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, INT_CONSTANT=37, ID=38, REAL_CONSTANT=39, CHAR_CONSTANT=40, LINE_COMMENT=41, BLOCK_COMMENT=42, WHITE_SPACE=43, NEW_LINE=44, TAB=45, CARRIAGE_RETURN=46; public static final int RULE_program = 0, RULE_program_definitions = 1, RULE_main_function = 2, RULE_expression = 3, RULE_function_invocation = 4, RULE_arguments = 5, RULE_statement = 6, RULE_block = 7, RULE_var_definition = 8, RULE_func_definition = 9, RULE_return_type = 10, RULE_function_block = 11, RULE_function_param = 12, RULE_primitive_type = 13, RULE_type = 14, RULE_void_type = 15, RULE_record_fields = 16; private static String[] makeRuleNames() { return new String[] { "program", "program_definitions", "main_function", "expression", "function_invocation", "arguments", "statement", "block", "var_definition", "func_definition", "return_type", "function_block", "function_param", "primitive_type", "type", "void_type", "record_fields" }; } public static final String[] ruleNames = makeRuleNames(); private static String[] makeLiteralNames() { return new String[] { null, "'main'", "'('", "')'", "'['", "']'", "'.'", "'-'", "'!'", "'*'", "'/'", "'%'", "'+'", "'>'", "'>='", "'<'", "'<='", "'!='", "'=='", "'&&'", "'||'", "','", "'read'", "';'", "'write'", "'='", "'return'", "'if'", "'else'", "'while'", "'{'", "'}'", "'int'", "'char'", "'double'", "'struct'", "'void'", null, null, null, null, null, null, null, "'\n'", "'\t'", "'\r'" }; } private static final String[] _LITERAL_NAMES = makeLiteralNames(); private static String[] makeSymbolicNames() { return new String[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "INT_CONSTANT", "ID", "REAL_CONSTANT", "CHAR_CONSTANT", "LINE_COMMENT", "BLOCK_COMMENT", "WHITE_SPACE", "NEW_LINE", "TAB", "CARRIAGE_RETURN" }; } private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** * @deprecated Use {@link #VOCABULARY} instead. */ @Deprecated public static final String[] tokenNames; static { tokenNames = new String[_SYMBOLIC_NAMES.length]; for (int i = 0; i < tokenNames.length; i++) { tokenNames[i] = VOCABULARY.getLiteralName(i); if (tokenNames[i] == null) { tokenNames[i] = VOCABULARY.getSymbolicName(i); } if (tokenNames[i] == null) { tokenNames[i] = "<INVALID>"; } } } @Override @Deprecated public String[] getTokenNames() { return tokenNames; } @Override public Vocabulary getVocabulary() { return VOCABULARY; } @Override public String getGrammarFileName() { return "Cmm.g4"; } @Override public String[] getRuleNames() { return ruleNames; } @Override public String getSerializedATN() { return _serializedATN; } @Override public ATN getATN() { return _ATN; } public CmmParser(TokenStream input) { super(input); _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } public static class ProgramContext extends ParserRuleContext { public Program ast; public Program_definitionsContext p1; public Main_functionContext m1; public TerminalNode EOF() { return getToken(CmmParser.EOF, 0); } public Program_definitionsContext program_definitions() { return getRuleContext(Program_definitionsContext.class,0); } public Main_functionContext main_function() { return getRuleContext(Main_functionContext.class,0); } public ProgramContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_program; } } public final ProgramContext program() throws RecognitionException { ProgramContext _localctx = new ProgramContext(_ctx, getState()); enterRule(_localctx, 0, RULE_program); try { enterOuterAlt(_localctx, 1); { setState(34); ((ProgramContext)_localctx).p1 = program_definitions(); setState(35); ((ProgramContext)_localctx).m1 = main_function(); ((ProgramContext)_localctx).p1.ast.add(((ProgramContext)_localctx).m1.ast); ((ProgramContext)_localctx).ast = new Program(((ProgramContext)_localctx).p1.ast.get(0).getLine(),((ProgramContext)_localctx).p1.ast.get(0).getColumn(),((ProgramContext)_localctx).p1.ast); setState(37); match(EOF); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Program_definitionsContext extends ParserRuleContext { public List<Definition> ast = new ArrayList<Definition>();; public Var_definitionContext v1; public Func_definitionContext f1; public Var_definitionContext v2; public List<Var_definitionContext> var_definition() { return getRuleContexts(Var_definitionContext.class); } public Var_definitionContext var_definition(int i) { return getRuleContext(Var_definitionContext.class,i); } public List<Func_definitionContext> func_definition() { return getRuleContexts(Func_definitionContext.class); } public Func_definitionContext func_definition(int i) { return getRuleContext(Func_definitionContext.class,i); } public Program_definitionsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_program_definitions; } } public final Program_definitionsContext program_definitions() throws RecognitionException { Program_definitionsContext _localctx = new Program_definitionsContext(_ctx, getState()); enterRule(_localctx, 2, RULE_program_definitions); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { setState(44); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,0,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { setState(39); ((Program_definitionsContext)_localctx).v1 = var_definition(); ((Program_definitionsContext)_localctx).v1.ast.forEach(var -> _localctx.ast.add(var)); } } } setState(46); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,0,_ctx); } setState(52); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,1,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { setState(47); ((Program_definitionsContext)_localctx).f1 = func_definition(); _localctx.ast.add(((Program_definitionsContext)_localctx).f1.ast); } } } setState(54); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,1,_ctx); } setState(60); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__31) | (1L << T__32) | (1L << T__33) | (1L << T__34))) != 0)) { { { setState(55); ((Program_definitionsContext)_localctx).v2 = var_definition(); ((Program_definitionsContext)_localctx).v2.ast.forEach(var -> _localctx.ast.add(var)); } } setState(62); _errHandler.sync(this); _la = _input.LA(1); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Main_functionContext extends ParserRuleContext { public FuncDefinition ast; public Void_typeContext t1; public Token i1; public Function_blockContext b1; public Void_typeContext void_type() { return getRuleContext(Void_typeContext.class,0); } public Function_blockContext function_block() { return getRuleContext(Function_blockContext.class,0); } public Main_functionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_main_function; } } public final Main_functionContext main_function() throws RecognitionException { Main_functionContext _localctx = new Main_functionContext(_ctx, getState()); enterRule(_localctx, 4, RULE_main_function); try { enterOuterAlt(_localctx, 1); { setState(63); ((Main_functionContext)_localctx).t1 = void_type(); setState(64); ((Main_functionContext)_localctx).i1 = match(T__0); setState(65); match(T__1); setState(66); match(T__2); setState(67); ((Main_functionContext)_localctx).b1 = function_block(); ((Main_functionContext)_localctx).ast = new FuncDefinition(((Main_functionContext)_localctx).t1.ast.getLine(), ((Main_functionContext)_localctx).t1.ast.getColumn(),(((Main_functionContext)_localctx).i1!=null?((Main_functionContext)_localctx).i1.getText():null), new FunctionType(((Main_functionContext)_localctx).t1.ast.getLine(), ((Main_functionContext)_localctx).t1.ast.getColumn(),((Main_functionContext)_localctx).t1.ast, new ArrayList<VarDefinition>()), ((Main_functionContext)_localctx).b1.ast); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class ExpressionContext extends ParserRuleContext { public Expression ast; public ExpressionContext e1; public ExpressionContext expression; public Function_invocationContext f1; public Primitive_typeContext dt; public Token i1; public Token r1; public Token c1; public Token ID; public Token op; public ExpressionContext e2; public List<ExpressionContext> expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } public Function_invocationContext function_invocation() { return getRuleContext(Function_invocationContext.class,0); } public Primitive_typeContext primitive_type() { return getRuleContext(Primitive_typeContext.class,0); } public TerminalNode INT_CONSTANT() { return getToken(CmmParser.INT_CONSTANT, 0); } public TerminalNode REAL_CONSTANT() { return getToken(CmmParser.REAL_CONSTANT, 0); } public TerminalNode CHAR_CONSTANT() { return getToken(CmmParser.CHAR_CONSTANT, 0); } public TerminalNode ID() { return getToken(CmmParser.ID, 0); } public ExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_expression; } } public final ExpressionContext expression() throws RecognitionException { return expression(0); } private ExpressionContext expression(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState); ExpressionContext _prevctx = _localctx; int _startState = 6; enterRecursionRule(_localctx, 6, RULE_expression, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { setState(101); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { case 1: { setState(71); match(T__1); setState(72); ((ExpressionContext)_localctx).expression = expression(0); setState(73); match(T__2); ((ExpressionContext)_localctx).ast = ((ExpressionContext)_localctx).expression.ast; } break; case 2: { setState(76); ((ExpressionContext)_localctx).f1 = function_invocation(); ((ExpressionContext)_localctx).ast = ((ExpressionContext)_localctx).f1.ast; } break; case 3: { setState(79); match(T__6); setState(80); ((ExpressionContext)_localctx).e1 = ((ExpressionContext)_localctx).expression = expression(11); ((ExpressionContext)_localctx).ast = new UnaryMinus(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast); } break; case 4: { setState(83); match(T__7); setState(84); ((ExpressionContext)_localctx).e1 = ((ExpressionContext)_localctx).expression = expression(10); ((ExpressionContext)_localctx).ast = new Negation(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast); } break; case 5: { setState(87); match(T__1); setState(88); ((ExpressionContext)_localctx).dt = primitive_type(); setState(89); match(T__2); setState(90); ((ExpressionContext)_localctx).e1 = ((ExpressionContext)_localctx).expression = expression(9); ((ExpressionContext)_localctx).ast = new Cast(((ExpressionContext)_localctx).dt.ast.getLine(),((ExpressionContext)_localctx).dt.ast.getColumn(),((ExpressionContext)_localctx).dt.ast,((ExpressionContext)_localctx).e1.ast); } break; case 6: { setState(93); ((ExpressionContext)_localctx).i1 = match(INT_CONSTANT); ((ExpressionContext)_localctx).ast = new IntLiteral(((ExpressionContext)_localctx).i1.getLine(), ((ExpressionContext)_localctx).i1.getCharPositionInLine()+1, LexerHelper.lexemeToInt((((ExpressionContext)_localctx).i1!=null?((ExpressionContext)_localctx).i1.getText():null))); } break; case 7: { setState(95); ((ExpressionContext)_localctx).r1 = match(REAL_CONSTANT); ((ExpressionContext)_localctx).ast = new DoubleLiteral(((ExpressionContext)_localctx).r1.getLine(), ((ExpressionContext)_localctx).r1.getCharPositionInLine()+1, LexerHelper.lexemeToReal((((ExpressionContext)_localctx).r1!=null?((ExpressionContext)_localctx).r1.getText():null))); } break; case 8: { setState(97); ((ExpressionContext)_localctx).c1 = match(CHAR_CONSTANT); ((ExpressionContext)_localctx).ast = new CharLiteral(((ExpressionContext)_localctx).c1.getLine(), ((ExpressionContext)_localctx).c1.getCharPositionInLine()+1, LexerHelper.lexemeToChar((((ExpressionContext)_localctx).c1!=null?((ExpressionContext)_localctx).c1.getText():null))); } break; case 9: { setState(99); ((ExpressionContext)_localctx).ID = match(ID); ((ExpressionContext)_localctx).ast = new Variable(((ExpressionContext)_localctx).ID.getLine(), ((ExpressionContext)_localctx).ID.getCharPositionInLine()+1, (((ExpressionContext)_localctx).ID!=null?((ExpressionContext)_localctx).ID.getText():null)); } break; } _ctx.stop = _input.LT(-1); setState(135); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,5,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { setState(133); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) { case 1: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(103); if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); setState(104); ((ExpressionContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__8) | (1L << T__9) | (1L << T__10))) != 0)) ) { ((ExpressionContext)_localctx).op = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } setState(105); ((ExpressionContext)_localctx).e2 = ((ExpressionContext)_localctx).expression = expression(9); ((ExpressionContext)_localctx).ast = new Arithmetic(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast,(((ExpressionContext)_localctx).op!=null?((ExpressionContext)_localctx).op.getText():null),((ExpressionContext)_localctx).e2.ast); } break; case 2: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(108); if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); setState(109); ((ExpressionContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__6 || _la==T__11) ) { ((ExpressionContext)_localctx).op = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } setState(110); ((ExpressionContext)_localctx).e2 = ((ExpressionContext)_localctx).expression = expression(8); ((ExpressionContext)_localctx).ast = new Arithmetic(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast,(((ExpressionContext)_localctx).op!=null?((ExpressionContext)_localctx).op.getText():null),((ExpressionContext)_localctx).e2.ast); } break; case 3: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(113); if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(114); ((ExpressionContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16) | (1L << T__17))) != 0)) ) { ((ExpressionContext)_localctx).op = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } setState(115); ((ExpressionContext)_localctx).e2 = ((ExpressionContext)_localctx).expression = expression(7); ((ExpressionContext)_localctx).ast = new Comparison(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast,(((ExpressionContext)_localctx).op!=null?((ExpressionContext)_localctx).op.getText():null),((ExpressionContext)_localctx).e2.ast); } break; case 4: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(118); if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); setState(119); ((ExpressionContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__18 || _la==T__19) ) { ((ExpressionContext)_localctx).op = (Token)_errHandler.recoverInline(this); } else { if ( _input.LA(1)==Token.EOF ) matchedEOF = true; _errHandler.reportMatch(this); consume(); } setState(120); ((ExpressionContext)_localctx).e2 = ((ExpressionContext)_localctx).expression = expression(6); ((ExpressionContext)_localctx).ast = new Logical(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast,(((ExpressionContext)_localctx).op!=null?((ExpressionContext)_localctx).op.getText():null),((ExpressionContext)_localctx).e2.ast); } break; case 5: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(123); if (!(precpred(_ctx, 14))) throw new FailedPredicateException(this, "precpred(_ctx, 14)"); setState(124); match(T__3); setState(125); ((ExpressionContext)_localctx).e2 = ((ExpressionContext)_localctx).expression = expression(0); setState(126); match(T__4); ((ExpressionContext)_localctx).ast = new ArrayIndexing(((ExpressionContext)_localctx).e1.ast.getLine(), ((ExpressionContext)_localctx).e1.ast.getColumn(), ((ExpressionContext)_localctx).e1.ast, ((ExpressionContext)_localctx).e2.ast); } break; case 6: { _localctx = new ExpressionContext(_parentctx, _parentState); _localctx.e1 = _prevctx; _localctx.e1 = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_expression); setState(129); if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); setState(130); match(T__5); setState(131); ((ExpressionContext)_localctx).ID = match(ID); ((ExpressionContext)_localctx).ast = new FieldAccess(((ExpressionContext)_localctx).e1.ast.getLine(),((ExpressionContext)_localctx).e1.ast.getColumn(),((ExpressionContext)_localctx).e1.ast, (((ExpressionContext)_localctx).ID!=null?((ExpressionContext)_localctx).ID.getText():null)); } break; } } } setState(137); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,5,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { unrollRecursionContexts(_parentctx); } return _localctx; } public static class Function_invocationContext extends ParserRuleContext { public FunctionInvocation ast; public Token i2; public ArgumentsContext arguments; public ArgumentsContext arguments() { return getRuleContext(ArgumentsContext.class,0); } public TerminalNode ID() { return getToken(CmmParser.ID, 0); } public Function_invocationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_function_invocation; } } public final Function_invocationContext function_invocation() throws RecognitionException { Function_invocationContext _localctx = new Function_invocationContext(_ctx, getState()); enterRule(_localctx, 8, RULE_function_invocation); try { enterOuterAlt(_localctx, 1); { setState(138); ((Function_invocationContext)_localctx).i2 = match(ID); setState(139); match(T__1); setState(140); ((Function_invocationContext)_localctx).arguments = arguments(); setState(141); match(T__2); ((Function_invocationContext)_localctx).ast = new FunctionInvocation(((Function_invocationContext)_localctx).i2.getLine(), ((Function_invocationContext)_localctx).i2.getCharPositionInLine()+1,new Variable(((Function_invocationContext)_localctx).i2.getLine(), ((Function_invocationContext)_localctx).i2.getCharPositionInLine()+1,(((Function_invocationContext)_localctx).i2!=null?((Function_invocationContext)_localctx).i2.getText():null)), ((Function_invocationContext)_localctx).arguments.ast); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class ArgumentsContext extends ParserRuleContext { public List<Expression> ast = new ArrayList<Expression>(); public ExpressionContext e1; public ExpressionContext e2; public List<ExpressionContext> expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } public ArgumentsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_arguments; } } public final ArgumentsContext arguments() throws RecognitionException { ArgumentsContext _localctx = new ArgumentsContext(_ctx, getState()); enterRule(_localctx, 10, RULE_arguments); int _la; try { setState(156); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: case T__6: case T__7: case INT_CONSTANT: case ID: case REAL_CONSTANT: case CHAR_CONSTANT: enterOuterAlt(_localctx, 1); { setState(144); ((ArgumentsContext)_localctx).e1 = expression(0); _localctx.ast.add(((ArgumentsContext)_localctx).e1.ast); setState(152); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__20) { { { setState(146); match(T__20); setState(147); ((ArgumentsContext)_localctx).e2 = expression(0); _localctx.ast.add(((ArgumentsContext)_localctx).e2.ast); } } setState(154); _errHandler.sync(this); _la = _input.LA(1); } } break; case T__2: case T__22: enterOuterAlt(_localctx, 2); { } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class StatementContext extends ParserRuleContext { public List<Statement> ast = new ArrayList<Statement>(); public ArgumentsContext a1; public Token semicolon; public ExpressionContext e1; public ExpressionContext e2; public BlockContext b1; public BlockContext b2; public Function_invocationContext f1; public ArgumentsContext arguments() { return getRuleContext(ArgumentsContext.class,0); } public List<ExpressionContext> expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } public List<BlockContext> block() { return getRuleContexts(BlockContext.class); } public BlockContext block(int i) { return getRuleContext(BlockContext.class,i); } public Function_invocationContext function_invocation() { return getRuleContext(Function_invocationContext.class,0); } public StatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_statement; } } public final StatementContext statement() throws RecognitionException { StatementContext _localctx = new StatementContext(_ctx, getState()); enterRule(_localctx, 12, RULE_statement); try { setState(206); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { setState(158); match(T__21); setState(159); ((StatementContext)_localctx).a1 = arguments(); setState(160); ((StatementContext)_localctx).semicolon = match(T__22); ((StatementContext)_localctx).a1.ast.forEach(expr -> _localctx.ast.add(new ReadStatement(((StatementContext)_localctx).semicolon.getLine(), ((StatementContext)_localctx).semicolon.getCharPositionInLine()+1, expr))); } break; case 2: enterOuterAlt(_localctx, 2); { setState(163); match(T__23); setState(164); ((StatementContext)_localctx).a1 = arguments(); setState(165); ((StatementContext)_localctx).semicolon = match(T__22); ((StatementContext)_localctx).a1.ast.forEach(expr -> _localctx.ast.add(new WriteStatement(((StatementContext)_localctx).semicolon.getLine(), ((StatementContext)_localctx).semicolon.getCharPositionInLine()+1, expr))); } break; case 3: enterOuterAlt(_localctx, 3); { setState(168); ((StatementContext)_localctx).e1 = expression(0); setState(169); match(T__24); setState(170); ((StatementContext)_localctx).e2 = expression(0); setState(171); match(T__22); _localctx.ast.add(new Assignment(((StatementContext)_localctx).e1.ast.getLine(),((StatementContext)_localctx).e1.ast.getColumn(),((StatementContext)_localctx).e1.ast, ((StatementContext)_localctx).e2.ast)); } break; case 4: enterOuterAlt(_localctx, 4); { setState(174); match(T__25); setState(175); ((StatementContext)_localctx).e1 = expression(0); setState(176); match(T__22); _localctx.ast.add(new Return(((StatementContext)_localctx).e1.ast.getLine(),((StatementContext)_localctx).e1.ast.getColumn(),((StatementContext)_localctx).e1.ast)); } break; case 5: enterOuterAlt(_localctx, 5); { setState(179); match(T__26); setState(180); match(T__1); setState(181); ((StatementContext)_localctx).e1 = expression(0); setState(182); match(T__2); setState(183); ((StatementContext)_localctx).b1 = block(); _localctx.ast.add(new IfElse(((StatementContext)_localctx).e1.ast.getLine(),((StatementContext)_localctx).e1.ast.getColumn(),((StatementContext)_localctx).e1.ast, ((StatementContext)_localctx).b1.ast, new ArrayList<Statement>())); } break; case 6: enterOuterAlt(_localctx, 6); { setState(186); match(T__26); setState(187); match(T__1); setState(188); ((StatementContext)_localctx).e1 = expression(0); setState(189); match(T__2); setState(190); ((StatementContext)_localctx).b1 = block(); setState(191); match(T__27); setState(192); ((StatementContext)_localctx).b2 = block(); _localctx.ast.add(new IfElse(((StatementContext)_localctx).e1.ast.getLine(),((StatementContext)_localctx).e1.ast.getColumn(),((StatementContext)_localctx).e1.ast, ((StatementContext)_localctx).b1.ast, ((StatementContext)_localctx).b2.ast)); } break; case 7: enterOuterAlt(_localctx, 7); { setState(195); match(T__28); setState(196); match(T__1); setState(197); ((StatementContext)_localctx).e1 = expression(0); setState(198); match(T__2); setState(199); ((StatementContext)_localctx).b1 = block(); _localctx.ast.add(new WhileLoop(((StatementContext)_localctx).e1.ast.getLine(),((StatementContext)_localctx).e1.ast.getColumn(),((StatementContext)_localctx).e1.ast, ((StatementContext)_localctx).b1.ast)); } break; case 8: enterOuterAlt(_localctx, 8); { setState(202); ((StatementContext)_localctx).f1 = function_invocation(); setState(203); match(T__22); _localctx.ast.add(((StatementContext)_localctx).f1.ast); } break; } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class BlockContext extends ParserRuleContext { public List<Statement> ast = new ArrayList<Statement>(); public StatementContext s1; public StatementContext s2; public List<StatementContext> statement() { return getRuleContexts(StatementContext.class); } public StatementContext statement(int i) { return getRuleContext(StatementContext.class,i); } public BlockContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_block; } } public final BlockContext block() throws RecognitionException { BlockContext _localctx = new BlockContext(_ctx, getState()); enterRule(_localctx, 14, RULE_block); int _la; try { setState(221); _errHandler.sync(this); switch (_input.LA(1)) { case T__1: case T__6: case T__7: case T__21: case T__23: case T__25: case T__26: case T__28: case INT_CONSTANT: case ID: case REAL_CONSTANT: case CHAR_CONSTANT: enterOuterAlt(_localctx, 1); { setState(208); ((BlockContext)_localctx).s1 = statement(); ((BlockContext)_localctx).s1.ast.forEach(stmt -> _localctx.ast.add(stmt)); } break; case T__29: enterOuterAlt(_localctx, 2); { setState(211); match(T__29); setState(217); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << T__6) | (1L << T__7) | (1L << T__21) | (1L << T__23) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << INT_CONSTANT) | (1L << ID) | (1L << REAL_CONSTANT) | (1L << CHAR_CONSTANT))) != 0)) { { { setState(212); ((BlockContext)_localctx).s2 = statement(); ((BlockContext)_localctx).s2.ast.forEach(stmt -> _localctx.ast.add(stmt)); } } setState(219); _errHandler.sync(this); _la = _input.LA(1); } setState(220); match(T__30); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Var_definitionContext extends ParserRuleContext { public List<VarDefinition> ast = new ArrayList<VarDefinition>(); public TypeContext t1; public Token i1; public Token i2; public TypeContext type() { return getRuleContext(TypeContext.class,0); } public List<TerminalNode> ID() { return getTokens(CmmParser.ID); } public TerminalNode ID(int i) { return getToken(CmmParser.ID, i); } public Var_definitionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_var_definition; } } public final Var_definitionContext var_definition() throws RecognitionException { Var_definitionContext _localctx = new Var_definitionContext(_ctx, getState()); enterRule(_localctx, 16, RULE_var_definition); int _la; try { enterOuterAlt(_localctx, 1); { setState(223); ((Var_definitionContext)_localctx).t1 = type(0); setState(224); ((Var_definitionContext)_localctx).i1 = match(ID); _localctx.ast.add(new VarDefinition(((Var_definitionContext)_localctx).t1.ast.getLine(),((Var_definitionContext)_localctx).t1.ast.getColumn(), (((Var_definitionContext)_localctx).i1!=null?((Var_definitionContext)_localctx).i1.getText():null), ((Var_definitionContext)_localctx).t1.ast)); setState(231); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__20) { { { setState(226); match(T__20); setState(227); ((Var_definitionContext)_localctx).i2 = match(ID); _localctx.ast.add(new VarDefinition(((Var_definitionContext)_localctx).t1.ast.getLine(),((Var_definitionContext)_localctx).t1.ast.getColumn(), (((Var_definitionContext)_localctx).i2!=null?((Var_definitionContext)_localctx).i2.getText():null), ((Var_definitionContext)_localctx).t1.ast)); } } setState(233); _errHandler.sync(this); _la = _input.LA(1); } setState(234); match(T__22); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Func_definitionContext extends ParserRuleContext { public FuncDefinition ast; public Return_typeContext t1; public Token i1; public Function_paramContext f1; public Function_blockContext b1; public Return_typeContext return_type() { return getRuleContext(Return_typeContext.class,0); } public TerminalNode ID() { return getToken(CmmParser.ID, 0); } public Function_paramContext function_param() { return getRuleContext(Function_paramContext.class,0); } public Function_blockContext function_block() { return getRuleContext(Function_blockContext.class,0); } public Func_definitionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_func_definition; } } public final Func_definitionContext func_definition() throws RecognitionException { Func_definitionContext _localctx = new Func_definitionContext(_ctx, getState()); enterRule(_localctx, 18, RULE_func_definition); try { enterOuterAlt(_localctx, 1); { setState(236); ((Func_definitionContext)_localctx).t1 = return_type(); setState(237); ((Func_definitionContext)_localctx).i1 = match(ID); setState(238); match(T__1); setState(239); ((Func_definitionContext)_localctx).f1 = function_param(); setState(240); match(T__2); setState(241); ((Func_definitionContext)_localctx).b1 = function_block(); ((Func_definitionContext)_localctx).ast = new FuncDefinition(((Func_definitionContext)_localctx).t1.ast.getLine(), ((Func_definitionContext)_localctx).t1.ast.getColumn(),(((Func_definitionContext)_localctx).i1!=null?((Func_definitionContext)_localctx).i1.getText():null), new FunctionType(((Func_definitionContext)_localctx).t1.ast.getLine(), ((Func_definitionContext)_localctx).t1.ast.getColumn(),((Func_definitionContext)_localctx).t1.ast, ((Func_definitionContext)_localctx).f1.ast), ((Func_definitionContext)_localctx).b1.ast); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Return_typeContext extends ParserRuleContext { public Type ast; public Primitive_typeContext p; public Void_typeContext v; public Primitive_typeContext primitive_type() { return getRuleContext(Primitive_typeContext.class,0); } public Void_typeContext void_type() { return getRuleContext(Void_typeContext.class,0); } public Return_typeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_return_type; } } public final Return_typeContext return_type() throws RecognitionException { Return_typeContext _localctx = new Return_typeContext(_ctx, getState()); enterRule(_localctx, 20, RULE_return_type); try { setState(250); _errHandler.sync(this); switch (_input.LA(1)) { case T__31: case T__32: case T__33: enterOuterAlt(_localctx, 1); { setState(244); ((Return_typeContext)_localctx).p = primitive_type(); ((Return_typeContext)_localctx).ast = ((Return_typeContext)_localctx).p.ast; } break; case T__35: enterOuterAlt(_localctx, 2); { setState(247); ((Return_typeContext)_localctx).v = void_type(); ((Return_typeContext)_localctx).ast = ((Return_typeContext)_localctx).v.ast; } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Function_blockContext extends ParserRuleContext { public List<Statement> ast = new ArrayList<Statement>(); public Var_definitionContext v1; public StatementContext s1; public List<Var_definitionContext> var_definition() { return getRuleContexts(Var_definitionContext.class); } public Var_definitionContext var_definition(int i) { return getRuleContext(Var_definitionContext.class,i); } public List<StatementContext> statement() { return getRuleContexts(StatementContext.class); } public StatementContext statement(int i) { return getRuleContext(StatementContext.class,i); } public Function_blockContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_function_block; } } public final Function_blockContext function_block() throws RecognitionException { Function_blockContext _localctx = new Function_blockContext(_ctx, getState()); enterRule(_localctx, 22, RULE_function_block); int _la; try { enterOuterAlt(_localctx, 1); { setState(252); match(T__29); setState(258); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__31) | (1L << T__32) | (1L << T__33) | (1L << T__34))) != 0)) { { { setState(253); ((Function_blockContext)_localctx).v1 = var_definition(); ((Function_blockContext)_localctx).v1.ast.forEach(vd -> _localctx.ast.add(vd)); } } setState(260); _errHandler.sync(this); _la = _input.LA(1); } setState(266); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << T__6) | (1L << T__7) | (1L << T__21) | (1L << T__23) | (1L << T__25) | (1L << T__26) | (1L << T__28) | (1L << INT_CONSTANT) | (1L << ID) | (1L << REAL_CONSTANT) | (1L << CHAR_CONSTANT))) != 0)) { { { setState(261); ((Function_blockContext)_localctx).s1 = statement(); ((Function_blockContext)_localctx).s1.ast.forEach(st -> _localctx.ast.add(st)); } } setState(268); _errHandler.sync(this); _la = _input.LA(1); } setState(269); match(T__30); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Function_paramContext extends ParserRuleContext { public List<VarDefinition> ast = new ArrayList<VarDefinition>(); public Primitive_typeContext t1; public Token i1; public Primitive_typeContext t2; public Token i2; public List<Primitive_typeContext> primitive_type() { return getRuleContexts(Primitive_typeContext.class); } public Primitive_typeContext primitive_type(int i) { return getRuleContext(Primitive_typeContext.class,i); } public List<TerminalNode> ID() { return getTokens(CmmParser.ID); } public TerminalNode ID(int i) { return getToken(CmmParser.ID, i); } public Function_paramContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_function_param; } } public final Function_paramContext function_param() throws RecognitionException { Function_paramContext _localctx = new Function_paramContext(_ctx, getState()); enterRule(_localctx, 24, RULE_function_param); int _la; try { setState(285); _errHandler.sync(this); switch (_input.LA(1)) { case T__31: case T__32: case T__33: enterOuterAlt(_localctx, 1); { setState(271); ((Function_paramContext)_localctx).t1 = primitive_type(); setState(272); ((Function_paramContext)_localctx).i1 = match(ID); _localctx.ast.add(new VarDefinition(((Function_paramContext)_localctx).t1.ast.getLine(),((Function_paramContext)_localctx).t1.ast.getColumn(), (((Function_paramContext)_localctx).i1!=null?((Function_paramContext)_localctx).i1.getText():null), ((Function_paramContext)_localctx).t1.ast)); setState(281); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__20) { { { setState(274); match(T__20); setState(275); ((Function_paramContext)_localctx).t2 = primitive_type(); setState(276); ((Function_paramContext)_localctx).i2 = match(ID); _localctx.ast.add(new VarDefinition(((Function_paramContext)_localctx).t2.ast.getLine(),((Function_paramContext)_localctx).t2.ast.getColumn(), (((Function_paramContext)_localctx).i2!=null?((Function_paramContext)_localctx).i2.getText():null), ((Function_paramContext)_localctx).t2.ast)); } } setState(283); _errHandler.sync(this); _la = _input.LA(1); } } break; case T__2: enterOuterAlt(_localctx, 2); { } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Primitive_typeContext extends ParserRuleContext { public Type ast; public Token i; public Token c; public Token d; public Primitive_typeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_primitive_type; } } public final Primitive_typeContext primitive_type() throws RecognitionException { Primitive_typeContext _localctx = new Primitive_typeContext(_ctx, getState()); enterRule(_localctx, 26, RULE_primitive_type); try { setState(293); _errHandler.sync(this); switch (_input.LA(1)) { case T__31: enterOuterAlt(_localctx, 1); { setState(287); ((Primitive_typeContext)_localctx).i = match(T__31); ((Primitive_typeContext)_localctx).ast = new IntType(((Primitive_typeContext)_localctx).i.getLine(), ((Primitive_typeContext)_localctx).i.getCharPositionInLine()+1); } break; case T__32: enterOuterAlt(_localctx, 2); { setState(289); ((Primitive_typeContext)_localctx).c = match(T__32); ((Primitive_typeContext)_localctx).ast = new CharType(((Primitive_typeContext)_localctx).c.getLine(), ((Primitive_typeContext)_localctx).c.getCharPositionInLine()+1); } break; case T__33: enterOuterAlt(_localctx, 3); { setState(291); ((Primitive_typeContext)_localctx).d = match(T__33); ((Primitive_typeContext)_localctx).ast = new DoubleType(((Primitive_typeContext)_localctx).d.getLine(), ((Primitive_typeContext)_localctx).d.getCharPositionInLine()+1); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class TypeContext extends ParserRuleContext { public Type ast; public TypeContext t; public Primitive_typeContext pt; public Record_fieldsContext rf; public Token i; public Primitive_typeContext primitive_type() { return getRuleContext(Primitive_typeContext.class,0); } public Record_fieldsContext record_fields() { return getRuleContext(Record_fieldsContext.class,0); } public TypeContext type() { return getRuleContext(TypeContext.class,0); } public TerminalNode INT_CONSTANT() { return getToken(CmmParser.INT_CONSTANT, 0); } public TypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_type; } } public final TypeContext type() throws RecognitionException { return type(0); } private TypeContext type(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); TypeContext _localctx = new TypeContext(_ctx, _parentState); TypeContext _prevctx = _localctx; int _startState = 28; enterRecursionRule(_localctx, 28, RULE_type, _p); try { int _alt; enterOuterAlt(_localctx, 1); { setState(305); _errHandler.sync(this); switch (_input.LA(1)) { case T__31: case T__32: case T__33: { setState(296); ((TypeContext)_localctx).pt = primitive_type(); ((TypeContext)_localctx).ast = ((TypeContext)_localctx).pt.ast; } break; case T__34: { setState(299); match(T__34); setState(300); match(T__29); setState(301); ((TypeContext)_localctx).rf = record_fields(); setState(302); match(T__30); ((TypeContext)_localctx).ast = new RecordType(((TypeContext)_localctx).rf.ast.get(0).getLine(), ((TypeContext)_localctx).rf.ast.get(0).getColumn(), ((TypeContext)_localctx).rf.ast); ((RecordType)_localctx.ast).checkDuplicatedFields(); } break; default: throw new NoViableAltException(this); } _ctx.stop = _input.LT(-1); setState(314); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,19,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { { _localctx = new TypeContext(_parentctx, _parentState); _localctx.t = _prevctx; _localctx.t = _prevctx; pushNewRecursionContext(_localctx, _startState, RULE_type); setState(307); if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); setState(308); match(T__3); setState(309); ((TypeContext)_localctx).i = match(INT_CONSTANT); setState(310); match(T__4); ((TypeContext)_localctx).ast = new ArrayType(((TypeContext)_localctx).t.ast.getLine(), ((TypeContext)_localctx).t.ast.getColumn(), ((TypeContext)_localctx).t.ast, LexerHelper.lexemeToInt((((TypeContext)_localctx).i!=null?((TypeContext)_localctx).i.getText():null))); ((TypeContext)_localctx).ast = ((ArrayType)_localctx.ast).organizeArraySizes(_localctx.ast,((TypeContext)_localctx).t.ast); } } } setState(316); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,19,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { unrollRecursionContexts(_parentctx); } return _localctx; } public static class Void_typeContext extends ParserRuleContext { public Type ast; public Token v; public Void_typeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_void_type; } } public final Void_typeContext void_type() throws RecognitionException { Void_typeContext _localctx = new Void_typeContext(_ctx, getState()); enterRule(_localctx, 30, RULE_void_type); try { enterOuterAlt(_localctx, 1); { setState(317); ((Void_typeContext)_localctx).v = match(T__35); ((Void_typeContext)_localctx).ast = new VoidType(((Void_typeContext)_localctx).v.getLine(), ((Void_typeContext)_localctx).v.getCharPositionInLine()+1); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class Record_fieldsContext extends ParserRuleContext { public List<RecordField> ast = new ArrayList<RecordField>(); public TypeContext t; public Token i1; public Token i2; public List<TypeContext> type() { return getRuleContexts(TypeContext.class); } public TypeContext type(int i) { return getRuleContext(TypeContext.class,i); } public List<TerminalNode> ID() { return getTokens(CmmParser.ID); } public TerminalNode ID(int i) { return getToken(CmmParser.ID, i); } public Record_fieldsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_record_fields; } } public final Record_fieldsContext record_fields() throws RecognitionException { Record_fieldsContext _localctx = new Record_fieldsContext(_ctx, getState()); enterRule(_localctx, 32, RULE_record_fields); int _la; try { setState(339); _errHandler.sync(this); switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { case 1: enterOuterAlt(_localctx, 1); { setState(335); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__31) | (1L << T__32) | (1L << T__33) | (1L << T__34))) != 0)) { { { setState(320); ((Record_fieldsContext)_localctx).t = type(0); setState(321); ((Record_fieldsContext)_localctx).i1 = match(ID); _localctx.ast.add(new RecordField(((Record_fieldsContext)_localctx).t.ast.getLine(),((Record_fieldsContext)_localctx).t.ast.getColumn(), ((Record_fieldsContext)_localctx).t.ast, (((Record_fieldsContext)_localctx).i1!=null?((Record_fieldsContext)_localctx).i1.getText():null))); setState(328); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__20) { { { setState(323); match(T__20); setState(324); ((Record_fieldsContext)_localctx).i2 = match(ID); _localctx.ast.add( new RecordField(((Record_fieldsContext)_localctx).t.ast.getLine(),((Record_fieldsContext)_localctx).t.ast.getColumn(), ((Record_fieldsContext)_localctx).t.ast, (((Record_fieldsContext)_localctx).i2!=null?((Record_fieldsContext)_localctx).i2.getText():null))); } } setState(330); _errHandler.sync(this); _la = _input.LA(1); } setState(331); match(T__22); } } setState(337); _errHandler.sync(this); _la = _input.LA(1); } } break; case 2: enterOuterAlt(_localctx, 2); { } break; } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { case 3: return expression_sempred((ExpressionContext)_localctx, predIndex); case 14: return type_sempred((TypeContext)_localctx, predIndex); } return true; } private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { switch (predIndex) { case 0: return precpred(_ctx, 8); case 1: return precpred(_ctx, 7); case 2: return precpred(_ctx, 6); case 3: return precpred(_ctx, 5); case 4: return precpred(_ctx, 14); case 5: return precpred(_ctx, 13); } return true; } private boolean type_sempred(TypeContext _localctx, int predIndex) { switch (predIndex) { case 6: return precpred(_ctx, 2); } return true; } public static final String _serializedATN = "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\60\u0158\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"+ "\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\7\3-\n\3\f\3\16\3\60\13\3\3\3\3\3\3\3"+ "\7\3\65\n\3\f\3\16\38\13\3\3\3\3\3\3\3\7\3=\n\3\f\3\16\3@\13\3\3\4\3\4"+ "\3\4\3\4\3\4\3\4\3\4\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\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\5h\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\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\7\5\u0088"+ "\n\5\f\5\16\5\u008b\13\5\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3"+ "\7\7\7\u0099\n\7\f\7\16\7\u009c\13\7\3\7\5\7\u009f\n\7\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\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\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\u00d1\n\b\3\t\3\t\3\t\3\t\3\t"+ "\3\t\3\t\7\t\u00da\n\t\f\t\16\t\u00dd\13\t\3\t\5\t\u00e0\n\t\3\n\3\n\3"+ "\n\3\n\3\n\3\n\7\n\u00e8\n\n\f\n\16\n\u00eb\13\n\3\n\3\n\3\13\3\13\3\13"+ "\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\5\f\u00fd\n\f\3\r\3"+ "\r\3\r\3\r\7\r\u0103\n\r\f\r\16\r\u0106\13\r\3\r\3\r\3\r\7\r\u010b\n\r"+ "\f\r\16\r\u010e\13\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\7"+ "\16\u011a\n\16\f\16\16\16\u011d\13\16\3\16\5\16\u0120\n\16\3\17\3\17\3"+ "\17\3\17\3\17\3\17\5\17\u0128\n\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20"+ "\3\20\3\20\3\20\5\20\u0134\n\20\3\20\3\20\3\20\3\20\3\20\7\20\u013b\n"+ "\20\f\20\16\20\u013e\13\20\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22"+ "\7\22\u0149\n\22\f\22\16\22\u014c\13\22\3\22\3\22\7\22\u0150\n\22\f\22"+ "\16\22\u0153\13\22\3\22\5\22\u0156\n\22\3\22\2\4\b\36\23\2\4\6\b\n\f\16"+ "\20\22\24\26\30\32\34\36 \"\2\6\3\2\13\r\4\2\t\t\16\16\3\2\17\24\3\2\25"+ "\26\2\u016f\2$\3\2\2\2\4.\3\2\2\2\6A\3\2\2\2\bg\3\2\2\2\n\u008c\3\2\2"+ "\2\f\u009e\3\2\2\2\16\u00d0\3\2\2\2\20\u00df\3\2\2\2\22\u00e1\3\2\2\2"+ "\24\u00ee\3\2\2\2\26\u00fc\3\2\2\2\30\u00fe\3\2\2\2\32\u011f\3\2\2\2\34"+ "\u0127\3\2\2\2\36\u0133\3\2\2\2 \u013f\3\2\2\2\"\u0155\3\2\2\2$%\5\4\3"+ "\2%&\5\6\4\2&\'\b\2\1\2\'(\7\2\2\3(\3\3\2\2\2)*\5\22\n\2*+\b\3\1\2+-\3"+ "\2\2\2,)\3\2\2\2-\60\3\2\2\2.,\3\2\2\2./\3\2\2\2/\66\3\2\2\2\60.\3\2\2"+ "\2\61\62\5\24\13\2\62\63\b\3\1\2\63\65\3\2\2\2\64\61\3\2\2\2\658\3\2\2"+ "\2\66\64\3\2\2\2\66\67\3\2\2\2\67>\3\2\2\28\66\3\2\2\29:\5\22\n\2:;\b"+ "\3\1\2;=\3\2\2\2<9\3\2\2\2=@\3\2\2\2><\3\2\2\2>?\3\2\2\2?\5\3\2\2\2@>"+ "\3\2\2\2AB\5 \21\2BC\7\3\2\2CD\7\4\2\2DE\7\5\2\2EF\5\30\r\2FG\b\4\1\2"+ "G\7\3\2\2\2HI\b\5\1\2IJ\7\4\2\2JK\5\b\5\2KL\7\5\2\2LM\b\5\1\2Mh\3\2\2"+ "\2NO\5\n\6\2OP\b\5\1\2Ph\3\2\2\2QR\7\t\2\2RS\5\b\5\rST\b\5\1\2Th\3\2\2"+ "\2UV\7\n\2\2VW\5\b\5\fWX\b\5\1\2Xh\3\2\2\2YZ\7\4\2\2Z[\5\34\17\2[\\\7"+ "\5\2\2\\]\5\b\5\13]^\b\5\1\2^h\3\2\2\2_`\7\'\2\2`h\b\5\1\2ab\7)\2\2bh"+ "\b\5\1\2cd\7*\2\2dh\b\5\1\2ef\7(\2\2fh\b\5\1\2gH\3\2\2\2gN\3\2\2\2gQ\3"+ "\2\2\2gU\3\2\2\2gY\3\2\2\2g_\3\2\2\2ga\3\2\2\2gc\3\2\2\2ge\3\2\2\2h\u0089"+ "\3\2\2\2ij\f\n\2\2jk\t\2\2\2kl\5\b\5\13lm\b\5\1\2m\u0088\3\2\2\2no\f\t"+ "\2\2op\t\3\2\2pq\5\b\5\nqr\b\5\1\2r\u0088\3\2\2\2st\f\b\2\2tu\t\4\2\2"+ "uv\5\b\5\tvw\b\5\1\2w\u0088\3\2\2\2xy\f\7\2\2yz\t\5\2\2z{\5\b\5\b{|\b"+ "\5\1\2|\u0088\3\2\2\2}~\f\20\2\2~\177\7\6\2\2\177\u0080\5\b\5\2\u0080"+ "\u0081\7\7\2\2\u0081\u0082\b\5\1\2\u0082\u0088\3\2\2\2\u0083\u0084\f\17"+ "\2\2\u0084\u0085\7\b\2\2\u0085\u0086\7(\2\2\u0086\u0088\b\5\1\2\u0087"+ "i\3\2\2\2\u0087n\3\2\2\2\u0087s\3\2\2\2\u0087x\3\2\2\2\u0087}\3\2\2\2"+ "\u0087\u0083\3\2\2\2\u0088\u008b\3\2\2\2\u0089\u0087\3\2\2\2\u0089\u008a"+ "\3\2\2\2\u008a\t\3\2\2\2\u008b\u0089\3\2\2\2\u008c\u008d\7(\2\2\u008d"+ "\u008e\7\4\2\2\u008e\u008f\5\f\7\2\u008f\u0090\7\5\2\2\u0090\u0091\b\6"+ "\1\2\u0091\13\3\2\2\2\u0092\u0093\5\b\5\2\u0093\u009a\b\7\1\2\u0094\u0095"+ "\7\27\2\2\u0095\u0096\5\b\5\2\u0096\u0097\b\7\1\2\u0097\u0099\3\2\2\2"+ "\u0098\u0094\3\2\2\2\u0099\u009c\3\2\2\2\u009a\u0098\3\2\2\2\u009a\u009b"+ "\3\2\2\2\u009b\u009f\3\2\2\2\u009c\u009a\3\2\2\2\u009d\u009f\3\2\2\2\u009e"+ "\u0092\3\2\2\2\u009e\u009d\3\2\2\2\u009f\r\3\2\2\2\u00a0\u00a1\7\30\2"+ "\2\u00a1\u00a2\5\f\7\2\u00a2\u00a3\7\31\2\2\u00a3\u00a4\b\b\1\2\u00a4"+ "\u00d1\3\2\2\2\u00a5\u00a6\7\32\2\2\u00a6\u00a7\5\f\7\2\u00a7\u00a8\7"+ "\31\2\2\u00a8\u00a9\b\b\1\2\u00a9\u00d1\3\2\2\2\u00aa\u00ab\5\b\5\2\u00ab"+ "\u00ac\7\33\2\2\u00ac\u00ad\5\b\5\2\u00ad\u00ae\7\31\2\2\u00ae\u00af\b"+ "\b\1\2\u00af\u00d1\3\2\2\2\u00b0\u00b1\7\34\2\2\u00b1\u00b2\5\b\5\2\u00b2"+ "\u00b3\7\31\2\2\u00b3\u00b4\b\b\1\2\u00b4\u00d1\3\2\2\2\u00b5\u00b6\7"+ "\35\2\2\u00b6\u00b7\7\4\2\2\u00b7\u00b8\5\b\5\2\u00b8\u00b9\7\5\2\2\u00b9"+ "\u00ba\5\20\t\2\u00ba\u00bb\b\b\1\2\u00bb\u00d1\3\2\2\2\u00bc\u00bd\7"+ "\35\2\2\u00bd\u00be\7\4\2\2\u00be\u00bf\5\b\5\2\u00bf\u00c0\7\5\2\2\u00c0"+ "\u00c1\5\20\t\2\u00c1\u00c2\7\36\2\2\u00c2\u00c3\5\20\t\2\u00c3\u00c4"+ "\b\b\1\2\u00c4\u00d1\3\2\2\2\u00c5\u00c6\7\37\2\2\u00c6\u00c7\7\4\2\2"+ "\u00c7\u00c8\5\b\5\2\u00c8\u00c9\7\5\2\2\u00c9\u00ca\5\20\t\2\u00ca\u00cb"+ "\b\b\1\2\u00cb\u00d1\3\2\2\2\u00cc\u00cd\5\n\6\2\u00cd\u00ce\7\31\2\2"+ "\u00ce\u00cf\b\b\1\2\u00cf\u00d1\3\2\2\2\u00d0\u00a0\3\2\2\2\u00d0\u00a5"+ "\3\2\2\2\u00d0\u00aa\3\2\2\2\u00d0\u00b0\3\2\2\2\u00d0\u00b5\3\2\2\2\u00d0"+ "\u00bc\3\2\2\2\u00d0\u00c5\3\2\2\2\u00d0\u00cc\3\2\2\2\u00d1\17\3\2\2"+ "\2\u00d2\u00d3\5\16\b\2\u00d3\u00d4\b\t\1\2\u00d4\u00e0\3\2\2\2\u00d5"+ "\u00db\7 \2\2\u00d6\u00d7\5\16\b\2\u00d7\u00d8\b\t\1\2\u00d8\u00da\3\2"+ "\2\2\u00d9\u00d6\3\2\2\2\u00da\u00dd\3\2\2\2\u00db\u00d9\3\2\2\2\u00db"+ "\u00dc\3\2\2\2\u00dc\u00de\3\2\2\2\u00dd\u00db\3\2\2\2\u00de\u00e0\7!"+ "\2\2\u00df\u00d2\3\2\2\2\u00df\u00d5\3\2\2\2\u00e0\21\3\2\2\2\u00e1\u00e2"+ "\5\36\20\2\u00e2\u00e3\7(\2\2\u00e3\u00e9\b\n\1\2\u00e4\u00e5\7\27\2\2"+ "\u00e5\u00e6\7(\2\2\u00e6\u00e8\b\n\1\2\u00e7\u00e4\3\2\2\2\u00e8\u00eb"+ "\3\2\2\2\u00e9\u00e7\3\2\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00ec\3\2\2\2\u00eb"+ "\u00e9\3\2\2\2\u00ec\u00ed\7\31\2\2\u00ed\23\3\2\2\2\u00ee\u00ef\5\26"+ "\f\2\u00ef\u00f0\7(\2\2\u00f0\u00f1\7\4\2\2\u00f1\u00f2\5\32\16\2\u00f2"+ "\u00f3\7\5\2\2\u00f3\u00f4\5\30\r\2\u00f4\u00f5\b\13\1\2\u00f5\25\3\2"+ "\2\2\u00f6\u00f7\5\34\17\2\u00f7\u00f8\b\f\1\2\u00f8\u00fd\3\2\2\2\u00f9"+ "\u00fa\5 \21\2\u00fa\u00fb\b\f\1\2\u00fb\u00fd\3\2\2\2\u00fc\u00f6\3\2"+ "\2\2\u00fc\u00f9\3\2\2\2\u00fd\27\3\2\2\2\u00fe\u0104\7 \2\2\u00ff\u0100"+ "\5\22\n\2\u0100\u0101\b\r\1\2\u0101\u0103\3\2\2\2\u0102\u00ff\3\2\2\2"+ "\u0103\u0106\3\2\2\2\u0104\u0102\3\2\2\2\u0104\u0105\3\2\2\2\u0105\u010c"+ "\3\2\2\2\u0106\u0104\3\2\2\2\u0107\u0108\5\16\b\2\u0108\u0109\b\r\1\2"+ "\u0109\u010b\3\2\2\2\u010a\u0107\3\2\2\2\u010b\u010e\3\2\2\2\u010c\u010a"+ "\3\2\2\2\u010c\u010d\3\2\2\2\u010d\u010f\3\2\2\2\u010e\u010c\3\2\2\2\u010f"+ "\u0110\7!\2\2\u0110\31\3\2\2\2\u0111\u0112\5\34\17\2\u0112\u0113\7(\2"+ "\2\u0113\u011b\b\16\1\2\u0114\u0115\7\27\2\2\u0115\u0116\5\34\17\2\u0116"+ "\u0117\7(\2\2\u0117\u0118\b\16\1\2\u0118\u011a\3\2\2\2\u0119\u0114\3\2"+ "\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2\2\2\u011b\u011c\3\2\2\2\u011c"+ "\u0120\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u0120\3\2\2\2\u011f\u0111\3\2"+ "\2\2\u011f\u011e\3\2\2\2\u0120\33\3\2\2\2\u0121\u0122\7\"\2\2\u0122\u0128"+ "\b\17\1\2\u0123\u0124\7#\2\2\u0124\u0128\b\17\1\2\u0125\u0126\7$\2\2\u0126"+ "\u0128\b\17\1\2\u0127\u0121\3\2\2\2\u0127\u0123\3\2\2\2\u0127\u0125\3"+ "\2\2\2\u0128\35\3\2\2\2\u0129\u012a\b\20\1\2\u012a\u012b\5\34\17\2\u012b"+ "\u012c\b\20\1\2\u012c\u0134\3\2\2\2\u012d\u012e\7%\2\2\u012e\u012f\7 "+ "\2\2\u012f\u0130\5\"\22\2\u0130\u0131\7!\2\2\u0131\u0132\b\20\1\2\u0132"+ "\u0134\3\2\2\2\u0133\u0129\3\2\2\2\u0133\u012d\3\2\2\2\u0134\u013c\3\2"+ "\2\2\u0135\u0136\f\4\2\2\u0136\u0137\7\6\2\2\u0137\u0138\7\'\2\2\u0138"+ "\u0139\7\7\2\2\u0139\u013b\b\20\1\2\u013a\u0135\3\2\2\2\u013b\u013e\3"+ "\2\2\2\u013c\u013a\3\2\2\2\u013c\u013d\3\2\2\2\u013d\37\3\2\2\2\u013e"+ "\u013c\3\2\2\2\u013f\u0140\7&\2\2\u0140\u0141\b\21\1\2\u0141!\3\2\2\2"+ "\u0142\u0143\5\36\20\2\u0143\u0144\7(\2\2\u0144\u014a\b\22\1\2\u0145\u0146"+ "\7\27\2\2\u0146\u0147\7(\2\2\u0147\u0149\b\22\1\2\u0148\u0145\3\2\2\2"+ "\u0149\u014c\3\2\2\2\u014a\u0148\3\2\2\2\u014a\u014b\3\2\2\2\u014b\u014d"+ "\3\2\2\2\u014c\u014a\3\2\2\2\u014d\u014e\7\31\2\2\u014e\u0150\3\2\2\2"+ "\u014f\u0142\3\2\2\2\u0150\u0153\3\2\2\2\u0151\u014f\3\2\2\2\u0151\u0152"+ "\3\2\2\2\u0152\u0156\3\2\2\2\u0153\u0151\3\2\2\2\u0154\u0156\3\2\2\2\u0155"+ "\u0151\3\2\2\2\u0155\u0154\3\2\2\2\u0156#\3\2\2\2\31.\66>g\u0087\u0089"+ "\u009a\u009e\u00d0\u00db\u00df\u00e9\u00fc\u0104\u010c\u011b\u011f\u0127"+ "\u0133\u013c\u014a\u0151\u0155"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } }