added antlr
This commit is contained in:
parent
8cdd13c4dc
commit
cd7aac282e
16
.gitignore
vendored
16
.gitignore
vendored
@ -31,14 +31,14 @@
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
.idea/artifacts
|
||||
.idea/compiler.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/modules.xml
|
||||
.idea/*.iml
|
||||
.idea/modules
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
18
.idea/misc.xml
generated
18
.idea/misc.xml
generated
@ -16,6 +16,22 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ANTLRNewGenerationPreferences">
|
||||
<option name="perGrammarGenerationSettings">
|
||||
<list>
|
||||
<PerGrammarGenerationSettings>
|
||||
<option name="fileName" value="$PROJECT_DIR$/src/main/java/parser/SimpleJava.g4" />
|
||||
<option name="autoGen" value="true" />
|
||||
<option name="outputDir" value="C:\Users\Johannes Ehlert\Documents\Git\JavaCompiler\src\main\java" />
|
||||
<option name="libDir" value="" />
|
||||
<option name="encoding" value="" />
|
||||
<option name="pkg" value="parser.generated" />
|
||||
<option name="language" value="" />
|
||||
<option name="generateVisitor" value="true" />
|
||||
</PerGrammarGenerationSettings>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
@ -24,7 +40,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
BIN
antlr-4.12.0-complete.jar
Normal file
BIN
antlr-4.12.0-complete.jar
Normal file
Binary file not shown.
23
src/main/java/parser/generated/SimpleJava.interp
Normal file
23
src/main/java/parser/generated/SimpleJava.interp
Normal file
@ -0,0 +1,23 @@
|
||||
token literal names:
|
||||
null
|
||||
'class'
|
||||
'{'
|
||||
'}'
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
IDENTIFIER
|
||||
WS
|
||||
|
||||
rule names:
|
||||
program
|
||||
classDeclaration
|
||||
|
||||
|
||||
atn:
|
||||
[4, 1, 5, 15, 2, 0, 7, 0, 2, 1, 7, 1, 1, 0, 4, 0, 6, 8, 0, 11, 0, 12, 0, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 2, 0, 0, 13, 0, 5, 1, 0, 0, 0, 2, 9, 1, 0, 0, 0, 4, 6, 3, 2, 1, 0, 5, 4, 1, 0, 0, 0, 6, 7, 1, 0, 0, 0, 7, 5, 1, 0, 0, 0, 7, 8, 1, 0, 0, 0, 8, 1, 1, 0, 0, 0, 9, 10, 5, 1, 0, 0, 10, 11, 5, 4, 0, 0, 11, 12, 5, 2, 0, 0, 12, 13, 5, 3, 0, 0, 13, 3, 1, 0, 0, 0, 1, 7]
|
8
src/main/java/parser/generated/SimpleJava.tokens
Normal file
8
src/main/java/parser/generated/SimpleJava.tokens
Normal file
@ -0,0 +1,8 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
IDENTIFIER=4
|
||||
WS=5
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
64
src/main/java/parser/generated/SimpleJavaBaseListener.java
Normal file
64
src/main/java/parser/generated/SimpleJavaBaseListener.java
Normal file
@ -0,0 +1,64 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link SimpleJavaListener},
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public class SimpleJavaBaseListener implements SimpleJavaListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterProgram(SimpleJavaParser.ProgramContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitProgram(SimpleJavaParser.ProgramContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitTerminal(TerminalNode node) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitErrorNode(ErrorNode node) { }
|
||||
}
|
29
src/main/java/parser/generated/SimpleJavaBaseVisitor.java
Normal file
29
src/main/java/parser/generated/SimpleJavaBaseVisitor.java
Normal file
@ -0,0 +1,29 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link SimpleJavaVisitor},
|
||||
* which can be extended to create a visitor which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public class SimpleJavaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SimpleJavaVisitor<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitProgram(SimpleJavaParser.ProgramContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx) { return visitChildren(ctx); }
|
||||
}
|
32
src/main/java/parser/generated/SimpleJavaLexer.interp
Normal file
32
src/main/java/parser/generated/SimpleJavaLexer.interp
Normal file
@ -0,0 +1,32 @@
|
||||
token literal names:
|
||||
null
|
||||
'class'
|
||||
'{'
|
||||
'}'
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
IDENTIFIER
|
||||
WS
|
||||
|
||||
rule names:
|
||||
T__0
|
||||
T__1
|
||||
T__2
|
||||
IDENTIFIER
|
||||
WS
|
||||
|
||||
channel names:
|
||||
DEFAULT_TOKEN_CHANNEL
|
||||
HIDDEN
|
||||
|
||||
mode names:
|
||||
DEFAULT_MODE
|
||||
|
||||
atn:
|
||||
[4, 0, 5, 35, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 5, 3, 24, 8, 3, 10, 3, 12, 3, 27, 9, 3, 1, 4, 4, 4, 30, 8, 4, 11, 4, 12, 4, 31, 1, 4, 1, 4, 0, 0, 5, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 1, 0, 3, 2, 0, 65, 90, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 36, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 1, 11, 1, 0, 0, 0, 3, 17, 1, 0, 0, 0, 5, 19, 1, 0, 0, 0, 7, 21, 1, 0, 0, 0, 9, 29, 1, 0, 0, 0, 11, 12, 5, 99, 0, 0, 12, 13, 5, 108, 0, 0, 13, 14, 5, 97, 0, 0, 14, 15, 5, 115, 0, 0, 15, 16, 5, 115, 0, 0, 16, 2, 1, 0, 0, 0, 17, 18, 5, 123, 0, 0, 18, 4, 1, 0, 0, 0, 19, 20, 5, 125, 0, 0, 20, 6, 1, 0, 0, 0, 21, 25, 7, 0, 0, 0, 22, 24, 7, 1, 0, 0, 23, 22, 1, 0, 0, 0, 24, 27, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 8, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 28, 30, 7, 2, 0, 0, 29, 28, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 29, 1, 0, 0, 0, 31, 32, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 34, 6, 4, 0, 0, 34, 10, 1, 0, 0, 0, 3, 0, 25, 31, 1, 6, 0, 0]
|
140
src/main/java/parser/generated/SimpleJavaLexer.java
Normal file
140
src/main/java/parser/generated/SimpleJavaLexer.java
Normal file
@ -0,0 +1,140 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
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", "CheckReturnValue", "this-escape"})
|
||||
public class SimpleJavaLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, IDENTIFIER=4, WS=5;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"T__0", "T__1", "T__2", "IDENTIFIER", "WS"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'class'", "'{'", "'}'"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, "IDENTIFIER", "WS"
|
||||
};
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public SimpleJavaLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "SimpleJava.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 =
|
||||
"\u0004\u0000\u0005#\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
|
||||
"\u0007\u0004\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+
|
||||
"\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003"+
|
||||
"\u0001\u0003\u0005\u0003\u0018\b\u0003\n\u0003\f\u0003\u001b\t\u0003\u0001"+
|
||||
"\u0004\u0004\u0004\u001e\b\u0004\u000b\u0004\f\u0004\u001f\u0001\u0004"+
|
||||
"\u0001\u0004\u0000\u0000\u0005\u0001\u0001\u0003\u0002\u0005\u0003\u0007"+
|
||||
"\u0004\t\u0005\u0001\u0000\u0003\u0002\u0000AZaz\u0004\u000009AZ__az\u0003"+
|
||||
"\u0000\t\n\r\r $\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0001\u000b\u0001\u0000"+
|
||||
"\u0000\u0000\u0003\u0011\u0001\u0000\u0000\u0000\u0005\u0013\u0001\u0000"+
|
||||
"\u0000\u0000\u0007\u0015\u0001\u0000\u0000\u0000\t\u001d\u0001\u0000\u0000"+
|
||||
"\u0000\u000b\f\u0005c\u0000\u0000\f\r\u0005l\u0000\u0000\r\u000e\u0005"+
|
||||
"a\u0000\u0000\u000e\u000f\u0005s\u0000\u0000\u000f\u0010\u0005s\u0000"+
|
||||
"\u0000\u0010\u0002\u0001\u0000\u0000\u0000\u0011\u0012\u0005{\u0000\u0000"+
|
||||
"\u0012\u0004\u0001\u0000\u0000\u0000\u0013\u0014\u0005}\u0000\u0000\u0014"+
|
||||
"\u0006\u0001\u0000\u0000\u0000\u0015\u0019\u0007\u0000\u0000\u0000\u0016"+
|
||||
"\u0018\u0007\u0001\u0000\u0000\u0017\u0016\u0001\u0000\u0000\u0000\u0018"+
|
||||
"\u001b\u0001\u0000\u0000\u0000\u0019\u0017\u0001\u0000\u0000\u0000\u0019"+
|
||||
"\u001a\u0001\u0000\u0000\u0000\u001a\b\u0001\u0000\u0000\u0000\u001b\u0019"+
|
||||
"\u0001\u0000\u0000\u0000\u001c\u001e\u0007\u0002\u0000\u0000\u001d\u001c"+
|
||||
"\u0001\u0000\u0000\u0000\u001e\u001f\u0001\u0000\u0000\u0000\u001f\u001d"+
|
||||
"\u0001\u0000\u0000\u0000\u001f \u0001\u0000\u0000\u0000 !\u0001\u0000"+
|
||||
"\u0000\u0000!\"\u0006\u0004\u0000\u0000\"\n\u0001\u0000\u0000\u0000\u0003"+
|
||||
"\u0000\u0019\u001f\u0001\u0006\u0000\u0000";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
8
src/main/java/parser/generated/SimpleJavaLexer.tokens
Normal file
8
src/main/java/parser/generated/SimpleJavaLexer.tokens
Normal file
@ -0,0 +1,8 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
IDENTIFIER=4
|
||||
WS=5
|
||||
'class'=1
|
||||
'{'=2
|
||||
'}'=3
|
30
src/main/java/parser/generated/SimpleJavaListener.java
Normal file
30
src/main/java/parser/generated/SimpleJavaListener.java
Normal file
@ -0,0 +1,30 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
* This interface defines a complete listener for a parse tree produced by
|
||||
* {@link SimpleJavaParser}.
|
||||
*/
|
||||
public interface SimpleJavaListener extends ParseTreeListener {
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
}
|
221
src/main/java/parser/generated/SimpleJavaParser.java
Normal file
221
src/main/java/parser/generated/SimpleJavaParser.java
Normal file
@ -0,0 +1,221 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
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 SimpleJavaParser 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
|
||||
T__0=1, T__1=2, T__2=3, IDENTIFIER=4, WS=5;
|
||||
public static final int
|
||||
RULE_program = 0, RULE_classDeclaration = 1;
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"program", "classDeclaration"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'class'", "'{'", "'}'"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, "IDENTIFIER", "WS"
|
||||
};
|
||||
}
|
||||
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 "SimpleJava.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public SimpleJavaParser(TokenStream input) {
|
||||
super(input);
|
||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class ProgramContext extends ParserRuleContext {
|
||||
public List<ClassDeclarationContext> classDeclaration() {
|
||||
return getRuleContexts(ClassDeclarationContext.class);
|
||||
}
|
||||
public ClassDeclarationContext classDeclaration(int i) {
|
||||
return getRuleContext(ClassDeclarationContext.class,i);
|
||||
}
|
||||
public ProgramContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_program; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterProgram(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitProgram(this);
|
||||
}
|
||||
@Override
|
||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
|
||||
if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor<? extends T>)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);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(5);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
do {
|
||||
{
|
||||
{
|
||||
setState(4);
|
||||
classDeclaration();
|
||||
}
|
||||
}
|
||||
setState(7);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
} while ( _la==T__0 );
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class ClassDeclarationContext extends ParserRuleContext {
|
||||
public TerminalNode IDENTIFIER() { return getToken(SimpleJavaParser.IDENTIFIER, 0); }
|
||||
public ClassDeclarationContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_classDeclaration; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).enterClassDeclaration(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof SimpleJavaListener ) ((SimpleJavaListener)listener).exitClassDeclaration(this);
|
||||
}
|
||||
@Override
|
||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
|
||||
if ( visitor instanceof SimpleJavaVisitor ) return ((SimpleJavaVisitor<? extends T>)visitor).visitClassDeclaration(this);
|
||||
else return visitor.visitChildren(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final ClassDeclarationContext classDeclaration() throws RecognitionException {
|
||||
ClassDeclarationContext _localctx = new ClassDeclarationContext(_ctx, getState());
|
||||
enterRule(_localctx, 2, RULE_classDeclaration);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(9);
|
||||
match(T__0);
|
||||
setState(10);
|
||||
match(IDENTIFIER);
|
||||
setState(11);
|
||||
match(T__1);
|
||||
setState(12);
|
||||
match(T__2);
|
||||
}
|
||||
}
|
||||
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\u0005\u000f\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001"+
|
||||
"\u0001\u0000\u0004\u0000\u0006\b\u0000\u000b\u0000\f\u0000\u0007\u0001"+
|
||||
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0000"+
|
||||
"\u0000\u0002\u0000\u0002\u0000\u0000\r\u0000\u0005\u0001\u0000\u0000\u0000"+
|
||||
"\u0002\t\u0001\u0000\u0000\u0000\u0004\u0006\u0003\u0002\u0001\u0000\u0005"+
|
||||
"\u0004\u0001\u0000\u0000\u0000\u0006\u0007\u0001\u0000\u0000\u0000\u0007"+
|
||||
"\u0005\u0001\u0000\u0000\u0000\u0007\b\u0001\u0000\u0000\u0000\b\u0001"+
|
||||
"\u0001\u0000\u0000\u0000\t\n\u0005\u0001\u0000\u0000\n\u000b\u0005\u0004"+
|
||||
"\u0000\u0000\u000b\f\u0005\u0002\u0000\u0000\f\r\u0005\u0003\u0000\u0000"+
|
||||
"\r\u0003\u0001\u0000\u0000\u0000\u0001\u0007";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/parser/generated/SimpleJavaVisitor.java
Normal file
25
src/main/java/parser/generated/SimpleJavaVisitor.java
Normal file
@ -0,0 +1,25 @@
|
||||
// Generated from C:/Users/Johannes Ehlert/Documents/Git/JavaCompiler/src/main/java/parser/SimpleJava.g4 by ANTLR 4.13.1
|
||||
package parser.generated;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This interface defines a complete generic visitor for a parse tree produced
|
||||
* by {@link SimpleJavaParser}.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
public interface SimpleJavaVisitor<T> extends ParseTreeVisitor<T> {
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#program}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitProgram(SimpleJavaParser.ProgramContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SimpleJavaParser#classDeclaration}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitClassDeclaration(SimpleJavaParser.ClassDeclarationContext ctx);
|
||||
}
|
Loading…
Reference in New Issue
Block a user