The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitProgram(DemoParser.ProgramContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitMainStatement(DemoParser.MainStatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitProgPartFunctionDefinition(DemoParser.ProgPartFunctionDefinitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitStatement(DemoParser.StatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBranch(DemoParser.BranchContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBlock(DemoParser.BlockContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitDiv(DemoParser.DivContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitVariable(DemoParser.VariableContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitFuncCallExpression(DemoParser.FuncCallExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitOr(DemoParser.OrContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitNumber(DemoParser.NumberContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitMult(DemoParser.MultContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitAnd(DemoParser.AndContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitRelational(DemoParser.RelationalContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitString(DemoParser.StringContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitPlus(DemoParser.PlusContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitMinus(DemoParser.MinusContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitVarDeclaration(DemoParser.VarDeclarationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitAssignment(DemoParser.AssignmentContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitPrintln(DemoParser.PrintlnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitPrint(DemoParser.PrintContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitFunctionDefinition(DemoParser.FunctionDefinitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitStatementList(DemoParser.StatementListContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitParameters(DemoParser.ParametersContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitFunctionCall(DemoParser.FunctionCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitExpressionList(DemoParser.ExpressionListContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.interp b/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.interp new file mode 100644 index 0000000..20b9e01 --- /dev/null +++ b/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.interp @@ -0,0 +1,65 @@ +token literal names: +null +';' +'/' +'*' +'-' +'+' +'int' +'=' +'print(' +')' +'(' +'{' +'return' +'}' +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +IDENTIFIER +NUMBER +WHITESPACE + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +IDENTIFIER +NUMBER +WHITESPACE + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 18, 92, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 7, 15, 76, 10, 15, 12, 15, 14, 15, 79, 11, 15, 3, 16, 6, 16, 82, 10, 16, 13, 16, 14, 16, 83, 3, 17, 6, 17, 87, 10, 17, 13, 17, 14, 17, 88, 3, 17, 3, 17, 2, 2, 18, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 3, 2, 6, 4, 2, 67, 92, 99, 124, 5, 2, 50, 59, 67, 92, 99, 124, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 2, 94, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 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, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 3, 35, 3, 2, 2, 2, 5, 37, 3, 2, 2, 2, 7, 39, 3, 2, 2, 2, 9, 41, 3, 2, 2, 2, 11, 43, 3, 2, 2, 2, 13, 45, 3, 2, 2, 2, 15, 49, 3, 2, 2, 2, 17, 51, 3, 2, 2, 2, 19, 58, 3, 2, 2, 2, 21, 60, 3, 2, 2, 2, 23, 62, 3, 2, 2, 2, 25, 64, 3, 2, 2, 2, 27, 71, 3, 2, 2, 2, 29, 73, 3, 2, 2, 2, 31, 81, 3, 2, 2, 2, 33, 86, 3, 2, 2, 2, 35, 36, 7, 61, 2, 2, 36, 4, 3, 2, 2, 2, 37, 38, 7, 49, 2, 2, 38, 6, 3, 2, 2, 2, 39, 40, 7, 44, 2, 2, 40, 8, 3, 2, 2, 2, 41, 42, 7, 47, 2, 2, 42, 10, 3, 2, 2, 2, 43, 44, 7, 45, 2, 2, 44, 12, 3, 2, 2, 2, 45, 46, 7, 107, 2, 2, 46, 47, 7, 112, 2, 2, 47, 48, 7, 118, 2, 2, 48, 14, 3, 2, 2, 2, 49, 50, 7, 63, 2, 2, 50, 16, 3, 2, 2, 2, 51, 52, 7, 114, 2, 2, 52, 53, 7, 116, 2, 2, 53, 54, 7, 107, 2, 2, 54, 55, 7, 112, 2, 2, 55, 56, 7, 118, 2, 2, 56, 57, 7, 42, 2, 2, 57, 18, 3, 2, 2, 2, 58, 59, 7, 43, 2, 2, 59, 20, 3, 2, 2, 2, 60, 61, 7, 42, 2, 2, 61, 22, 3, 2, 2, 2, 62, 63, 7, 125, 2, 2, 63, 24, 3, 2, 2, 2, 64, 65, 7, 116, 2, 2, 65, 66, 7, 103, 2, 2, 66, 67, 7, 118, 2, 2, 67, 68, 7, 119, 2, 2, 68, 69, 7, 116, 2, 2, 69, 70, 7, 112, 2, 2, 70, 26, 3, 2, 2, 2, 71, 72, 7, 127, 2, 2, 72, 28, 3, 2, 2, 2, 73, 77, 9, 2, 2, 2, 74, 76, 9, 3, 2, 2, 75, 74, 3, 2, 2, 2, 76, 79, 3, 2, 2, 2, 77, 75, 3, 2, 2, 2, 77, 78, 3, 2, 2, 2, 78, 30, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 80, 82, 9, 4, 2, 2, 81, 80, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 81, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 32, 3, 2, 2, 2, 85, 87, 9, 5, 2, 2, 86, 85, 3, 2, 2, 2, 87, 88, 3, 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 90, 3, 2, 2, 2, 90, 91, 8, 17, 2, 2, 91, 34, 3, 2, 2, 2, 6, 2, 77, 83, 88, 3, 8, 2, 2] \ No newline at end of file diff --git a/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.java b/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.java new file mode 100644 index 0000000..63ebbf8 --- /dev/null +++ b/parser/src/main/java/de/letsbuildacompiler/parser/DemoLexer.java @@ -0,0 +1,160 @@ +// Generated from /home/thibaud/Programmation/Java/antlr-compiler/Demo.g4 by ANTLR 4.7 +package de.letsbuildacompiler.parser; +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 DemoLexer 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 + 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, IDENTIFIER=24, + NUMBER=25, WHITESPACE=26, STRING=27; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "IDENTIFIER", "NUMBER", + "WHITESPACE", "STRING" + }; + + private static final String[] _LITERAL_NAMES = { + null, "';'", "'if'", "'('", "')'", "'else'", "'{'", "'}'", "'/'", "'*'", + "'-'", "'+'", "'<'", "'<='", "'>'", "'>='", "'&&'", "'||'", "'int'", "'='", + "'println('", "'print('", "'return'", "','" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + "IDENTIFIER", "NUMBER", "WHITESPACE", "STRING" + }; + 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] = "