674 lines
22 KiB
Java
674 lines
22 KiB
Java
// Generated from /home/tuanvu/Desktop/M1/S8/PDS/tp2-vsl-pds/src/main/antlr/VSLParser.g by ANTLR 4.13.1
|
|
|
|
package TP2;
|
|
|
|
import TP2.Program.Program;
|
|
import TP2.SymTable.SymTable;
|
|
|
|
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", "CheckReturnValue"})
|
|
public class VSLParser extends Parser {
|
|
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
|
|
|
|
protected static final DFA[] _decisionToDFA;
|
|
protected static final PredictionContextCache _sharedContextCache =
|
|
new PredictionContextCache();
|
|
public static final int
|
|
FUNCTION=1, PROTOTYPE=2, TYPE_INT=3, TYPE_VOID=4, LE=5, LT=6, GE=7, GT=8,
|
|
IF=9, THEN=10, ELSE=11, FIN=12, WHILE=13, DO=14, DONE=15, READ=16, PRINT=17,
|
|
RETURN=18, TEXT=19, NUMBER=20, ParO=21, ParF=22, PLUS=23, MINUS=24, DIV=25,
|
|
TIMES=26, WS=27, COMMENT=28;
|
|
public static final int
|
|
RULE_program = 0, RULE_function = 1, RULE_prototype = 2, RULE_list_instr = 3,
|
|
RULE_instruction = 4, RULE_expression = 5, RULE_td_expression = 6, RULE_lit = 7,
|
|
RULE_ident = 8, RULE_type = 9;
|
|
private static String[] makeRuleNames() {
|
|
return new String[] {
|
|
"program", "function", "prototype", "list_instr", "instruction", "expression",
|
|
"td_expression", "lit", "ident", "type"
|
|
};
|
|
}
|
|
public static final String[] ruleNames = makeRuleNames();
|
|
|
|
private static String[] makeLiteralNames() {
|
|
return new String[] {
|
|
null, "'FUNC'", "'PROTO'", "'INT'", "'VOID'", "'<='", "'<'", "'>='",
|
|
"'>'", "'IF'", "'THEN'", "'ELSE'", "'FI'", "'WHILE'", "'DO'", "'DONE'",
|
|
"'READ'", "'PRINT'", "'RETURN'", null, null, "'('", "')'", "'+'", "'-'",
|
|
"'/'", "'*'"
|
|
};
|
|
}
|
|
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
private static String[] makeSymbolicNames() {
|
|
return new String[] {
|
|
null, "FUNCTION", "PROTOTYPE", "TYPE_INT", "TYPE_VOID", "LE", "LT", "GE",
|
|
"GT", "IF", "THEN", "ELSE", "FIN", "WHILE", "DO", "DONE", "READ", "PRINT",
|
|
"RETURN", "TEXT", "NUMBER", "ParO", "ParF", "PLUS", "MINUS", "DIV", "TIMES",
|
|
"WS", "COMMENT"
|
|
};
|
|
}
|
|
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 "VSLParser.g"; }
|
|
|
|
@Override
|
|
public String[] getRuleNames() { return ruleNames; }
|
|
|
|
@Override
|
|
public String getSerializedATN() { return _serializedATN; }
|
|
|
|
@Override
|
|
public ATN getATN() { return _ATN; }
|
|
|
|
public VSLParser(TokenStream input) {
|
|
super(input);
|
|
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class ProgramContext extends ParserRuleContext {
|
|
public Program.Program p;
|
|
public FunctionContext func;
|
|
public TerminalNode EOF() { return getToken(VSLParser.EOF, 0); }
|
|
public FunctionContext function() {
|
|
return getRuleContext(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(20);
|
|
((ProgramContext)_localctx).func = function();
|
|
setState(21);
|
|
match(EOF);
|
|
((ProgramContext)_localctx).p = new Program.Program(((ProgramContext)_localctx).func.out);
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class FunctionContext extends ParserRuleContext {
|
|
public List<Program.Function> out;
|
|
public TypeContext t;
|
|
public IdentContext i;
|
|
public List_instrContext instrs;
|
|
public TerminalNode FUNCTION() { return getToken(VSLParser.FUNCTION, 0); }
|
|
public TerminalNode ParO() { return getToken(VSLParser.ParO, 0); }
|
|
public TerminalNode ParF() { return getToken(VSLParser.ParF, 0); }
|
|
public TypeContext type() {
|
|
return getRuleContext(TypeContext.class,0);
|
|
}
|
|
public IdentContext ident() {
|
|
return getRuleContext(IdentContext.class,0);
|
|
}
|
|
public List_instrContext list_instr() {
|
|
return getRuleContext(List_instrContext.class,0);
|
|
}
|
|
public FunctionContext(ParserRuleContext parent, int invokingState) {
|
|
super(parent, invokingState);
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_function; }
|
|
}
|
|
|
|
public final FunctionContext function() throws RecognitionException {
|
|
FunctionContext _localctx = new FunctionContext(_ctx, getState());
|
|
enterRule(_localctx, 2, RULE_function);
|
|
|
|
SymTable.SymTable sym_table = new SymTable.SymTable();
|
|
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(24);
|
|
match(FUNCTION);
|
|
setState(25);
|
|
((FunctionContext)_localctx).t = type();
|
|
setState(26);
|
|
((FunctionContext)_localctx).i = ident();
|
|
setState(27);
|
|
match(ParO);
|
|
setState(28);
|
|
match(ParF);
|
|
setState(29);
|
|
((FunctionContext)_localctx).instrs = list_instr(sym_table);
|
|
|
|
_localctx.out.add(new Program.Function(((FunctionContext)_localctx).t.return_type, ((FunctionContext)_localctx).i.out, ((FunctionContext)_localctx).instrs.out));
|
|
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class PrototypeContext extends ParserRuleContext {
|
|
public Program.Program p;
|
|
public PrototypeContext(ParserRuleContext parent, int invokingState) {
|
|
super(parent, invokingState);
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_prototype; }
|
|
}
|
|
|
|
public final PrototypeContext prototype() throws RecognitionException {
|
|
PrototypeContext _localctx = new PrototypeContext(_ctx, getState());
|
|
enterRule(_localctx, 4, RULE_prototype);
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class List_instrContext extends ParserRuleContext {
|
|
public SymTable.SymTable table;
|
|
public List<Program.Instruction> out;
|
|
public InstructionContext instruction;
|
|
public InstructionContext instruction() {
|
|
return getRuleContext(InstructionContext.class,0);
|
|
}
|
|
public List_instrContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
|
|
public List_instrContext(ParserRuleContext parent, int invokingState, SymTable.SymTable table) {
|
|
super(parent, invokingState);
|
|
this.table = table;
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_list_instr; }
|
|
}
|
|
|
|
public final List_instrContext list_instr(SymTable.SymTable table) throws RecognitionException {
|
|
List_instrContext _localctx = new List_instrContext(_ctx, getState(), table);
|
|
enterRule(_localctx, 6, RULE_list_instr);
|
|
|
|
List<Program.Instruction> instructions = new List<Program.Instruction>();
|
|
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(34);
|
|
((List_instrContext)_localctx).instruction = instruction(table);
|
|
|
|
instructions.add(((List_instrContext)_localctx).instruction.out);
|
|
((List_instrContext)_localctx).out = instructions;
|
|
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class InstructionContext extends ParserRuleContext {
|
|
public SymTable.SymTable table;
|
|
public List<Program.Instruction> out;
|
|
public TerminalNode RETURN() { return getToken(VSLParser.RETURN, 0); }
|
|
public ExpressionContext expression() {
|
|
return getRuleContext(ExpressionContext.class,0);
|
|
}
|
|
public InstructionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
|
|
public InstructionContext(ParserRuleContext parent, int invokingState, SymTable.SymTable table) {
|
|
super(parent, invokingState);
|
|
this.table = table;
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_instruction; }
|
|
}
|
|
|
|
public final InstructionContext instruction(SymTable.SymTable table) throws RecognitionException {
|
|
InstructionContext _localctx = new InstructionContext(_ctx, getState(), table);
|
|
enterRule(_localctx, 8, RULE_instruction);
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(37);
|
|
match(RETURN);
|
|
setState(38);
|
|
expression(SymTable table);
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class ExpressionContext extends ParserRuleContext {
|
|
public SymTable.SymTable table;
|
|
public Type return_Type;
|
|
public Expression out;
|
|
public Td_expressionContext left;
|
|
public Token op;
|
|
public Td_expressionContext right;
|
|
public List<Td_expressionContext> td_expression() {
|
|
return getRuleContexts(Td_expressionContext.class);
|
|
}
|
|
public Td_expressionContext td_expression(int i) {
|
|
return getRuleContext(Td_expressionContext.class,i);
|
|
}
|
|
public List<TerminalNode> PLUS() { return getTokens(VSLParser.PLUS); }
|
|
public TerminalNode PLUS(int i) {
|
|
return getToken(VSLParser.PLUS, i);
|
|
}
|
|
public List<TerminalNode> MINUS() { return getTokens(VSLParser.MINUS); }
|
|
public TerminalNode MINUS(int i) {
|
|
return getToken(VSLParser.MINUS, i);
|
|
}
|
|
public ExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
|
|
public ExpressionContext(ParserRuleContext parent, int invokingState, SymTable.SymTable table) {
|
|
super(parent, invokingState);
|
|
this.table = table;
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_expression; }
|
|
}
|
|
|
|
public final ExpressionContext expression(SymTable.SymTable table) throws RecognitionException {
|
|
ExpressionContext _localctx = new ExpressionContext(_ctx, getState(), table);
|
|
enterRule(_localctx, 10, RULE_expression);
|
|
int _la;
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(40);
|
|
((ExpressionContext)_localctx).left = td_expression(table);
|
|
|
|
((ExpressionContext)_localctx).out = ((ExpressionContext)_localctx).left.out;
|
|
((ExpressionContext)_localctx).return_Type = ((ExpressionContext)_localctx).left.return_Type;
|
|
|
|
setState(48);
|
|
_errHandler.sync(this);
|
|
_la = _input.LA(1);
|
|
while (_la==PLUS || _la==MINUS) {
|
|
{
|
|
{
|
|
setState(42);
|
|
((ExpressionContext)_localctx).op = _input.LT(1);
|
|
_la = _input.LA(1);
|
|
if ( !(_la==PLUS || _la==MINUS) ) {
|
|
((ExpressionContext)_localctx).op = (Token)_errHandler.recoverInline(this);
|
|
}
|
|
else {
|
|
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
|
|
_errHandler.reportMatch(this);
|
|
consume();
|
|
}
|
|
setState(43);
|
|
((ExpressionContext)_localctx).right = td_expression(table);
|
|
|
|
((ExpressionContext)_localctx).out = new Program.BinopExpression(
|
|
switch(((ExpressionContext)_localctx).op.getType()) {
|
|
case PLUS -> Op.PLUS;
|
|
case MINUS -> Op.MINUS;
|
|
default -> throw new IllegalArgumentException("Unknown operator");
|
|
},
|
|
((ExpressionContext)_localctx).left.out,
|
|
((ExpressionContext)_localctx).right.out
|
|
);
|
|
((ExpressionContext)_localctx).return_Type = ((ExpressionContext)_localctx).right.return_Type;
|
|
|
|
}
|
|
}
|
|
setState(50);
|
|
_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;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class Td_expressionContext extends ParserRuleContext {
|
|
public SymTable.SymTable table;
|
|
public Type return_Type;
|
|
public Expression out;
|
|
public LitContext left;
|
|
public Token op;
|
|
public LitContext right;
|
|
public List<LitContext> lit() {
|
|
return getRuleContexts(LitContext.class);
|
|
}
|
|
public LitContext lit(int i) {
|
|
return getRuleContext(LitContext.class,i);
|
|
}
|
|
public List<TerminalNode> TIMES() { return getTokens(VSLParser.TIMES); }
|
|
public TerminalNode TIMES(int i) {
|
|
return getToken(VSLParser.TIMES, i);
|
|
}
|
|
public List<TerminalNode> DIV() { return getTokens(VSLParser.DIV); }
|
|
public TerminalNode DIV(int i) {
|
|
return getToken(VSLParser.DIV, i);
|
|
}
|
|
public Td_expressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
|
|
public Td_expressionContext(ParserRuleContext parent, int invokingState, SymTable.SymTable table) {
|
|
super(parent, invokingState);
|
|
this.table = table;
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_td_expression; }
|
|
}
|
|
|
|
public final Td_expressionContext td_expression(SymTable.SymTable table) throws RecognitionException {
|
|
Td_expressionContext _localctx = new Td_expressionContext(_ctx, getState(), table);
|
|
enterRule(_localctx, 12, RULE_td_expression);
|
|
int _la;
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(51);
|
|
((Td_expressionContext)_localctx).left = lit();
|
|
|
|
((Td_expressionContext)_localctx).out = ((Td_expressionContext)_localctx).left.out;
|
|
((Td_expressionContext)_localctx).return_Type = ((Td_expressionContext)_localctx).left.return_Type;
|
|
|
|
setState(59);
|
|
_errHandler.sync(this);
|
|
_la = _input.LA(1);
|
|
while (_la==DIV || _la==TIMES) {
|
|
{
|
|
{
|
|
setState(53);
|
|
((Td_expressionContext)_localctx).op = _input.LT(1);
|
|
_la = _input.LA(1);
|
|
if ( !(_la==DIV || _la==TIMES) ) {
|
|
((Td_expressionContext)_localctx).op = (Token)_errHandler.recoverInline(this);
|
|
}
|
|
else {
|
|
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
|
|
_errHandler.reportMatch(this);
|
|
consume();
|
|
}
|
|
setState(54);
|
|
((Td_expressionContext)_localctx).right = lit();
|
|
|
|
((Td_expressionContext)_localctx).out = new Program.BinopExpression(
|
|
switch(((Td_expressionContext)_localctx).op.getType()) {
|
|
case TIMES -> Op.TIMES;
|
|
case DIV -> Op.DIV;
|
|
default -> throw new IllegalArgumentException("Unknown operator");
|
|
},
|
|
((Td_expressionContext)_localctx).left.out,
|
|
((Td_expressionContext)_localctx).right.out
|
|
);
|
|
((Td_expressionContext)_localctx).return_Type = ((Td_expressionContext)_localctx).right.return_Type;
|
|
|
|
}
|
|
}
|
|
setState(61);
|
|
_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;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class LitContext extends ParserRuleContext {
|
|
public Expression out;
|
|
public Type return_Type;
|
|
public Token NUMBER;
|
|
public TerminalNode NUMBER() { return getToken(VSLParser.NUMBER, 0); }
|
|
public LitContext(ParserRuleContext parent, int invokingState) {
|
|
super(parent, invokingState);
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_lit; }
|
|
}
|
|
|
|
public final LitContext lit() throws RecognitionException {
|
|
LitContext _localctx = new LitContext(_ctx, getState());
|
|
enterRule(_localctx, 14, RULE_lit);
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(62);
|
|
((LitContext)_localctx).NUMBER = match(NUMBER);
|
|
|
|
((LitContext)_localctx).return_Type = new Program.Type_int();
|
|
((LitContext)_localctx).out = new Program.Const((((LitContext)_localctx).NUMBER!=null?Integer.valueOf(((LitContext)_localctx).NUMBER.getText()):0));
|
|
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class IdentContext extends ParserRuleContext {
|
|
public String out;
|
|
public Token TEXT;
|
|
public TerminalNode TEXT() { return getToken(VSLParser.TEXT, 0); }
|
|
public IdentContext(ParserRuleContext parent, int invokingState) {
|
|
super(parent, invokingState);
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_ident; }
|
|
}
|
|
|
|
public final IdentContext ident() throws RecognitionException {
|
|
IdentContext _localctx = new IdentContext(_ctx, getState());
|
|
enterRule(_localctx, 16, RULE_ident);
|
|
try {
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(65);
|
|
((IdentContext)_localctx).TEXT = match(TEXT);
|
|
((IdentContext)_localctx).out = ((IdentContext)_localctx).TEXT.getText();
|
|
}
|
|
}
|
|
catch (RecognitionException re) {
|
|
_localctx.exception = re;
|
|
_errHandler.reportError(this, re);
|
|
_errHandler.recover(this, re);
|
|
}
|
|
finally {
|
|
exitRule();
|
|
}
|
|
return _localctx;
|
|
}
|
|
|
|
@SuppressWarnings("CheckReturnValue")
|
|
public static class TypeContext extends ParserRuleContext {
|
|
public Type return_type;
|
|
public TerminalNode TYPE_INT() { return getToken(VSLParser.TYPE_INT, 0); }
|
|
public TerminalNode TYPE_VOID() { return getToken(VSLParser.TYPE_VOID, 0); }
|
|
public TypeContext(ParserRuleContext parent, int invokingState) {
|
|
super(parent, invokingState);
|
|
}
|
|
@Override public int getRuleIndex() { return RULE_type; }
|
|
}
|
|
|
|
public final TypeContext type() throws RecognitionException {
|
|
TypeContext _localctx = new TypeContext(_ctx, getState());
|
|
enterRule(_localctx, 18, RULE_type);
|
|
try {
|
|
setState(72);
|
|
_errHandler.sync(this);
|
|
switch (_input.LA(1)) {
|
|
case TYPE_INT:
|
|
enterOuterAlt(_localctx, 1);
|
|
{
|
|
setState(68);
|
|
match(TYPE_INT);
|
|
((TypeContext)_localctx).return_type = new Program.Type.Type_int();
|
|
}
|
|
break;
|
|
case TYPE_VOID:
|
|
enterOuterAlt(_localctx, 2);
|
|
{
|
|
setState(70);
|
|
match(TYPE_VOID);
|
|
((TypeContext)_localctx).return_type = new Program.Type.Type_void();
|
|
}
|
|
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 final String _serializedATN =
|
|
"\u0004\u0001\u001cK\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
|
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+
|
|
"\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+
|
|
"\b\u0007\b\u0002\t\u0007\t\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+
|
|
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
|
"\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+
|
|
"\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+
|
|
"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0005\u0005/\b\u0005"+
|
|
"\n\u0005\f\u00052\t\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
|
|
"\u0001\u0006\u0001\u0006\u0005\u0006:\b\u0006\n\u0006\f\u0006=\t\u0006"+
|
|
"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\t\u0001"+
|
|
"\t\u0001\t\u0001\t\u0003\tI\b\t\u0001\t\u0000\u0000\n\u0000\u0002\u0004"+
|
|
"\u0006\b\n\f\u000e\u0010\u0012\u0000\u0002\u0001\u0000\u0017\u0018\u0001"+
|
|
"\u0000\u0019\u001aC\u0000\u0014\u0001\u0000\u0000\u0000\u0002\u0018\u0001"+
|
|
"\u0000\u0000\u0000\u0004 \u0001\u0000\u0000\u0000\u0006\"\u0001\u0000"+
|
|
"\u0000\u0000\b%\u0001\u0000\u0000\u0000\n(\u0001\u0000\u0000\u0000\f3"+
|
|
"\u0001\u0000\u0000\u0000\u000e>\u0001\u0000\u0000\u0000\u0010A\u0001\u0000"+
|
|
"\u0000\u0000\u0012H\u0001\u0000\u0000\u0000\u0014\u0015\u0003\u0002\u0001"+
|
|
"\u0000\u0015\u0016\u0005\u0000\u0000\u0001\u0016\u0017\u0006\u0000\uffff"+
|
|
"\uffff\u0000\u0017\u0001\u0001\u0000\u0000\u0000\u0018\u0019\u0005\u0001"+
|
|
"\u0000\u0000\u0019\u001a\u0003\u0012\t\u0000\u001a\u001b\u0003\u0010\b"+
|
|
"\u0000\u001b\u001c\u0005\u0015\u0000\u0000\u001c\u001d\u0005\u0016\u0000"+
|
|
"\u0000\u001d\u001e\u0003\u0006\u0003\u0000\u001e\u001f\u0006\u0001\uffff"+
|
|
"\uffff\u0000\u001f\u0003\u0001\u0000\u0000\u0000 !\u0001\u0000\u0000\u0000"+
|
|
"!\u0005\u0001\u0000\u0000\u0000\"#\u0003\b\u0004\u0000#$\u0006\u0003\uffff"+
|
|
"\uffff\u0000$\u0007\u0001\u0000\u0000\u0000%&\u0005\u0012\u0000\u0000"+
|
|
"&\'\u0003\n\u0005\u0000\'\t\u0001\u0000\u0000\u0000()\u0003\f\u0006\u0000"+
|
|
")0\u0006\u0005\uffff\uffff\u0000*+\u0007\u0000\u0000\u0000+,\u0003\f\u0006"+
|
|
"\u0000,-\u0006\u0005\uffff\uffff\u0000-/\u0001\u0000\u0000\u0000.*\u0001"+
|
|
"\u0000\u0000\u0000/2\u0001\u0000\u0000\u00000.\u0001\u0000\u0000\u0000"+
|
|
"01\u0001\u0000\u0000\u00001\u000b\u0001\u0000\u0000\u000020\u0001\u0000"+
|
|
"\u0000\u000034\u0003\u000e\u0007\u00004;\u0006\u0006\uffff\uffff\u0000"+
|
|
"56\u0007\u0001\u0000\u000067\u0003\u000e\u0007\u000078\u0006\u0006\uffff"+
|
|
"\uffff\u00008:\u0001\u0000\u0000\u000095\u0001\u0000\u0000\u0000:=\u0001"+
|
|
"\u0000\u0000\u0000;9\u0001\u0000\u0000\u0000;<\u0001\u0000\u0000\u0000"+
|
|
"<\r\u0001\u0000\u0000\u0000=;\u0001\u0000\u0000\u0000>?\u0005\u0014\u0000"+
|
|
"\u0000?@\u0006\u0007\uffff\uffff\u0000@\u000f\u0001\u0000\u0000\u0000"+
|
|
"AB\u0005\u0013\u0000\u0000BC\u0006\b\uffff\uffff\u0000C\u0011\u0001\u0000"+
|
|
"\u0000\u0000DE\u0005\u0003\u0000\u0000EI\u0006\t\uffff\uffff\u0000FG\u0005"+
|
|
"\u0004\u0000\u0000GI\u0006\t\uffff\uffff\u0000HD\u0001\u0000\u0000\u0000"+
|
|
"HF\u0001\u0000\u0000\u0000I\u0013\u0001\u0000\u0000\u0000\u00030;H";
|
|
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);
|
|
}
|
|
}
|
|
} |