From 94709c14303597afe2f2cfe738530ecb590e852f Mon Sep 17 00:00:00 2001 From: User <> Date: Wed, 26 Apr 2017 15:55:18 +0200 Subject: [PATCH] basic language --- src/pp/s1184725/boppi/Basic.g4 | 75 ++ src/pp/s1184725/boppi/Basic.tokens | 78 ++ src/pp/s1184725/boppi/BasicBaseVisitor.java | 168 +++ src/pp/s1184725/boppi/BasicLexer.java | 201 ++++ src/pp/s1184725/boppi/BasicLexer.tokens | 78 ++ src/pp/s1184725/boppi/BasicParser.java | 1020 +++++++++++++++++++ src/pp/s1184725/boppi/BasicVisitor.java | 164 +++ 7 files changed, 1784 insertions(+) create mode 100644 src/pp/s1184725/boppi/Basic.g4 create mode 100644 src/pp/s1184725/boppi/Basic.tokens create mode 100644 src/pp/s1184725/boppi/BasicBaseVisitor.java create mode 100644 src/pp/s1184725/boppi/BasicLexer.java create mode 100644 src/pp/s1184725/boppi/BasicLexer.tokens create mode 100644 src/pp/s1184725/boppi/BasicParser.java create mode 100644 src/pp/s1184725/boppi/BasicVisitor.java diff --git a/src/pp/s1184725/boppi/Basic.g4 b/src/pp/s1184725/boppi/Basic.g4 new file mode 100644 index 0000000..118f08b --- /dev/null +++ b/src/pp/s1184725/boppi/Basic.g4 @@ -0,0 +1,75 @@ +grammar Basic; + +program: expr; + +expr + : PAROPEN expr PARCLOSE #parens + | BRAOPEN expr BRACLOSE #block + | IN PAROPEN variable (LISTDELIM variable)* PARCLOSE #read + | OUT PAROPEN expr (LISTDELIM expr)* PARCLOSE #write + | IFOPEN cond=expr IFTRUE onTrue=expr (IFFALSE onFalse=expr)? IFCLOSE #if + | WHILEOPEN cond=expr WHILETRUE onTrue=expr WHILECLOSE #while + | op=(PLUS|MINUS|NOT) expr #prefix1 + | lhs=expr op=(MULTIPLY|DIVIDE|MODULO) rhs=expr #infix1 + | lhs=expr op=(PLUS|MINUS) rhs=expr #infix2 + | lhs=expr op=(LT|LEQ|GTE|GT|EQ|NEQ) rhs=expr #infix3 + | lhs=expr AND rhs=expr #infix4 + | lhs=expr OR rhs=expr #infix5 + | DECLARE type IDENTIFIER #declare + | variable ASSIGN expr #assign + | expr (COMPOUND expr?)+ #compound + | variable #var + | LITERAL10 #number + | CHAR #char + | (TRUE|FALSE) #bool + ; + +type: staticType=(INTTYPE | BOOLTYPE | CHARTYPE) | variable; +variable: IDENTIFIER; + +PAROPEN: '('; +PARCLOSE: ')'; +BRAOPEN: '{'; +BRACLOSE: '}'; +IN: 'read'; +OUT: 'print'; +IFOPEN: 'if'; +IFTRUE: 'then'; +IFFALSE: 'else'; +IFCLOSE: 'fi'; +WHILEOPEN: 'while'; +WHILETRUE: 'do'; +WHILECLOSE: 'od'; + +PLUS: '+'; +MINUS: '-'; +NOT: '!'; +MULTIPLY: '*'; +DIVIDE: '/'; +MODULO: '%'; +LEQ: '<='; +GTE: '>='; +NEQ: '<>'; +EQ: '=='; +LT: '<'; +GT: '>'; +AND: '&&'; +OR: '||'; + +DECLARE: 'var'; +INTTYPE: 'int'; +BOOLTYPE: 'bool'; +CHARTYPE: 'char'; +ASSIGN: ':='; +COMPOUND: ';'; +LISTDELIM: ','; + +CHAR: '\'' . '\''; +TRUE: 'true'; +FALSE: 'false'; +IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*; +LITERAL10: ('0' | [1-9] [0-9]*); + +WHITESPACE: [\t\r\n ] -> skip; +LINECOMMENT: '//' ~[\r\n]* -> skip; +BLOCKCOMMENT: '/*' .*? '*/' -> skip; diff --git a/src/pp/s1184725/boppi/Basic.tokens b/src/pp/s1184725/boppi/Basic.tokens new file mode 100644 index 0000000..5686c68 --- /dev/null +++ b/src/pp/s1184725/boppi/Basic.tokens @@ -0,0 +1,78 @@ +PAROPEN=1 +PARCLOSE=2 +BRAOPEN=3 +BRACLOSE=4 +IN=5 +OUT=6 +IFOPEN=7 +IFTRUE=8 +IFFALSE=9 +IFCLOSE=10 +WHILEOPEN=11 +WHILETRUE=12 +WHILECLOSE=13 +PLUS=14 +MINUS=15 +NOT=16 +MULTIPLY=17 +DIVIDE=18 +MODULO=19 +LEQ=20 +GTE=21 +NEQ=22 +EQ=23 +LT=24 +GT=25 +AND=26 +OR=27 +DECLARE=28 +INTTYPE=29 +BOOLTYPE=30 +CHARTYPE=31 +ASSIGN=32 +COMPOUND=33 +LISTDELIM=34 +CHAR=35 +TRUE=36 +FALSE=37 +IDENTIFIER=38 +LITERAL10=39 +WHITESPACE=40 +LINECOMMENT=41 +BLOCKCOMMENT=42 +'('=1 +')'=2 +'{'=3 +'}'=4 +'read'=5 +'print'=6 +'if'=7 +'then'=8 +'else'=9 +'fi'=10 +'while'=11 +'do'=12 +'od'=13 +'+'=14 +'-'=15 +'!'=16 +'*'=17 +'/'=18 +'%'=19 +'<='=20 +'>='=21 +'<>'=22 +'=='=23 +'<'=24 +'>'=25 +'&&'=26 +'||'=27 +'var'=28 +'int'=29 +'bool'=30 +'char'=31 +':='=32 +';'=33 +','=34 +'true'=36 +'false'=37 diff --git a/src/pp/s1184725/boppi/BasicBaseVisitor.java b/src/pp/s1184725/boppi/BasicBaseVisitor.java new file mode 100644 index 0000000..d109159 --- /dev/null +++ b/src/pp/s1184725/boppi/BasicBaseVisitor.java @@ -0,0 +1,168 @@ +// Generated from Basic.g4 by ANTLR 4.7 +package pp.s1184725.boppi; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link BasicVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public class BasicBaseVisitor extends AbstractParseTreeVisitor implements BasicVisitor { + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitProgram(BasicParser.ProgramContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitParens(BasicParser.ParensContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitRead(BasicParser.ReadContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDeclare(BasicParser.DeclareContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBool(BasicParser.BoolContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVar(BasicParser.VarContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix2(BasicParser.Infix2Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix3(BasicParser.Infix3Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix1(BasicParser.Infix1Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitWhile(BasicParser.WhileContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCompound(BasicParser.CompoundContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix4(BasicParser.Infix4Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix5(BasicParser.Infix5Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitNumber(BasicParser.NumberContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitChar(BasicParser.CharContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBlock(BasicParser.BlockContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitWrite(BasicParser.WriteContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIf(BasicParser.IfContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrefix1(BasicParser.Prefix1Context ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitAssign(BasicParser.AssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitType(BasicParser.TypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVariable(BasicParser.VariableContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/pp/s1184725/boppi/BasicLexer.java b/src/pp/s1184725/boppi/BasicLexer.java new file mode 100644 index 0000000..1874d4c --- /dev/null +++ b/src/pp/s1184725/boppi/BasicLexer.java @@ -0,0 +1,201 @@ +// Generated from Basic.g4 by ANTLR 4.7 +package pp.s1184725.boppi; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class BasicLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + PAROPEN=1, PARCLOSE=2, BRAOPEN=3, BRACLOSE=4, IN=5, OUT=6, IFOPEN=7, IFTRUE=8, + IFFALSE=9, IFCLOSE=10, WHILEOPEN=11, WHILETRUE=12, WHILECLOSE=13, PLUS=14, + MINUS=15, NOT=16, MULTIPLY=17, DIVIDE=18, MODULO=19, LEQ=20, GTE=21, NEQ=22, + EQ=23, LT=24, GT=25, AND=26, OR=27, DECLARE=28, INTTYPE=29, BOOLTYPE=30, + CHARTYPE=31, ASSIGN=32, COMPOUND=33, LISTDELIM=34, CHAR=35, TRUE=36, FALSE=37, + IDENTIFIER=38, LITERAL10=39, WHITESPACE=40, LINECOMMENT=41, BLOCKCOMMENT=42; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "PAROPEN", "PARCLOSE", "BRAOPEN", "BRACLOSE", "IN", "OUT", "IFOPEN", "IFTRUE", + "IFFALSE", "IFCLOSE", "WHILEOPEN", "WHILETRUE", "WHILECLOSE", "PLUS", + "MINUS", "NOT", "MULTIPLY", "DIVIDE", "MODULO", "LEQ", "GTE", "NEQ", "EQ", + "LT", "GT", "AND", "OR", "DECLARE", "INTTYPE", "BOOLTYPE", "CHARTYPE", + "ASSIGN", "COMPOUND", "LISTDELIM", "CHAR", "TRUE", "FALSE", "IDENTIFIER", + "LITERAL10", "WHITESPACE", "LINECOMMENT", "BLOCKCOMMENT" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'('", "')'", "'{'", "'}'", "'read'", "'print'", "'if'", "'then'", + "'else'", "'fi'", "'while'", "'do'", "'od'", "'+'", "'-'", "'!'", "'*'", + "'/'", "'%'", "'<='", "'>='", "'<>'", "'=='", "'<'", "'>'", "'&&'", "'||'", + "'var'", "'int'", "'bool'", "'char'", "':='", "';'", "','", null, "'true'", + "'false'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "PAROPEN", "PARCLOSE", "BRAOPEN", "BRACLOSE", "IN", "OUT", "IFOPEN", + "IFTRUE", "IFFALSE", "IFCLOSE", "WHILEOPEN", "WHILETRUE", "WHILECLOSE", + "PLUS", "MINUS", "NOT", "MULTIPLY", "DIVIDE", "MODULO", "LEQ", "GTE", + "NEQ", "EQ", "LT", "GT", "AND", "OR", "DECLARE", "INTTYPE", "BOOLTYPE", + "CHARTYPE", "ASSIGN", "COMPOUND", "LISTDELIM", "CHAR", "TRUE", "FALSE", + "IDENTIFIER", "LITERAL10", "WHITESPACE", "LINECOMMENT", "BLOCKCOMMENT" + }; + 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] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public BasicLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Basic.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2,\u00fe\b\1\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\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\3"+ + "\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7"+ + "\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13"+ + "\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3\20\3\20"+ + "\3\21\3\21\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26"+ + "\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\32\3\32\3\33\3\33\3\33\3\34"+ + "\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37"+ + "\3\37\3 \3 \3 \3 \3 \3!\3!\3!\3\"\3\"\3#\3#\3$\3$\3$\3$\3%\3%\3%\3%\3"+ + "%\3&\3&\3&\3&\3&\3&\3\'\3\'\7\'\u00d3\n\'\f\'\16\'\u00d6\13\'\3(\3(\3"+ + "(\7(\u00db\n(\f(\16(\u00de\13(\5(\u00e0\n(\3)\3)\3)\3)\3*\3*\3*\3*\7*"+ + "\u00ea\n*\f*\16*\u00ed\13*\3*\3*\3+\3+\3+\3+\7+\u00f5\n+\f+\16+\u00f8"+ + "\13+\3+\3+\3+\3+\3+\3\u00f6\2,\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13"+ + "\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61"+ + "\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,\3\2\b\5\2C\\"+ + "aac|\6\2\62;C\\aac|\3\2\63;\3\2\62;\5\2\13\f\17\17\"\"\4\2\f\f\17\17\2"+ + "\u0102\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2"+ + "\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3"+ + "\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2"+ + "\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2"+ + "/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2"+ + "\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2"+ + "G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3"+ + "\2\2\2\2U\3\2\2\2\3W\3\2\2\2\5Y\3\2\2\2\7[\3\2\2\2\t]\3\2\2\2\13_\3\2"+ + "\2\2\rd\3\2\2\2\17j\3\2\2\2\21m\3\2\2\2\23r\3\2\2\2\25w\3\2\2\2\27z\3"+ + "\2\2\2\31\u0080\3\2\2\2\33\u0083\3\2\2\2\35\u0086\3\2\2\2\37\u0088\3\2"+ + "\2\2!\u008a\3\2\2\2#\u008c\3\2\2\2%\u008e\3\2\2\2\'\u0090\3\2\2\2)\u0092"+ + "\3\2\2\2+\u0095\3\2\2\2-\u0098\3\2\2\2/\u009b\3\2\2\2\61\u009e\3\2\2\2"+ + "\63\u00a0\3\2\2\2\65\u00a2\3\2\2\2\67\u00a5\3\2\2\29\u00a8\3\2\2\2;\u00ac"+ + "\3\2\2\2=\u00b0\3\2\2\2?\u00b5\3\2\2\2A\u00ba\3\2\2\2C\u00bd\3\2\2\2E"+ + "\u00bf\3\2\2\2G\u00c1\3\2\2\2I\u00c5\3\2\2\2K\u00ca\3\2\2\2M\u00d0\3\2"+ + "\2\2O\u00df\3\2\2\2Q\u00e1\3\2\2\2S\u00e5\3\2\2\2U\u00f0\3\2\2\2WX\7*"+ + "\2\2X\4\3\2\2\2YZ\7+\2\2Z\6\3\2\2\2[\\\7}\2\2\\\b\3\2\2\2]^\7\177\2\2"+ + "^\n\3\2\2\2_`\7t\2\2`a\7g\2\2ab\7c\2\2bc\7f\2\2c\f\3\2\2\2de\7r\2\2ef"+ + "\7t\2\2fg\7k\2\2gh\7p\2\2hi\7v\2\2i\16\3\2\2\2jk\7k\2\2kl\7h\2\2l\20\3"+ + "\2\2\2mn\7v\2\2no\7j\2\2op\7g\2\2pq\7p\2\2q\22\3\2\2\2rs\7g\2\2st\7n\2"+ + "\2tu\7u\2\2uv\7g\2\2v\24\3\2\2\2wx\7h\2\2xy\7k\2\2y\26\3\2\2\2z{\7y\2"+ + "\2{|\7j\2\2|}\7k\2\2}~\7n\2\2~\177\7g\2\2\177\30\3\2\2\2\u0080\u0081\7"+ + "f\2\2\u0081\u0082\7q\2\2\u0082\32\3\2\2\2\u0083\u0084\7q\2\2\u0084\u0085"+ + "\7f\2\2\u0085\34\3\2\2\2\u0086\u0087\7-\2\2\u0087\36\3\2\2\2\u0088\u0089"+ + "\7/\2\2\u0089 \3\2\2\2\u008a\u008b\7#\2\2\u008b\"\3\2\2\2\u008c\u008d"+ + "\7,\2\2\u008d$\3\2\2\2\u008e\u008f\7\61\2\2\u008f&\3\2\2\2\u0090\u0091"+ + "\7\'\2\2\u0091(\3\2\2\2\u0092\u0093\7>\2\2\u0093\u0094\7?\2\2\u0094*\3"+ + "\2\2\2\u0095\u0096\7@\2\2\u0096\u0097\7?\2\2\u0097,\3\2\2\2\u0098\u0099"+ + "\7>\2\2\u0099\u009a\7@\2\2\u009a.\3\2\2\2\u009b\u009c\7?\2\2\u009c\u009d"+ + "\7?\2\2\u009d\60\3\2\2\2\u009e\u009f\7>\2\2\u009f\62\3\2\2\2\u00a0\u00a1"+ + "\7@\2\2\u00a1\64\3\2\2\2\u00a2\u00a3\7(\2\2\u00a3\u00a4\7(\2\2\u00a4\66"+ + "\3\2\2\2\u00a5\u00a6\7~\2\2\u00a6\u00a7\7~\2\2\u00a78\3\2\2\2\u00a8\u00a9"+ + "\7x\2\2\u00a9\u00aa\7c\2\2\u00aa\u00ab\7t\2\2\u00ab:\3\2\2\2\u00ac\u00ad"+ + "\7k\2\2\u00ad\u00ae\7p\2\2\u00ae\u00af\7v\2\2\u00af<\3\2\2\2\u00b0\u00b1"+ + "\7d\2\2\u00b1\u00b2\7q\2\2\u00b2\u00b3\7q\2\2\u00b3\u00b4\7n\2\2\u00b4"+ + ">\3\2\2\2\u00b5\u00b6\7e\2\2\u00b6\u00b7\7j\2\2\u00b7\u00b8\7c\2\2\u00b8"+ + "\u00b9\7t\2\2\u00b9@\3\2\2\2\u00ba\u00bb\7<\2\2\u00bb\u00bc\7?\2\2\u00bc"+ + "B\3\2\2\2\u00bd\u00be\7=\2\2\u00beD\3\2\2\2\u00bf\u00c0\7.\2\2\u00c0F"+ + "\3\2\2\2\u00c1\u00c2\7)\2\2\u00c2\u00c3\13\2\2\2\u00c3\u00c4\7)\2\2\u00c4"+ + "H\3\2\2\2\u00c5\u00c6\7v\2\2\u00c6\u00c7\7t\2\2\u00c7\u00c8\7w\2\2\u00c8"+ + "\u00c9\7g\2\2\u00c9J\3\2\2\2\u00ca\u00cb\7h\2\2\u00cb\u00cc\7c\2\2\u00cc"+ + "\u00cd\7n\2\2\u00cd\u00ce\7u\2\2\u00ce\u00cf\7g\2\2\u00cfL\3\2\2\2\u00d0"+ + "\u00d4\t\2\2\2\u00d1\u00d3\t\3\2\2\u00d2\u00d1\3\2\2\2\u00d3\u00d6\3\2"+ + "\2\2\u00d4\u00d2\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5N\3\2\2\2\u00d6\u00d4"+ + "\3\2\2\2\u00d7\u00e0\7\62\2\2\u00d8\u00dc\t\4\2\2\u00d9\u00db\t\5\2\2"+ + "\u00da\u00d9\3\2\2\2\u00db\u00de\3\2\2\2\u00dc\u00da\3\2\2\2\u00dc\u00dd"+ + "\3\2\2\2\u00dd\u00e0\3\2\2\2\u00de\u00dc\3\2\2\2\u00df\u00d7\3\2\2\2\u00df"+ + "\u00d8\3\2\2\2\u00e0P\3\2\2\2\u00e1\u00e2\t\6\2\2\u00e2\u00e3\3\2\2\2"+ + "\u00e3\u00e4\b)\2\2\u00e4R\3\2\2\2\u00e5\u00e6\7\61\2\2\u00e6\u00e7\7"+ + "\61\2\2\u00e7\u00eb\3\2\2\2\u00e8\u00ea\n\7\2\2\u00e9\u00e8\3\2\2\2\u00ea"+ + "\u00ed\3\2\2\2\u00eb\u00e9\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\u00ee\3\2"+ + "\2\2\u00ed\u00eb\3\2\2\2\u00ee\u00ef\b*\2\2\u00efT\3\2\2\2\u00f0\u00f1"+ + "\7\61\2\2\u00f1\u00f2\7,\2\2\u00f2\u00f6\3\2\2\2\u00f3\u00f5\13\2\2\2"+ + "\u00f4\u00f3\3\2\2\2\u00f5\u00f8\3\2\2\2\u00f6\u00f7\3\2\2\2\u00f6\u00f4"+ + "\3\2\2\2\u00f7\u00f9\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f9\u00fa\7,\2\2\u00fa"+ + "\u00fb\7\61\2\2\u00fb\u00fc\3\2\2\2\u00fc\u00fd\b+\2\2\u00fdV\3\2\2\2"+ + "\b\2\u00d4\u00dc\u00df\u00eb\u00f6\3\b\2\2"; + 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); + } + } +} \ No newline at end of file diff --git a/src/pp/s1184725/boppi/BasicLexer.tokens b/src/pp/s1184725/boppi/BasicLexer.tokens new file mode 100644 index 0000000..5686c68 --- /dev/null +++ b/src/pp/s1184725/boppi/BasicLexer.tokens @@ -0,0 +1,78 @@ +PAROPEN=1 +PARCLOSE=2 +BRAOPEN=3 +BRACLOSE=4 +IN=5 +OUT=6 +IFOPEN=7 +IFTRUE=8 +IFFALSE=9 +IFCLOSE=10 +WHILEOPEN=11 +WHILETRUE=12 +WHILECLOSE=13 +PLUS=14 +MINUS=15 +NOT=16 +MULTIPLY=17 +DIVIDE=18 +MODULO=19 +LEQ=20 +GTE=21 +NEQ=22 +EQ=23 +LT=24 +GT=25 +AND=26 +OR=27 +DECLARE=28 +INTTYPE=29 +BOOLTYPE=30 +CHARTYPE=31 +ASSIGN=32 +COMPOUND=33 +LISTDELIM=34 +CHAR=35 +TRUE=36 +FALSE=37 +IDENTIFIER=38 +LITERAL10=39 +WHITESPACE=40 +LINECOMMENT=41 +BLOCKCOMMENT=42 +'('=1 +')'=2 +'{'=3 +'}'=4 +'read'=5 +'print'=6 +'if'=7 +'then'=8 +'else'=9 +'fi'=10 +'while'=11 +'do'=12 +'od'=13 +'+'=14 +'-'=15 +'!'=16 +'*'=17 +'/'=18 +'%'=19 +'<='=20 +'>='=21 +'<>'=22 +'=='=23 +'<'=24 +'>'=25 +'&&'=26 +'||'=27 +'var'=28 +'int'=29 +'bool'=30 +'char'=31 +':='=32 +';'=33 +','=34 +'true'=36 +'false'=37 diff --git a/src/pp/s1184725/boppi/BasicParser.java b/src/pp/s1184725/boppi/BasicParser.java new file mode 100644 index 0000000..7d57337 --- /dev/null +++ b/src/pp/s1184725/boppi/BasicParser.java @@ -0,0 +1,1020 @@ +// Generated from Basic.g4 by ANTLR 4.7 +package pp.s1184725.boppi; +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 BasicParser extends Parser { + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + PAROPEN=1, PARCLOSE=2, BRAOPEN=3, BRACLOSE=4, IN=5, OUT=6, IFOPEN=7, IFTRUE=8, + IFFALSE=9, IFCLOSE=10, WHILEOPEN=11, WHILETRUE=12, WHILECLOSE=13, PLUS=14, + MINUS=15, NOT=16, MULTIPLY=17, DIVIDE=18, MODULO=19, LEQ=20, GTE=21, NEQ=22, + EQ=23, LT=24, GT=25, AND=26, OR=27, DECLARE=28, INTTYPE=29, BOOLTYPE=30, + CHARTYPE=31, ASSIGN=32, COMPOUND=33, LISTDELIM=34, CHAR=35, TRUE=36, FALSE=37, + IDENTIFIER=38, LITERAL10=39, WHITESPACE=40, LINECOMMENT=41, BLOCKCOMMENT=42; + public static final int + RULE_program = 0, RULE_expr = 1, RULE_type = 2, RULE_variable = 3; + public static final String[] ruleNames = { + "program", "expr", "type", "variable" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'('", "')'", "'{'", "'}'", "'read'", "'print'", "'if'", "'then'", + "'else'", "'fi'", "'while'", "'do'", "'od'", "'+'", "'-'", "'!'", "'*'", + "'/'", "'%'", "'<='", "'>='", "'<>'", "'=='", "'<'", "'>'", "'&&'", "'||'", + "'var'", "'int'", "'bool'", "'char'", "':='", "';'", "','", null, "'true'", + "'false'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "PAROPEN", "PARCLOSE", "BRAOPEN", "BRACLOSE", "IN", "OUT", "IFOPEN", + "IFTRUE", "IFFALSE", "IFCLOSE", "WHILEOPEN", "WHILETRUE", "WHILECLOSE", + "PLUS", "MINUS", "NOT", "MULTIPLY", "DIVIDE", "MODULO", "LEQ", "GTE", + "NEQ", "EQ", "LT", "GT", "AND", "OR", "DECLARE", "INTTYPE", "BOOLTYPE", + "CHARTYPE", "ASSIGN", "COMPOUND", "LISTDELIM", "CHAR", "TRUE", "FALSE", + "IDENTIFIER", "LITERAL10", "WHITESPACE", "LINECOMMENT", "BLOCKCOMMENT" + }; + 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] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "Basic.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public BasicParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + public static class ProgramContext extends ParserRuleContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public ProgramContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_program; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitProgram(this); + else return visitor.visitChildren(this); + } + } + + public final ProgramContext program() throws RecognitionException { + ProgramContext _localctx = new ProgramContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_program); + try { + enterOuterAlt(_localctx, 1); + { + setState(8); + expr(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ExprContext extends ParserRuleContext { + public ExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expr; } + + public ExprContext() { } + public void copyFrom(ExprContext ctx) { + super.copyFrom(ctx); + } + } + public static class ParensContext extends ExprContext { + public TerminalNode PAROPEN() { return getToken(BasicParser.PAROPEN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode PARCLOSE() { return getToken(BasicParser.PARCLOSE, 0); } + public ParensContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitParens(this); + else return visitor.visitChildren(this); + } + } + public static class ReadContext extends ExprContext { + public TerminalNode IN() { return getToken(BasicParser.IN, 0); } + public TerminalNode PAROPEN() { return getToken(BasicParser.PAROPEN, 0); } + public List variable() { + return getRuleContexts(VariableContext.class); + } + public VariableContext variable(int i) { + return getRuleContext(VariableContext.class,i); + } + public TerminalNode PARCLOSE() { return getToken(BasicParser.PARCLOSE, 0); } + public List LISTDELIM() { return getTokens(BasicParser.LISTDELIM); } + public TerminalNode LISTDELIM(int i) { + return getToken(BasicParser.LISTDELIM, i); + } + public ReadContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitRead(this); + else return visitor.visitChildren(this); + } + } + public static class DeclareContext extends ExprContext { + public TerminalNode DECLARE() { return getToken(BasicParser.DECLARE, 0); } + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public TerminalNode IDENTIFIER() { return getToken(BasicParser.IDENTIFIER, 0); } + public DeclareContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitDeclare(this); + else return visitor.visitChildren(this); + } + } + public static class BoolContext extends ExprContext { + public TerminalNode TRUE() { return getToken(BasicParser.TRUE, 0); } + public TerminalNode FALSE() { return getToken(BasicParser.FALSE, 0); } + public BoolContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitBool(this); + else return visitor.visitChildren(this); + } + } + public static class VarContext extends ExprContext { + public VariableContext variable() { + return getRuleContext(VariableContext.class,0); + } + public VarContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitVar(this); + else return visitor.visitChildren(this); + } + } + public static class Infix2Context extends ExprContext { + public ExprContext lhs; + public Token op; + public ExprContext rhs; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode PLUS() { return getToken(BasicParser.PLUS, 0); } + public TerminalNode MINUS() { return getToken(BasicParser.MINUS, 0); } + public Infix2Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitInfix2(this); + else return visitor.visitChildren(this); + } + } + public static class Infix3Context extends ExprContext { + public ExprContext lhs; + public Token op; + public ExprContext rhs; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode LT() { return getToken(BasicParser.LT, 0); } + public TerminalNode LEQ() { return getToken(BasicParser.LEQ, 0); } + public TerminalNode GTE() { return getToken(BasicParser.GTE, 0); } + public TerminalNode GT() { return getToken(BasicParser.GT, 0); } + public TerminalNode EQ() { return getToken(BasicParser.EQ, 0); } + public TerminalNode NEQ() { return getToken(BasicParser.NEQ, 0); } + public Infix3Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitInfix3(this); + else return visitor.visitChildren(this); + } + } + public static class Infix1Context extends ExprContext { + public ExprContext lhs; + public Token op; + public ExprContext rhs; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode MULTIPLY() { return getToken(BasicParser.MULTIPLY, 0); } + public TerminalNode DIVIDE() { return getToken(BasicParser.DIVIDE, 0); } + public TerminalNode MODULO() { return getToken(BasicParser.MODULO, 0); } + public Infix1Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitInfix1(this); + else return visitor.visitChildren(this); + } + } + public static class WhileContext extends ExprContext { + public ExprContext cond; + public ExprContext onTrue; + public TerminalNode WHILEOPEN() { return getToken(BasicParser.WHILEOPEN, 0); } + public TerminalNode WHILETRUE() { return getToken(BasicParser.WHILETRUE, 0); } + public TerminalNode WHILECLOSE() { return getToken(BasicParser.WHILECLOSE, 0); } + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public WhileContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitWhile(this); + else return visitor.visitChildren(this); + } + } + public static class CompoundContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public List COMPOUND() { return getTokens(BasicParser.COMPOUND); } + public TerminalNode COMPOUND(int i) { + return getToken(BasicParser.COMPOUND, i); + } + public CompoundContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitCompound(this); + else return visitor.visitChildren(this); + } + } + public static class Infix4Context extends ExprContext { + public ExprContext lhs; + public ExprContext rhs; + public TerminalNode AND() { return getToken(BasicParser.AND, 0); } + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public Infix4Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitInfix4(this); + else return visitor.visitChildren(this); + } + } + public static class Infix5Context extends ExprContext { + public ExprContext lhs; + public ExprContext rhs; + public TerminalNode OR() { return getToken(BasicParser.OR, 0); } + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public Infix5Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitInfix5(this); + else return visitor.visitChildren(this); + } + } + public static class NumberContext extends ExprContext { + public TerminalNode LITERAL10() { return getToken(BasicParser.LITERAL10, 0); } + public NumberContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitNumber(this); + else return visitor.visitChildren(this); + } + } + public static class CharContext extends ExprContext { + public TerminalNode CHAR() { return getToken(BasicParser.CHAR, 0); } + public CharContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitChar(this); + else return visitor.visitChildren(this); + } + } + public static class BlockContext extends ExprContext { + public TerminalNode BRAOPEN() { return getToken(BasicParser.BRAOPEN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode BRACLOSE() { return getToken(BasicParser.BRACLOSE, 0); } + public BlockContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitBlock(this); + else return visitor.visitChildren(this); + } + } + public static class WriteContext extends ExprContext { + public TerminalNode OUT() { return getToken(BasicParser.OUT, 0); } + public TerminalNode PAROPEN() { return getToken(BasicParser.PAROPEN, 0); } + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode PARCLOSE() { return getToken(BasicParser.PARCLOSE, 0); } + public List LISTDELIM() { return getTokens(BasicParser.LISTDELIM); } + public TerminalNode LISTDELIM(int i) { + return getToken(BasicParser.LISTDELIM, i); + } + public WriteContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitWrite(this); + else return visitor.visitChildren(this); + } + } + public static class IfContext extends ExprContext { + public ExprContext cond; + public ExprContext onTrue; + public ExprContext onFalse; + public TerminalNode IFOPEN() { return getToken(BasicParser.IFOPEN, 0); } + public TerminalNode IFTRUE() { return getToken(BasicParser.IFTRUE, 0); } + public TerminalNode IFCLOSE() { return getToken(BasicParser.IFCLOSE, 0); } + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode IFFALSE() { return getToken(BasicParser.IFFALSE, 0); } + public IfContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitIf(this); + else return visitor.visitChildren(this); + } + } + public static class Prefix1Context extends ExprContext { + public Token op; + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode PLUS() { return getToken(BasicParser.PLUS, 0); } + public TerminalNode MINUS() { return getToken(BasicParser.MINUS, 0); } + public TerminalNode NOT() { return getToken(BasicParser.NOT, 0); } + public Prefix1Context(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitPrefix1(this); + else return visitor.visitChildren(this); + } + } + public static class AssignContext extends ExprContext { + public VariableContext variable() { + return getRuleContext(VariableContext.class,0); + } + public TerminalNode ASSIGN() { return getToken(BasicParser.ASSIGN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public AssignContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + + public final ExprContext expr() throws RecognitionException { + return expr(0); + } + + private ExprContext expr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExprContext _localctx = new ExprContext(_ctx, _parentState); + ExprContext _prevctx = _localctx; + int _startState = 2; + enterRecursionRule(_localctx, 2, RULE_expr, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(73); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + { + _localctx = new ParensContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(11); + match(PAROPEN); + setState(12); + expr(0); + setState(13); + match(PARCLOSE); + } + break; + case 2: + { + _localctx = new BlockContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(15); + match(BRAOPEN); + setState(16); + expr(0); + setState(17); + match(BRACLOSE); + } + break; + case 3: + { + _localctx = new ReadContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(19); + match(IN); + setState(20); + match(PAROPEN); + setState(21); + variable(); + setState(26); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==LISTDELIM) { + { + { + setState(22); + match(LISTDELIM); + setState(23); + variable(); + } + } + setState(28); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(29); + match(PARCLOSE); + } + break; + case 4: + { + _localctx = new WriteContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(31); + match(OUT); + setState(32); + match(PAROPEN); + setState(33); + expr(0); + setState(38); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==LISTDELIM) { + { + { + setState(34); + match(LISTDELIM); + setState(35); + expr(0); + } + } + setState(40); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(41); + match(PARCLOSE); + } + break; + case 5: + { + _localctx = new IfContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(43); + match(IFOPEN); + setState(44); + ((IfContext)_localctx).cond = expr(0); + setState(45); + match(IFTRUE); + setState(46); + ((IfContext)_localctx).onTrue = expr(0); + setState(49); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==IFFALSE) { + { + setState(47); + match(IFFALSE); + setState(48); + ((IfContext)_localctx).onFalse = expr(0); + } + } + + setState(51); + match(IFCLOSE); + } + break; + case 6: + { + _localctx = new WhileContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(53); + match(WHILEOPEN); + setState(54); + ((WhileContext)_localctx).cond = expr(0); + setState(55); + match(WHILETRUE); + setState(56); + ((WhileContext)_localctx).onTrue = expr(0); + setState(57); + match(WHILECLOSE); + } + break; + case 7: + { + _localctx = new Prefix1Context(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(59); + ((Prefix1Context)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PLUS) | (1L << MINUS) | (1L << NOT))) != 0)) ) { + ((Prefix1Context)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(60); + expr(13); + } + break; + case 8: + { + _localctx = new DeclareContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(61); + match(DECLARE); + setState(62); + type(); + setState(63); + match(IDENTIFIER); + } + break; + case 9: + { + _localctx = new AssignContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(65); + variable(); + setState(66); + match(ASSIGN); + setState(67); + expr(6); + } + break; + case 10: + { + _localctx = new VarContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(69); + variable(); + } + break; + case 11: + { + _localctx = new NumberContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(70); + match(LITERAL10); + } + break; + case 12: + { + _localctx = new CharContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(71); + match(CHAR); + } + break; + case 13: + { + _localctx = new BoolContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(72); + _la = _input.LA(1); + if ( !(_la==TRUE || _la==FALSE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + break; + } + _ctx.stop = _input.LT(-1); + setState(101); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(99); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { + case 1: + { + _localctx = new Infix1Context(new ExprContext(_parentctx, _parentState)); + ((Infix1Context)_localctx).lhs = _prevctx; + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(75); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(76); + ((Infix1Context)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MULTIPLY) | (1L << DIVIDE) | (1L << MODULO))) != 0)) ) { + ((Infix1Context)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(77); + ((Infix1Context)_localctx).rhs = expr(13); + } + break; + case 2: + { + _localctx = new Infix2Context(new ExprContext(_parentctx, _parentState)); + ((Infix2Context)_localctx).lhs = _prevctx; + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(78); + if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); + setState(79); + ((Infix2Context)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==PLUS || _la==MINUS) ) { + ((Infix2Context)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(80); + ((Infix2Context)_localctx).rhs = expr(12); + } + break; + case 3: + { + _localctx = new Infix3Context(new ExprContext(_parentctx, _parentState)); + ((Infix3Context)_localctx).lhs = _prevctx; + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(81); + if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); + setState(82); + ((Infix3Context)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LEQ) | (1L << GTE) | (1L << NEQ) | (1L << EQ) | (1L << LT) | (1L << GT))) != 0)) ) { + ((Infix3Context)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(83); + ((Infix3Context)_localctx).rhs = expr(11); + } + break; + case 4: + { + _localctx = new Infix4Context(new ExprContext(_parentctx, _parentState)); + ((Infix4Context)_localctx).lhs = _prevctx; + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(84); + if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); + setState(85); + match(AND); + setState(86); + ((Infix4Context)_localctx).rhs = expr(10); + } + break; + case 5: + { + _localctx = new Infix5Context(new ExprContext(_parentctx, _parentState)); + ((Infix5Context)_localctx).lhs = _prevctx; + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(87); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(88); + match(OR); + setState(89); + ((Infix5Context)_localctx).rhs = expr(9); + } + break; + case 6: + { + _localctx = new CompoundContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(90); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(95); + _errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + setState(91); + match(COMPOUND); + setState(93); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) { + case 1: + { + setState(92); + expr(0); + } + break; + } + } + } + break; + default: + throw new NoViableAltException(this); + } + setState(97); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,5,_ctx); + } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); + } + break; + } + } + } + setState(103); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class TypeContext extends ParserRuleContext { + public Token staticType; + public TerminalNode INTTYPE() { return getToken(BasicParser.INTTYPE, 0); } + public TerminalNode BOOLTYPE() { return getToken(BasicParser.BOOLTYPE, 0); } + public TerminalNode CHARTYPE() { return getToken(BasicParser.CHARTYPE, 0); } + public VariableContext variable() { + return getRuleContext(VariableContext.class,0); + } + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_type; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + TypeContext _localctx = new TypeContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_type); + int _la; + try { + setState(106); + _errHandler.sync(this); + switch (_input.LA(1)) { + case INTTYPE: + case BOOLTYPE: + case CHARTYPE: + enterOuterAlt(_localctx, 1); + { + setState(104); + ((TypeContext)_localctx).staticType = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INTTYPE) | (1L << BOOLTYPE) | (1L << CHARTYPE))) != 0)) ) { + ((TypeContext)_localctx).staticType = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + break; + case IDENTIFIER: + enterOuterAlt(_localctx, 2); + { + setState(105); + variable(); + } + 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 VariableContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { return getToken(BasicParser.IDENTIFIER, 0); } + public VariableContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_variable; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BasicVisitor ) return ((BasicVisitor)visitor).visitVariable(this); + else return visitor.visitChildren(this); + } + } + + public final VariableContext variable() throws RecognitionException { + VariableContext _localctx = new VariableContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_variable); + try { + enterOuterAlt(_localctx, 1); + { + setState(108); + match(IDENTIFIER); + } + } + 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 1: + return expr_sempred((ExprContext)_localctx, predIndex); + } + return true; + } + private boolean expr_sempred(ExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 12); + case 1: + return precpred(_ctx, 11); + case 2: + return precpred(_ctx, 10); + case 3: + return precpred(_ctx, 9); + case 4: + return precpred(_ctx, 8); + case 5: + return precpred(_ctx, 5); + } + return true; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3,q\4\2\t\2\4\3\t\3"+ + "\4\4\t\4\4\5\t\5\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ + "\3\3\3\3\3\7\3\33\n\3\f\3\16\3\36\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7\3"+ + "\'\n\3\f\3\16\3*\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3\64\n\3\3\3\3"+ + "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ + "\3\3\3\3\3\3\5\3L\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+ + "\3\3\3\3\3\3\3\3\3\3\3\3\5\3`\n\3\6\3b\n\3\r\3\16\3c\7\3f\n\3\f\3\16\3"+ + "i\13\3\3\4\3\4\5\4m\n\4\3\5\3\5\3\5\2\3\4\6\2\4\6\b\2\b\3\2\20\22\3\2"+ + "&\'\3\2\23\25\3\2\20\21\3\2\26\33\3\2\37!\2\u0084\2\n\3\2\2\2\4K\3\2\2"+ + "\2\6l\3\2\2\2\bn\3\2\2\2\n\13\5\4\3\2\13\3\3\2\2\2\f\r\b\3\1\2\r\16\7"+ + "\3\2\2\16\17\5\4\3\2\17\20\7\4\2\2\20L\3\2\2\2\21\22\7\5\2\2\22\23\5\4"+ + "\3\2\23\24\7\6\2\2\24L\3\2\2\2\25\26\7\7\2\2\26\27\7\3\2\2\27\34\5\b\5"+ + "\2\30\31\7$\2\2\31\33\5\b\5\2\32\30\3\2\2\2\33\36\3\2\2\2\34\32\3\2\2"+ + "\2\34\35\3\2\2\2\35\37\3\2\2\2\36\34\3\2\2\2\37 \7\4\2\2 L\3\2\2\2!\""+ + "\7\b\2\2\"#\7\3\2\2#(\5\4\3\2$%\7$\2\2%\'\5\4\3\2&$\3\2\2\2\'*\3\2\2\2"+ + "(&\3\2\2\2()\3\2\2\2)+\3\2\2\2*(\3\2\2\2+,\7\4\2\2,L\3\2\2\2-.\7\t\2\2"+ + "./\5\4\3\2/\60\7\n\2\2\60\63\5\4\3\2\61\62\7\13\2\2\62\64\5\4\3\2\63\61"+ + "\3\2\2\2\63\64\3\2\2\2\64\65\3\2\2\2\65\66\7\f\2\2\66L\3\2\2\2\678\7\r"+ + "\2\289\5\4\3\29:\7\16\2\2:;\5\4\3\2;<\7\17\2\2\t\2\2\2>L\5"+ + "\4\3\17?@\7\36\2\2@A\5\6\4\2AB\7(\2\2BL\3\2\2\2CD\5\b\5\2DE\7\"\2\2EF"+ + "\5\4\3\bFL\3\2\2\2GL\5\b\5\2HL\7)\2\2IL\7%\2\2JL\t\3\2\2K\f\3\2\2\2K\21"+ + "\3\2\2\2K\25\3\2\2\2K!\3\2\2\2K-\3\2\2\2K\67\3\2\2\2K=\3\2\2\2K?\3\2\2"+ + "\2KC\3\2\2\2KG\3\2\2\2KH\3\2\2\2KI\3\2\2\2KJ\3\2\2\2Lg\3\2\2\2MN\f\16"+ + "\2\2NO\t\4\2\2Of\5\4\3\17PQ\f\r\2\2QR\t\5\2\2Rf\5\4\3\16ST\f\f\2\2TU\t"+ + "\6\2\2Uf\5\4\3\rVW\f\13\2\2WX\7\34\2\2Xf\5\4\3\fYZ\f\n\2\2Z[\7\35\2\2"+ + "[f\5\4\3\13\\a\f\7\2\2]_\7#\2\2^`\5\4\3\2_^\3\2\2\2_`\3\2\2\2`b\3\2\2"+ + "\2a]\3\2\2\2bc\3\2\2\2ca\3\2\2\2cd\3\2\2\2df\3\2\2\2eM\3\2\2\2eP\3\2\2"+ + "\2eS\3\2\2\2eV\3\2\2\2eY\3\2\2\2e\\\3\2\2\2fi\3\2\2\2ge\3\2\2\2gh\3\2"+ + "\2\2h\5\3\2\2\2ig\3\2\2\2jm\t\7\2\2km\5\b\5\2lj\3\2\2\2lk\3\2\2\2m\7\3"+ + "\2\2\2no\7(\2\2o\t\3\2\2\2\13\34(\63K_cegl"; + 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); + } + } +} \ No newline at end of file diff --git a/src/pp/s1184725/boppi/BasicVisitor.java b/src/pp/s1184725/boppi/BasicVisitor.java new file mode 100644 index 0000000..06729fa --- /dev/null +++ b/src/pp/s1184725/boppi/BasicVisitor.java @@ -0,0 +1,164 @@ +// Generated from Basic.g4 by ANTLR 4.7 +package pp.s1184725.boppi; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link BasicParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface BasicVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link BasicParser#program}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitProgram(BasicParser.ProgramContext ctx); + /** + * Visit a parse tree produced by the {@code parens} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParens(BasicParser.ParensContext ctx); + /** + * Visit a parse tree produced by the {@code read} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRead(BasicParser.ReadContext ctx); + /** + * Visit a parse tree produced by the {@code declare} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclare(BasicParser.DeclareContext ctx); + /** + * Visit a parse tree produced by the {@code bool} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBool(BasicParser.BoolContext ctx); + /** + * Visit a parse tree produced by the {@code var} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVar(BasicParser.VarContext ctx); + /** + * Visit a parse tree produced by the {@code infix2} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix2(BasicParser.Infix2Context ctx); + /** + * Visit a parse tree produced by the {@code infix3} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix3(BasicParser.Infix3Context ctx); + /** + * Visit a parse tree produced by the {@code infix1} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix1(BasicParser.Infix1Context ctx); + /** + * Visit a parse tree produced by the {@code while} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhile(BasicParser.WhileContext ctx); + /** + * Visit a parse tree produced by the {@code compound} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCompound(BasicParser.CompoundContext ctx); + /** + * Visit a parse tree produced by the {@code infix4} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix4(BasicParser.Infix4Context ctx); + /** + * Visit a parse tree produced by the {@code infix5} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix5(BasicParser.Infix5Context ctx); + /** + * Visit a parse tree produced by the {@code number} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNumber(BasicParser.NumberContext ctx); + /** + * Visit a parse tree produced by the {@code char} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitChar(BasicParser.CharContext ctx); + /** + * Visit a parse tree produced by the {@code block} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(BasicParser.BlockContext ctx); + /** + * Visit a parse tree produced by the {@code write} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWrite(BasicParser.WriteContext ctx); + /** + * Visit a parse tree produced by the {@code if} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIf(BasicParser.IfContext ctx); + /** + * Visit a parse tree produced by the {@code prefix1} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrefix1(BasicParser.Prefix1Context ctx); + /** + * Visit a parse tree produced by the {@code assign} + * labeled alternative in {@link BasicParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(BasicParser.AssignContext ctx); + /** + * Visit a parse tree produced by {@link BasicParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitType(BasicParser.TypeContext ctx); + /** + * Visit a parse tree produced by {@link BasicParser#variable}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariable(BasicParser.VariableContext ctx); +} \ No newline at end of file