finish code gen
This commit is contained in:
parent
39363e1ba7
commit
33b867e62a
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -9,6 +9,12 @@ temp/
|
||||||
.vscode/
|
.vscode/
|
||||||
CodeGen.old/
|
CodeGen.old/
|
||||||
|
|
||||||
|
## Ban Generated Code
|
||||||
|
LibCmo/Generated/*.hpp
|
||||||
|
LibCmo/Generated/*.cpp
|
||||||
|
Unvirt/Generated/*.hpp
|
||||||
|
Unvirt/Generated/*.cpp
|
||||||
|
|
||||||
## CMake Banned
|
## CMake Banned
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
|
|
4
CodeGen/.gitignore
vendored
4
CodeGen/.gitignore
vendored
|
@ -2,6 +2,10 @@
|
||||||
*.interp
|
*.interp
|
||||||
*.tokens
|
*.tokens
|
||||||
|
|
||||||
|
CKGeneralLexer*.java
|
||||||
|
CKEnumsParser*.java
|
||||||
|
CKDefinesParser*.java
|
||||||
|
|
||||||
# Eclipse projects
|
# Eclipse projects
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
|
|
@ -3,4 +3,4 @@ options { tokenVocab = CKGeneralLexer; }
|
||||||
|
|
||||||
prog: definePair+ ;
|
prog: definePair+ ;
|
||||||
|
|
||||||
definePair: CKGENERAL_DEFINE CKGENERAL_ID CKGENERAL_NUM ;
|
definePair: CKGENERAL_DEFINE CKGENERAL_ID (CKGENERAL_NUM | CKGENERAL_ID) ;
|
||||||
|
|
|
@ -1,217 +0,0 @@
|
||||||
// Generated from CKDefinesParser.g4 by ANTLR 4.13.0
|
|
||||||
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 CKDefinesParser extends Parser {
|
|
||||||
static { RuntimeMetaData.checkVersion("4.13.0", RuntimeMetaData.VERSION); }
|
|
||||||
|
|
||||||
protected static final DFA[] _decisionToDFA;
|
|
||||||
protected static final PredictionContextCache _sharedContextCache =
|
|
||||||
new PredictionContextCache();
|
|
||||||
public static final int
|
|
||||||
CKGENERAL_TYPEDEF=1, CKGENERAL_DEFINE=2, CKGENERAL_ENUM=3, CKGENERAL_LBRACKET=4,
|
|
||||||
CKGENERAL_RBRACKET=5, CKGENERAL_EQUAL=6, CKGENERAL_SEMICOLON=7, CKGENERAL_LSHIFT=8,
|
|
||||||
CKGENERAL_OR=9, CKGENERAL_COMMA=10, CKGENERAL_ID=11, CKGENERAL_NUM=12,
|
|
||||||
CKGENERAL_LINE_COMMENT=13, CKGENERAL_BLOCK_COMMENT=14, CKGENERAL_WS=15;
|
|
||||||
public static final int
|
|
||||||
RULE_prog = 0, RULE_definePair = 1;
|
|
||||||
private static String[] makeRuleNames() {
|
|
||||||
return new String[] {
|
|
||||||
"prog", "definePair"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static final String[] ruleNames = makeRuleNames();
|
|
||||||
|
|
||||||
private static String[] makeLiteralNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "'typedef'", "'#define'", "'enum'", "'{'", "'}'", "'='", "';'",
|
|
||||||
"'<<'", "'|'", "','"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
||||||
private static String[] makeSymbolicNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "CKGENERAL_TYPEDEF", "CKGENERAL_DEFINE", "CKGENERAL_ENUM", "CKGENERAL_LBRACKET",
|
|
||||||
"CKGENERAL_RBRACKET", "CKGENERAL_EQUAL", "CKGENERAL_SEMICOLON", "CKGENERAL_LSHIFT",
|
|
||||||
"CKGENERAL_OR", "CKGENERAL_COMMA", "CKGENERAL_ID", "CKGENERAL_NUM", "CKGENERAL_LINE_COMMENT",
|
|
||||||
"CKGENERAL_BLOCK_COMMENT", "CKGENERAL_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 "CKDefinesParser.g4"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getRuleNames() { return ruleNames; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSerializedATN() { return _serializedATN; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ATN getATN() { return _ATN; }
|
|
||||||
|
|
||||||
public CKDefinesParser(TokenStream input) {
|
|
||||||
super(input);
|
|
||||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class ProgContext extends ParserRuleContext {
|
|
||||||
public List<DefinePairContext> definePair() {
|
|
||||||
return getRuleContexts(DefinePairContext.class);
|
|
||||||
}
|
|
||||||
public DefinePairContext definePair(int i) {
|
|
||||||
return getRuleContext(DefinePairContext.class,i);
|
|
||||||
}
|
|
||||||
public ProgContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_prog; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKDefinesParserListener ) ((CKDefinesParserListener)listener).enterProg(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKDefinesParserListener ) ((CKDefinesParserListener)listener).exitProg(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final ProgContext prog() throws RecognitionException {
|
|
||||||
ProgContext _localctx = new ProgContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 0, RULE_prog);
|
|
||||||
int _la;
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(5);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
do {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
setState(4);
|
|
||||||
definePair();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(7);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
} while ( _la==CKGENERAL_DEFINE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (RecognitionException re) {
|
|
||||||
_localctx.exception = re;
|
|
||||||
_errHandler.reportError(this, re);
|
|
||||||
_errHandler.recover(this, re);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exitRule();
|
|
||||||
}
|
|
||||||
return _localctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class DefinePairContext extends ParserRuleContext {
|
|
||||||
public TerminalNode CKGENERAL_DEFINE() { return getToken(CKDefinesParser.CKGENERAL_DEFINE, 0); }
|
|
||||||
public TerminalNode CKGENERAL_ID() { return getToken(CKDefinesParser.CKGENERAL_ID, 0); }
|
|
||||||
public TerminalNode CKGENERAL_NUM() { return getToken(CKDefinesParser.CKGENERAL_NUM, 0); }
|
|
||||||
public DefinePairContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_definePair; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKDefinesParserListener ) ((CKDefinesParserListener)listener).enterDefinePair(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKDefinesParserListener ) ((CKDefinesParserListener)listener).exitDefinePair(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final DefinePairContext definePair() throws RecognitionException {
|
|
||||||
DefinePairContext _localctx = new DefinePairContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 2, RULE_definePair);
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(9);
|
|
||||||
match(CKGENERAL_DEFINE);
|
|
||||||
setState(10);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
setState(11);
|
|
||||||
match(CKGENERAL_NUM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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\u000f\u000e\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\u0000\u0000\u0002"+
|
|
||||||
"\u0000\u0002\u0000\u0000\f\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\u0002\u0000\u0000\n\u000b\u0005\u000b\u0000"+
|
|
||||||
"\u0000\u000b\f\u0005\f\u0000\u0000\f\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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Generated from CKDefinesParser.g4 by ANTLR 4.13.0
|
|
||||||
|
|
||||||
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 CKDefinesParserListener},
|
|
||||||
* which can be extended to create a listener which only needs to handle a subset
|
|
||||||
* of the available methods.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public class CKDefinesParserBaseListener implements CKDefinesParserListener {
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterProg(CKDefinesParser.ProgContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitProg(CKDefinesParser.ProgContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterDefinePair(CKDefinesParser.DefinePairContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitDefinePair(CKDefinesParser.DefinePairContext 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) { }
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Generated from CKDefinesParser.g4 by ANTLR 4.13.0
|
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface defines a complete listener for a parse tree produced by
|
|
||||||
* {@link CKDefinesParser}.
|
|
||||||
*/
|
|
||||||
public interface CKDefinesParserListener extends ParseTreeListener {
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link CKDefinesParser#prog}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterProg(CKDefinesParser.ProgContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link CKDefinesParser#prog}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitProg(CKDefinesParser.ProgContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link CKDefinesParser#definePair}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterDefinePair(CKDefinesParser.DefinePairContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link CKDefinesParser#definePair}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitDefinePair(CKDefinesParser.DefinePairContext ctx);
|
|
||||||
}
|
|
|
@ -1,477 +0,0 @@
|
||||||
// Generated from CKEnumsParser.g4 by ANTLR 4.13.0
|
|
||||||
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 CKEnumsParser extends Parser {
|
|
||||||
static { RuntimeMetaData.checkVersion("4.13.0", RuntimeMetaData.VERSION); }
|
|
||||||
|
|
||||||
protected static final DFA[] _decisionToDFA;
|
|
||||||
protected static final PredictionContextCache _sharedContextCache =
|
|
||||||
new PredictionContextCache();
|
|
||||||
public static final int
|
|
||||||
CKGENERAL_TYPEDEF=1, CKGENERAL_DEFINE=2, CKGENERAL_ENUM=3, CKGENERAL_LBRACKET=4,
|
|
||||||
CKGENERAL_RBRACKET=5, CKGENERAL_EQUAL=6, CKGENERAL_SEMICOLON=7, CKGENERAL_LSHIFT=8,
|
|
||||||
CKGENERAL_OR=9, CKGENERAL_COMMA=10, CKGENERAL_ID=11, CKGENERAL_NUM=12,
|
|
||||||
CKGENERAL_LINE_COMMENT=13, CKGENERAL_BLOCK_COMMENT=14, CKGENERAL_WS=15;
|
|
||||||
public static final int
|
|
||||||
RULE_prog = 0, RULE_enumBody = 1, RULE_entryPair = 2, RULE_entryValue = 3;
|
|
||||||
private static String[] makeRuleNames() {
|
|
||||||
return new String[] {
|
|
||||||
"prog", "enumBody", "entryPair", "entryValue"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static final String[] ruleNames = makeRuleNames();
|
|
||||||
|
|
||||||
private static String[] makeLiteralNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "'typedef'", "'#define'", "'enum'", "'{'", "'}'", "'='", "';'",
|
|
||||||
"'<<'", "'|'", "','"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
||||||
private static String[] makeSymbolicNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "CKGENERAL_TYPEDEF", "CKGENERAL_DEFINE", "CKGENERAL_ENUM", "CKGENERAL_LBRACKET",
|
|
||||||
"CKGENERAL_RBRACKET", "CKGENERAL_EQUAL", "CKGENERAL_SEMICOLON", "CKGENERAL_LSHIFT",
|
|
||||||
"CKGENERAL_OR", "CKGENERAL_COMMA", "CKGENERAL_ID", "CKGENERAL_NUM", "CKGENERAL_LINE_COMMENT",
|
|
||||||
"CKGENERAL_BLOCK_COMMENT", "CKGENERAL_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 "CKEnumsParser.g4"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getRuleNames() { return ruleNames; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSerializedATN() { return _serializedATN; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ATN getATN() { return _ATN; }
|
|
||||||
|
|
||||||
public CKEnumsParser(TokenStream input) {
|
|
||||||
super(input);
|
|
||||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class ProgContext extends ParserRuleContext {
|
|
||||||
public List<EnumBodyContext> enumBody() {
|
|
||||||
return getRuleContexts(EnumBodyContext.class);
|
|
||||||
}
|
|
||||||
public EnumBodyContext enumBody(int i) {
|
|
||||||
return getRuleContext(EnumBodyContext.class,i);
|
|
||||||
}
|
|
||||||
public ProgContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_prog; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).enterProg(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).exitProg(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final ProgContext prog() throws RecognitionException {
|
|
||||||
ProgContext _localctx = new ProgContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 0, RULE_prog);
|
|
||||||
int _la;
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(11);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
while (_la==CKGENERAL_TYPEDEF || _la==CKGENERAL_ENUM) {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
setState(8);
|
|
||||||
enumBody();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(13);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (RecognitionException re) {
|
|
||||||
_localctx.exception = re;
|
|
||||||
_errHandler.reportError(this, re);
|
|
||||||
_errHandler.recover(this, re);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exitRule();
|
|
||||||
}
|
|
||||||
return _localctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class EnumBodyContext extends ParserRuleContext {
|
|
||||||
public TerminalNode CKGENERAL_ENUM() { return getToken(CKEnumsParser.CKGENERAL_ENUM, 0); }
|
|
||||||
public List<TerminalNode> CKGENERAL_ID() { return getTokens(CKEnumsParser.CKGENERAL_ID); }
|
|
||||||
public TerminalNode CKGENERAL_ID(int i) {
|
|
||||||
return getToken(CKEnumsParser.CKGENERAL_ID, i);
|
|
||||||
}
|
|
||||||
public TerminalNode CKGENERAL_LBRACKET() { return getToken(CKEnumsParser.CKGENERAL_LBRACKET, 0); }
|
|
||||||
public TerminalNode CKGENERAL_RBRACKET() { return getToken(CKEnumsParser.CKGENERAL_RBRACKET, 0); }
|
|
||||||
public TerminalNode CKGENERAL_SEMICOLON() { return getToken(CKEnumsParser.CKGENERAL_SEMICOLON, 0); }
|
|
||||||
public TerminalNode CKGENERAL_TYPEDEF() { return getToken(CKEnumsParser.CKGENERAL_TYPEDEF, 0); }
|
|
||||||
public List<EntryPairContext> entryPair() {
|
|
||||||
return getRuleContexts(EntryPairContext.class);
|
|
||||||
}
|
|
||||||
public EntryPairContext entryPair(int i) {
|
|
||||||
return getRuleContext(EntryPairContext.class,i);
|
|
||||||
}
|
|
||||||
public EnumBodyContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_enumBody; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).enterEnumBody(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).exitEnumBody(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final EnumBodyContext enumBody() throws RecognitionException {
|
|
||||||
EnumBodyContext _localctx = new EnumBodyContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 2, RULE_enumBody);
|
|
||||||
int _la;
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(15);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
if (_la==CKGENERAL_TYPEDEF) {
|
|
||||||
{
|
|
||||||
setState(14);
|
|
||||||
match(CKGENERAL_TYPEDEF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(17);
|
|
||||||
match(CKGENERAL_ENUM);
|
|
||||||
setState(18);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
setState(19);
|
|
||||||
match(CKGENERAL_LBRACKET);
|
|
||||||
setState(21);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
do {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
setState(20);
|
|
||||||
entryPair();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(23);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
} while ( _la==CKGENERAL_ID );
|
|
||||||
setState(25);
|
|
||||||
match(CKGENERAL_RBRACKET);
|
|
||||||
setState(27);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
if (_la==CKGENERAL_ID) {
|
|
||||||
{
|
|
||||||
setState(26);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(29);
|
|
||||||
match(CKGENERAL_SEMICOLON);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (RecognitionException re) {
|
|
||||||
_localctx.exception = re;
|
|
||||||
_errHandler.reportError(this, re);
|
|
||||||
_errHandler.recover(this, re);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exitRule();
|
|
||||||
}
|
|
||||||
return _localctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class EntryPairContext extends ParserRuleContext {
|
|
||||||
public TerminalNode CKGENERAL_ID() { return getToken(CKEnumsParser.CKGENERAL_ID, 0); }
|
|
||||||
public TerminalNode CKGENERAL_EQUAL() { return getToken(CKEnumsParser.CKGENERAL_EQUAL, 0); }
|
|
||||||
public EntryValueContext entryValue() {
|
|
||||||
return getRuleContext(EntryValueContext.class,0);
|
|
||||||
}
|
|
||||||
public TerminalNode CKGENERAL_COMMA() { return getToken(CKEnumsParser.CKGENERAL_COMMA, 0); }
|
|
||||||
public EntryPairContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_entryPair; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).enterEntryPair(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).exitEntryPair(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final EntryPairContext entryPair() throws RecognitionException {
|
|
||||||
EntryPairContext _localctx = new EntryPairContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 4, RULE_entryPair);
|
|
||||||
int _la;
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(31);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
setState(34);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
if (_la==CKGENERAL_EQUAL) {
|
|
||||||
{
|
|
||||||
setState(32);
|
|
||||||
match(CKGENERAL_EQUAL);
|
|
||||||
setState(33);
|
|
||||||
entryValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(37);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
if (_la==CKGENERAL_COMMA) {
|
|
||||||
{
|
|
||||||
setState(36);
|
|
||||||
match(CKGENERAL_COMMA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (RecognitionException re) {
|
|
||||||
_localctx.exception = re;
|
|
||||||
_errHandler.reportError(this, re);
|
|
||||||
_errHandler.recover(this, re);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exitRule();
|
|
||||||
}
|
|
||||||
return _localctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class EntryValueContext extends ParserRuleContext {
|
|
||||||
public EntryValueContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_entryValue; }
|
|
||||||
|
|
||||||
public EntryValueContext() { }
|
|
||||||
public void copyFrom(EntryValueContext ctx) {
|
|
||||||
super.copyFrom(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class EntryDirectValueContext extends EntryValueContext {
|
|
||||||
public List<TerminalNode> CKGENERAL_NUM() { return getTokens(CKEnumsParser.CKGENERAL_NUM); }
|
|
||||||
public TerminalNode CKGENERAL_NUM(int i) {
|
|
||||||
return getToken(CKEnumsParser.CKGENERAL_NUM, i);
|
|
||||||
}
|
|
||||||
public TerminalNode CKGENERAL_LSHIFT() { return getToken(CKEnumsParser.CKGENERAL_LSHIFT, 0); }
|
|
||||||
public EntryDirectValueContext(EntryValueContext ctx) { copyFrom(ctx); }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).enterEntryDirectValue(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).exitEntryDirectValue(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class EntryRelativeValueContext extends EntryValueContext {
|
|
||||||
public List<TerminalNode> CKGENERAL_ID() { return getTokens(CKEnumsParser.CKGENERAL_ID); }
|
|
||||||
public TerminalNode CKGENERAL_ID(int i) {
|
|
||||||
return getToken(CKEnumsParser.CKGENERAL_ID, i);
|
|
||||||
}
|
|
||||||
public List<TerminalNode> CKGENERAL_OR() { return getTokens(CKEnumsParser.CKGENERAL_OR); }
|
|
||||||
public TerminalNode CKGENERAL_OR(int i) {
|
|
||||||
return getToken(CKEnumsParser.CKGENERAL_OR, i);
|
|
||||||
}
|
|
||||||
public EntryRelativeValueContext(EntryValueContext ctx) { copyFrom(ctx); }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).enterEntryRelativeValue(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof CKEnumsParserListener ) ((CKEnumsParserListener)listener).exitEntryRelativeValue(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final EntryValueContext entryValue() throws RecognitionException {
|
|
||||||
EntryValueContext _localctx = new EntryValueContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 6, RULE_entryValue);
|
|
||||||
int _la;
|
|
||||||
try {
|
|
||||||
setState(52);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
switch (_input.LA(1)) {
|
|
||||||
case CKGENERAL_NUM:
|
|
||||||
_localctx = new EntryDirectValueContext(_localctx);
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(39);
|
|
||||||
match(CKGENERAL_NUM);
|
|
||||||
setState(42);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
if (_la==CKGENERAL_LSHIFT) {
|
|
||||||
{
|
|
||||||
setState(40);
|
|
||||||
match(CKGENERAL_LSHIFT);
|
|
||||||
setState(41);
|
|
||||||
match(CKGENERAL_NUM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CKGENERAL_ID:
|
|
||||||
_localctx = new EntryRelativeValueContext(_localctx);
|
|
||||||
enterOuterAlt(_localctx, 2);
|
|
||||||
{
|
|
||||||
setState(44);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
setState(49);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
while (_la==CKGENERAL_OR) {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
setState(45);
|
|
||||||
match(CKGENERAL_OR);
|
|
||||||
setState(46);
|
|
||||||
match(CKGENERAL_ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(51);
|
|
||||||
_errHandler.sync(this);
|
|
||||||
_la = _input.LA(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new NoViableAltException(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (RecognitionException re) {
|
|
||||||
_localctx.exception = re;
|
|
||||||
_errHandler.reportError(this, re);
|
|
||||||
_errHandler.recover(this, re);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
exitRule();
|
|
||||||
}
|
|
||||||
return _localctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String _serializedATN =
|
|
||||||
"\u0004\u0001\u000f7\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
|
||||||
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0001\u0000\u0005\u0000\n\b"+
|
|
||||||
"\u0000\n\u0000\f\u0000\r\t\u0000\u0001\u0001\u0003\u0001\u0010\b\u0001"+
|
|
||||||
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0004\u0001\u0016\b\u0001"+
|
|
||||||
"\u000b\u0001\f\u0001\u0017\u0001\u0001\u0001\u0001\u0003\u0001\u001c\b"+
|
|
||||||
"\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0003"+
|
|
||||||
"\u0002#\b\u0002\u0001\u0002\u0003\u0002&\b\u0002\u0001\u0003\u0001\u0003"+
|
|
||||||
"\u0001\u0003\u0003\u0003+\b\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+
|
|
||||||
"\u0005\u00030\b\u0003\n\u0003\f\u00033\t\u0003\u0003\u00035\b\u0003\u0001"+
|
|
||||||
"\u0003\u0000\u0000\u0004\u0000\u0002\u0004\u0006\u0000\u0000;\u0000\u000b"+
|
|
||||||
"\u0001\u0000\u0000\u0000\u0002\u000f\u0001\u0000\u0000\u0000\u0004\u001f"+
|
|
||||||
"\u0001\u0000\u0000\u0000\u00064\u0001\u0000\u0000\u0000\b\n\u0003\u0002"+
|
|
||||||
"\u0001\u0000\t\b\u0001\u0000\u0000\u0000\n\r\u0001\u0000\u0000\u0000\u000b"+
|
|
||||||
"\t\u0001\u0000\u0000\u0000\u000b\f\u0001\u0000\u0000\u0000\f\u0001\u0001"+
|
|
||||||
"\u0000\u0000\u0000\r\u000b\u0001\u0000\u0000\u0000\u000e\u0010\u0005\u0001"+
|
|
||||||
"\u0000\u0000\u000f\u000e\u0001\u0000\u0000\u0000\u000f\u0010\u0001\u0000"+
|
|
||||||
"\u0000\u0000\u0010\u0011\u0001\u0000\u0000\u0000\u0011\u0012\u0005\u0003"+
|
|
||||||
"\u0000\u0000\u0012\u0013\u0005\u000b\u0000\u0000\u0013\u0015\u0005\u0004"+
|
|
||||||
"\u0000\u0000\u0014\u0016\u0003\u0004\u0002\u0000\u0015\u0014\u0001\u0000"+
|
|
||||||
"\u0000\u0000\u0016\u0017\u0001\u0000\u0000\u0000\u0017\u0015\u0001\u0000"+
|
|
||||||
"\u0000\u0000\u0017\u0018\u0001\u0000\u0000\u0000\u0018\u0019\u0001\u0000"+
|
|
||||||
"\u0000\u0000\u0019\u001b\u0005\u0005\u0000\u0000\u001a\u001c\u0005\u000b"+
|
|
||||||
"\u0000\u0000\u001b\u001a\u0001\u0000\u0000\u0000\u001b\u001c\u0001\u0000"+
|
|
||||||
"\u0000\u0000\u001c\u001d\u0001\u0000\u0000\u0000\u001d\u001e\u0005\u0007"+
|
|
||||||
"\u0000\u0000\u001e\u0003\u0001\u0000\u0000\u0000\u001f\"\u0005\u000b\u0000"+
|
|
||||||
"\u0000 !\u0005\u0006\u0000\u0000!#\u0003\u0006\u0003\u0000\" \u0001\u0000"+
|
|
||||||
"\u0000\u0000\"#\u0001\u0000\u0000\u0000#%\u0001\u0000\u0000\u0000$&\u0005"+
|
|
||||||
"\n\u0000\u0000%$\u0001\u0000\u0000\u0000%&\u0001\u0000\u0000\u0000&\u0005"+
|
|
||||||
"\u0001\u0000\u0000\u0000\'*\u0005\f\u0000\u0000()\u0005\b\u0000\u0000"+
|
|
||||||
")+\u0005\f\u0000\u0000*(\u0001\u0000\u0000\u0000*+\u0001\u0000\u0000\u0000"+
|
|
||||||
"+5\u0001\u0000\u0000\u0000,1\u0005\u000b\u0000\u0000-.\u0005\t\u0000\u0000"+
|
|
||||||
".0\u0005\u000b\u0000\u0000/-\u0001\u0000\u0000\u000003\u0001\u0000\u0000"+
|
|
||||||
"\u00001/\u0001\u0000\u0000\u000012\u0001\u0000\u0000\u000025\u0001\u0000"+
|
|
||||||
"\u0000\u000031\u0001\u0000\u0000\u00004\'\u0001\u0000\u0000\u00004,\u0001"+
|
|
||||||
"\u0000\u0000\u00005\u0007\u0001\u0000\u0000\u0000\t\u000b\u000f\u0017"+
|
|
||||||
"\u001b\"%*14";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
// Generated from CKEnumsParser.g4 by ANTLR 4.13.0
|
|
||||||
|
|
||||||
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 CKEnumsParserListener},
|
|
||||||
* which can be extended to create a listener which only needs to handle a subset
|
|
||||||
* of the available methods.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public class CKEnumsParserBaseListener implements CKEnumsParserListener {
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterProg(CKEnumsParser.ProgContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitProg(CKEnumsParser.ProgContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterEnumBody(CKEnumsParser.EnumBodyContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitEnumBody(CKEnumsParser.EnumBodyContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterEntryPair(CKEnumsParser.EntryPairContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitEntryPair(CKEnumsParser.EntryPairContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterEntryDirectValue(CKEnumsParser.EntryDirectValueContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitEntryDirectValue(CKEnumsParser.EntryDirectValueContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterEntryRelativeValue(CKEnumsParser.EntryRelativeValueContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitEntryRelativeValue(CKEnumsParser.EntryRelativeValueContext 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) { }
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Generated from CKEnumsParser.g4 by ANTLR 4.13.0
|
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface defines a complete listener for a parse tree produced by
|
|
||||||
* {@link CKEnumsParser}.
|
|
||||||
*/
|
|
||||||
public interface CKEnumsParserListener extends ParseTreeListener {
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link CKEnumsParser#prog}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterProg(CKEnumsParser.ProgContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link CKEnumsParser#prog}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitProg(CKEnumsParser.ProgContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link CKEnumsParser#enumBody}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterEnumBody(CKEnumsParser.EnumBodyContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link CKEnumsParser#enumBody}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitEnumBody(CKEnumsParser.EnumBodyContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link CKEnumsParser#entryPair}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterEntryPair(CKEnumsParser.EntryPairContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link CKEnumsParser#entryPair}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitEntryPair(CKEnumsParser.EntryPairContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code entryDirectValue}
|
|
||||||
* labeled alternative in {@link CKEnumsParser#entryValue}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterEntryDirectValue(CKEnumsParser.EntryDirectValueContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code entryDirectValue}
|
|
||||||
* labeled alternative in {@link CKEnumsParser#entryValue}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitEntryDirectValue(CKEnumsParser.EntryDirectValueContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code entryRelativeValue}
|
|
||||||
* labeled alternative in {@link CKEnumsParser#entryValue}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterEntryRelativeValue(CKEnumsParser.EntryRelativeValueContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code entryRelativeValue}
|
|
||||||
* labeled alternative in {@link CKEnumsParser#entryValue}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitEntryRelativeValue(CKEnumsParser.EntryRelativeValueContext ctx);
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.antlr.v4.runtime.*;
|
|
||||||
import org.antlr.v4.runtime.tree.*;
|
|
||||||
|
|
||||||
public class CKEnumsRunner {
|
|
||||||
|
|
||||||
private static List<Enum_t> getProg(String infile) throws Exception {
|
|
||||||
CKCommonHelper.InputFilePair pair = CKCommonHelper.openInputFile(infile);
|
|
||||||
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
|
||||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
|
||||||
CKEnumParser parser = new CKEnumParser(tokens);
|
|
||||||
|
|
||||||
ParseTree tree = parser.prog();
|
|
||||||
ParseTreeWalker walker = new ParseTreeWalker();
|
|
||||||
EnumWalker worker = new EnumWalker(tokens);
|
|
||||||
walker.walk(worker, tree);
|
|
||||||
|
|
||||||
pair.mUnderlyingStream.close();
|
|
||||||
return worker.getResult();
|
|
||||||
}
|
|
||||||
public static void run(String inCk2Enums, String inVxEnums, String outEnums, String outAccessibleValues) throws Exception {
|
|
||||||
List<Enum_t> ck2prog = getProg(inCk2Enums);
|
|
||||||
List<Enum_t> vxprog = getProg(inVxEnums);
|
|
||||||
|
|
||||||
OutputStreamWriter fs = CKCommonHelper.openOutputFile(outEnums);
|
|
||||||
EnumWriter.writeEnums(fs, ck2prog, vxprog);
|
|
||||||
fs.close();
|
|
||||||
|
|
||||||
fs = CKCommonHelper.openOutputFile(outAccessibleValues);
|
|
||||||
EnumWriter.writeAccessibleValues(fs, ck2prog, vxprog);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,196 +0,0 @@
|
||||||
// Generated from CKGeneralLexer.g4 by ANTLR 4.13.0
|
|
||||||
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"})
|
|
||||||
public class CKGeneralLexer extends Lexer {
|
|
||||||
static { RuntimeMetaData.checkVersion("4.13.0", RuntimeMetaData.VERSION); }
|
|
||||||
|
|
||||||
protected static final DFA[] _decisionToDFA;
|
|
||||||
protected static final PredictionContextCache _sharedContextCache =
|
|
||||||
new PredictionContextCache();
|
|
||||||
public static final int
|
|
||||||
CKGENERAL_TYPEDEF=1, CKGENERAL_DEFINE=2, CKGENERAL_ENUM=3, CKGENERAL_LBRACKET=4,
|
|
||||||
CKGENERAL_RBRACKET=5, CKGENERAL_EQUAL=6, CKGENERAL_SEMICOLON=7, CKGENERAL_LSHIFT=8,
|
|
||||||
CKGENERAL_OR=9, CKGENERAL_COMMA=10, CKGENERAL_ID=11, CKGENERAL_NUM=12,
|
|
||||||
CKGENERAL_LINE_COMMENT=13, CKGENERAL_BLOCK_COMMENT=14, CKGENERAL_WS=15;
|
|
||||||
public static final int
|
|
||||||
COMMENTS=2, WHITESPACE=3;
|
|
||||||
public static String[] channelNames = {
|
|
||||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN", "COMMENTS", "WHITESPACE"
|
|
||||||
};
|
|
||||||
|
|
||||||
public static String[] modeNames = {
|
|
||||||
"DEFAULT_MODE"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static String[] makeRuleNames() {
|
|
||||||
return new String[] {
|
|
||||||
"CKGENERAL_TYPEDEF", "CKGENERAL_DEFINE", "CKGENERAL_ENUM", "CKGENERAL_LBRACKET",
|
|
||||||
"CKGENERAL_RBRACKET", "CKGENERAL_EQUAL", "CKGENERAL_SEMICOLON", "CKGENERAL_LSHIFT",
|
|
||||||
"CKGENERAL_OR", "CKGENERAL_COMMA", "CKGENERAL_ID", "CKGENERAL_NUM", "CKGENERAL_LINE_COMMENT",
|
|
||||||
"CKGENERAL_BLOCK_COMMENT", "CKGENERAL_WS"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static final String[] ruleNames = makeRuleNames();
|
|
||||||
|
|
||||||
private static String[] makeLiteralNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "'typedef'", "'#define'", "'enum'", "'{'", "'}'", "'='", "';'",
|
|
||||||
"'<<'", "'|'", "','"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
||||||
private static String[] makeSymbolicNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "CKGENERAL_TYPEDEF", "CKGENERAL_DEFINE", "CKGENERAL_ENUM", "CKGENERAL_LBRACKET",
|
|
||||||
"CKGENERAL_RBRACKET", "CKGENERAL_EQUAL", "CKGENERAL_SEMICOLON", "CKGENERAL_LSHIFT",
|
|
||||||
"CKGENERAL_OR", "CKGENERAL_COMMA", "CKGENERAL_ID", "CKGENERAL_NUM", "CKGENERAL_LINE_COMMENT",
|
|
||||||
"CKGENERAL_BLOCK_COMMENT", "CKGENERAL_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 CKGeneralLexer(CharStream input) {
|
|
||||||
super(input);
|
|
||||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGrammarFileName() { return "CKGeneralLexer.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\u000fz\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
|
||||||
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
|
|
||||||
"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+
|
|
||||||
"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+
|
|
||||||
"\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0001"+
|
|
||||||
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001"+
|
|
||||||
"\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
|
||||||
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+
|
|
||||||
"\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004\u0001"+
|
|
||||||
"\u0004\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0007\u0001"+
|
|
||||||
"\u0007\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\n\u0001\n\u0005"+
|
|
||||||
"\nF\b\n\n\n\f\nI\t\n\u0001\u000b\u0001\u000b\u0001\u000b\u0003\u000bN"+
|
|
||||||
"\b\u000b\u0001\u000b\u0004\u000bQ\b\u000b\u000b\u000b\f\u000bR\u0001\u000b"+
|
|
||||||
"\u0005\u000bV\b\u000b\n\u000b\f\u000bY\t\u000b\u0001\f\u0001\f\u0001\f"+
|
|
||||||
"\u0001\f\u0005\f_\b\f\n\f\f\fb\t\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001"+
|
|
||||||
"\r\u0001\r\u0005\rj\b\r\n\r\f\rm\t\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001"+
|
|
||||||
"\r\u0001\u000e\u0004\u000eu\b\u000e\u000b\u000e\f\u000ev\u0001\u000e\u0001"+
|
|
||||||
"\u000e\u0001k\u0000\u000f\u0001\u0001\u0003\u0002\u0005\u0003\u0007\u0004"+
|
|
||||||
"\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u000b\u0017"+
|
|
||||||
"\f\u0019\r\u001b\u000e\u001d\u000f\u0001\u0000\u0007\u0003\u0000AZ__a"+
|
|
||||||
"z\u0004\u000009AZ__az\u0002\u0000XXxx\u0003\u000009AFaf\u0004\u0000LL"+
|
|
||||||
"UUlluu\u0002\u0000\n\n\r\r\u0003\u0000\t\n\r\r \u0081\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\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u0000\u001b\u0001\u0000\u0000\u0000\u0000\u001d\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u0001\u001f\u0001\u0000\u0000\u0000\u0003\'\u0001\u0000\u0000\u0000"+
|
|
||||||
"\u0005/\u0001\u0000\u0000\u0000\u00074\u0001\u0000\u0000\u0000\t6\u0001"+
|
|
||||||
"\u0000\u0000\u0000\u000b8\u0001\u0000\u0000\u0000\r:\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u000f<\u0001\u0000\u0000\u0000\u0011?\u0001\u0000\u0000\u0000\u0013"+
|
|
||||||
"A\u0001\u0000\u0000\u0000\u0015C\u0001\u0000\u0000\u0000\u0017M\u0001"+
|
|
||||||
"\u0000\u0000\u0000\u0019Z\u0001\u0000\u0000\u0000\u001be\u0001\u0000\u0000"+
|
|
||||||
"\u0000\u001dt\u0001\u0000\u0000\u0000\u001f \u0005t\u0000\u0000 !\u0005"+
|
|
||||||
"y\u0000\u0000!\"\u0005p\u0000\u0000\"#\u0005e\u0000\u0000#$\u0005d\u0000"+
|
|
||||||
"\u0000$%\u0005e\u0000\u0000%&\u0005f\u0000\u0000&\u0002\u0001\u0000\u0000"+
|
|
||||||
"\u0000\'(\u0005#\u0000\u0000()\u0005d\u0000\u0000)*\u0005e\u0000\u0000"+
|
|
||||||
"*+\u0005f\u0000\u0000+,\u0005i\u0000\u0000,-\u0005n\u0000\u0000-.\u0005"+
|
|
||||||
"e\u0000\u0000.\u0004\u0001\u0000\u0000\u0000/0\u0005e\u0000\u000001\u0005"+
|
|
||||||
"n\u0000\u000012\u0005u\u0000\u000023\u0005m\u0000\u00003\u0006\u0001\u0000"+
|
|
||||||
"\u0000\u000045\u0005{\u0000\u00005\b\u0001\u0000\u0000\u000067\u0005}"+
|
|
||||||
"\u0000\u00007\n\u0001\u0000\u0000\u000089\u0005=\u0000\u00009\f\u0001"+
|
|
||||||
"\u0000\u0000\u0000:;\u0005;\u0000\u0000;\u000e\u0001\u0000\u0000\u0000"+
|
|
||||||
"<=\u0005<\u0000\u0000=>\u0005<\u0000\u0000>\u0010\u0001\u0000\u0000\u0000"+
|
|
||||||
"?@\u0005|\u0000\u0000@\u0012\u0001\u0000\u0000\u0000AB\u0005,\u0000\u0000"+
|
|
||||||
"B\u0014\u0001\u0000\u0000\u0000CG\u0007\u0000\u0000\u0000DF\u0007\u0001"+
|
|
||||||
"\u0000\u0000ED\u0001\u0000\u0000\u0000FI\u0001\u0000\u0000\u0000GE\u0001"+
|
|
||||||
"\u0000\u0000\u0000GH\u0001\u0000\u0000\u0000H\u0016\u0001\u0000\u0000"+
|
|
||||||
"\u0000IG\u0001\u0000\u0000\u0000JK\u00050\u0000\u0000KN\u0007\u0002\u0000"+
|
|
||||||
"\u0000LN\u0005-\u0000\u0000MJ\u0001\u0000\u0000\u0000ML\u0001\u0000\u0000"+
|
|
||||||
"\u0000MN\u0001\u0000\u0000\u0000NP\u0001\u0000\u0000\u0000OQ\u0007\u0003"+
|
|
||||||
"\u0000\u0000PO\u0001\u0000\u0000\u0000QR\u0001\u0000\u0000\u0000RP\u0001"+
|
|
||||||
"\u0000\u0000\u0000RS\u0001\u0000\u0000\u0000SW\u0001\u0000\u0000\u0000"+
|
|
||||||
"TV\u0007\u0004\u0000\u0000UT\u0001\u0000\u0000\u0000VY\u0001\u0000\u0000"+
|
|
||||||
"\u0000WU\u0001\u0000\u0000\u0000WX\u0001\u0000\u0000\u0000X\u0018\u0001"+
|
|
||||||
"\u0000\u0000\u0000YW\u0001\u0000\u0000\u0000Z[\u0005/\u0000\u0000[\\\u0005"+
|
|
||||||
"/\u0000\u0000\\`\u0001\u0000\u0000\u0000]_\b\u0005\u0000\u0000^]\u0001"+
|
|
||||||
"\u0000\u0000\u0000_b\u0001\u0000\u0000\u0000`^\u0001\u0000\u0000\u0000"+
|
|
||||||
"`a\u0001\u0000\u0000\u0000ac\u0001\u0000\u0000\u0000b`\u0001\u0000\u0000"+
|
|
||||||
"\u0000cd\u0006\f\u0000\u0000d\u001a\u0001\u0000\u0000\u0000ef\u0005/\u0000"+
|
|
||||||
"\u0000fg\u0005*\u0000\u0000gk\u0001\u0000\u0000\u0000hj\t\u0000\u0000"+
|
|
||||||
"\u0000ih\u0001\u0000\u0000\u0000jm\u0001\u0000\u0000\u0000kl\u0001\u0000"+
|
|
||||||
"\u0000\u0000ki\u0001\u0000\u0000\u0000ln\u0001\u0000\u0000\u0000mk\u0001"+
|
|
||||||
"\u0000\u0000\u0000no\u0005*\u0000\u0000op\u0005/\u0000\u0000pq\u0001\u0000"+
|
|
||||||
"\u0000\u0000qr\u0006\r\u0000\u0000r\u001c\u0001\u0000\u0000\u0000su\u0007"+
|
|
||||||
"\u0006\u0000\u0000ts\u0001\u0000\u0000\u0000uv\u0001\u0000\u0000\u0000"+
|
|
||||||
"vt\u0001\u0000\u0000\u0000vw\u0001\u0000\u0000\u0000wx\u0001\u0000\u0000"+
|
|
||||||
"\u0000xy\u0006\u000e\u0001\u0000y\u001e\u0001\u0000\u0000\u0000\b\u0000"+
|
|
||||||
"GMRW`kv\u0002\u0000\u0002\u0000\u0000\u0003\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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
public class CKMain {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
CKEnumRunner.run("src/CKENUMS.txt", "src/VXENUMS.txt", "dest/CKEnums.gen.hpp", "dest/AccessibleValue.gen.hpp");
|
|
||||||
System.out.println("DONE!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +1,120 @@
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
import org.antlr.v4.runtime.tree.*;
|
import org.antlr.v4.runtime.tree.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The specialized walker for collecting CK_CLASSID and its inherit relationship.
|
* The specialized walker for collecting CK_CLASSID and its inherit
|
||||||
|
* relationship.
|
||||||
*/
|
*/
|
||||||
public class ClassidWalker extends CKDefinesParserBaseListener {
|
public class ClassidWalker extends CKDefinesParserBaseListener {
|
||||||
|
|
||||||
|
public ClassidWalker(BufferedTokenStream tokenStream) {
|
||||||
|
mTokenStream = tokenStream;
|
||||||
|
mResult = null;
|
||||||
|
|
||||||
|
mLevelStack = null;
|
||||||
|
mCurrentEnum = null;
|
||||||
|
mCurrentEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumsHelper.Enum_t getEnum() {
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getClassidLevel(Token defineHead) {
|
||||||
|
Token ws = CommonHelper.getPreChannelToken(mTokenStream, defineHead, CKGeneralLexer.WHITESPACE);
|
||||||
|
if (ws == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// reverse finding how many tab used.
|
||||||
|
int counter = 0;
|
||||||
|
char[] wstxt = ws.getText().toCharArray();
|
||||||
|
for (int i = wstxt.length - 1; i >= 0; i--) {
|
||||||
|
if (wstxt[i] == '\t') {
|
||||||
|
counter++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void safePop() {
|
||||||
|
if (mLevelStack.size() != 0)
|
||||||
|
mLevelStack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void safePopTimes(int times) {
|
||||||
|
for (int i = 0; i < times; i++) {
|
||||||
|
if (mLevelStack.size() != 0)
|
||||||
|
mLevelStack.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferedTokenStream mTokenStream;
|
||||||
|
private EnumsHelper.Enum_t mResult;
|
||||||
|
|
||||||
|
private int mLevel;
|
||||||
|
private Stack<EnumsHelper.EnumEntryWithHierarchy_t> mLevelStack;
|
||||||
|
private EnumsHelper.Enum_t mCurrentEnum;
|
||||||
|
private EnumsHelper.EnumEntryWithHierarchy_t mCurrentEntry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enterProg(CKDefinesParser.ProgContext ctx) {
|
public void enterProg(CKDefinesParser.ProgContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
mLevel = 0;
|
||||||
super.enterProg(ctx);
|
mLevelStack = new Stack<EnumsHelper.EnumEntryWithHierarchy_t>();
|
||||||
|
mCurrentEnum = new EnumsHelper.Enum_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitProg(CKDefinesParser.ProgContext ctx) {
|
public void exitProg(CKDefinesParser.ProgContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
mLevel = 0;
|
||||||
super.exitProg(ctx);
|
mLevelStack = null;
|
||||||
|
|
||||||
|
// classid is signed int and do not have flags feature.
|
||||||
|
mCurrentEnum.mCanUnsigned = false;
|
||||||
|
mCurrentEnum.mUseFlags = false;
|
||||||
|
mResult = mCurrentEnum;
|
||||||
|
mCurrentEnum = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enterDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
||||||
|
mCurrentEntry = new EnumsHelper.EnumEntryWithHierarchy_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
public void exitDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
// fill entry info
|
||||||
super.exitDefinePair(ctx);
|
mCurrentEntry.mEntryName = ctx.CKGENERAL_ID(0).getText();
|
||||||
|
mCurrentEntry.mEntryValue = ctx.CKGENERAL_NUM().getText();
|
||||||
|
|
||||||
|
// fill entry level info
|
||||||
|
int this_level = getClassidLevel(ctx.getStart());
|
||||||
|
if (this_level > mLevel) {
|
||||||
|
// level up
|
||||||
|
mLevel++;
|
||||||
|
|
||||||
|
mLevelStack.push(mCurrentEntry);
|
||||||
|
mCurrentEntry.mHierarchy.addAll(mLevelStack);
|
||||||
|
} else if (this_level == mLevel) {
|
||||||
|
safePop();
|
||||||
|
mLevelStack.push(mCurrentEntry);
|
||||||
|
mCurrentEntry.mHierarchy.addAll(mLevelStack);
|
||||||
|
} else if (this_level < mLevel) {
|
||||||
|
// level down
|
||||||
|
safePopTimes(mLevel - this_level + 1);
|
||||||
|
mLevel = this_level;
|
||||||
|
|
||||||
|
mLevelStack.push(mCurrentEntry);
|
||||||
|
mCurrentEntry.mHierarchy.addAll(mLevelStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
// move to list
|
||||||
|
mCurrentEnum.mEntries.add(mCurrentEntry);
|
||||||
|
mCurrentEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,41 @@
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The accessible values writer of CK_CLASSID.
|
* The accessible values writer of CK_CLASSID.
|
||||||
*/
|
*/
|
||||||
public class ClassidWriter {
|
public class ClassidWriter {
|
||||||
|
public static void writeClassids(OutputStreamWriter writer, EnumsHelper.Enum_t classids) throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer);
|
||||||
|
indent.puts("#pragma once");
|
||||||
|
indent.puts("#include \"CKEnums.hpp\"");
|
||||||
|
indent.puts("#include <cstdint>");
|
||||||
|
indent.puts("#include <string>");
|
||||||
|
indent.puts("#include <vector>");
|
||||||
|
indent.puts("namespace Unvirt::AccessibleValue::EnumReflection {");
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
indent.puts("struct CkClassidReflection { std::vector<const char*> mHierarchy; };");
|
||||||
|
indent.puts("using CkClassidReflectionArray = std::vector<std::pair<LibCmo::CK2::CK_CLASSID, CkClassidReflection>>;");
|
||||||
|
|
||||||
|
indent.puts("namespace CK2 {");
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
indent.puts("const CkClassidReflectionArray CK_CLASSID {");
|
||||||
|
indent.inc();
|
||||||
|
for (EnumsHelper.EnumEntry_t entry : classids.mEntries) {
|
||||||
|
EnumsHelper.EnumEntryWithHierarchy_t specialized = (EnumsHelper.EnumEntryWithHierarchy_t)entry;
|
||||||
|
|
||||||
|
String hierarchy = specialized.mHierarchy.stream().map(value -> value.mEntryName).collect(Collectors.joining("\", \""));
|
||||||
|
indent.printf("{ LibCmo::CK2::CK_CLASSID::%s, { { \"%s\" } } },", entry.mEntryName, hierarchy);
|
||||||
|
}
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,23 +6,68 @@ import org.antlr.v4.runtime.tree.*;
|
||||||
* The generic walker for collecting defines as a enum.
|
* The generic walker for collecting defines as a enum.
|
||||||
*/
|
*/
|
||||||
public class DefinesWalker extends CKDefinesParserBaseListener {
|
public class DefinesWalker extends CKDefinesParserBaseListener {
|
||||||
|
public DefinesWalker(BufferedTokenStream tokenStream) {
|
||||||
|
mCommentsFinder = new CommentsFinder(tokenStream);
|
||||||
|
mResult = null;
|
||||||
|
|
||||||
|
mCurrentEnum = null;
|
||||||
|
mCurrentEntry = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumsHelper.Enum_t getEnum() {
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommentsFinder mCommentsFinder;
|
||||||
|
private EnumsHelper.Enum_t mResult;
|
||||||
|
|
||||||
|
private EnumsHelper.Enum_t mCurrentEnum;
|
||||||
|
private EnumsHelper.EnumEntry_t mCurrentEntry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enterProg(CKDefinesParser.ProgContext ctx) {
|
public void enterProg(CKDefinesParser.ProgContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
mCurrentEnum = new EnumsHelper.Enum_t();
|
||||||
super.enterProg(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitProg(CKDefinesParser.ProgContext ctx) {
|
public void exitProg(CKDefinesParser.ProgContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
mResult = mCurrentEnum;
|
||||||
super.exitProg(ctx);
|
mCurrentEnum = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enterDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
||||||
|
mCurrentEntry = new EnumsHelper.EnumEntry_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
public void exitDefinePair(CKDefinesParser.DefinePairContext ctx) {
|
||||||
// TODO Auto-generated method stub
|
// set values
|
||||||
super.exitDefinePair(ctx);
|
mCurrentEntry.mEntryName = ctx.CKGENERAL_ID(0).getText();
|
||||||
|
mCurrentEntry.mEntryComment = mCommentsFinder.getComment(ctx.getStart(), ctx.getStop());
|
||||||
|
|
||||||
|
if (ctx.CKGENERAL_NUM() == null) {
|
||||||
|
// define with id
|
||||||
|
mCurrentEntry.mEntryValue = ctx.CKGENERAL_ID(1).getText();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// define with number
|
||||||
|
String num = ctx.CKGENERAL_NUM().getText();
|
||||||
|
mCurrentEntry.mEntryValue = num;
|
||||||
|
|
||||||
|
// check whether this enum can be unsigned
|
||||||
|
if (CommonHelper.isNegativeNumber(num)) {
|
||||||
|
mCurrentEnum.mCanUnsigned = false;
|
||||||
|
}
|
||||||
|
// if the number is in hex form, this enum MIGHT have flags feature
|
||||||
|
if (CommonHelper.isHexNumber(num)) {
|
||||||
|
mCurrentEnum.mUseFlags = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// add entry
|
||||||
|
mCurrentEnum.mEntries.add(mCurrentEntry);
|
||||||
|
mCurrentEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,20 @@ public class EnumsHelper {
|
||||||
public String mEntryValue; ///< The value of this entry. null if this entry do not have explicit value.
|
public String mEntryValue; ///< The value of this entry. null if this entry do not have explicit value.
|
||||||
public String mEntryComment; ///< The comment of this entry. null if no comment.
|
public String mEntryComment; ///< The comment of this entry. null if no comment.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The specialized EnumEntry type which can store extra hierarchy info.
|
||||||
|
* Used in CK_CLASSID parsing.
|
||||||
|
*/
|
||||||
|
public static class EnumEntryWithHierarchy_t extends EnumEntry_t {
|
||||||
|
public EnumEntryWithHierarchy_t() {
|
||||||
|
super();
|
||||||
|
mHierarchy = new Vector<EnumEntryWithHierarchy_t>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector<EnumEntryWithHierarchy_t> mHierarchy; ///< The list to store this CK_CLASSID inheritance relationship.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The struct to describe an enum.
|
* The struct to describe an enum.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class EnumsWalker extends CKEnumsParserBaseListener {
|
||||||
case 2: {
|
case 2: {
|
||||||
// set value
|
// set value
|
||||||
TerminalNode num = nums.get(0), offset = nums.get(1);
|
TerminalNode num = nums.get(0), offset = nums.get(1);
|
||||||
mCurrentEntry.mEntryValue = String.format("{} << {}", num.getText(), offset.getText());
|
mCurrentEntry.mEntryValue = String.format("%s << %s", num.getText(), offset.getText());
|
||||||
|
|
||||||
// << operator appears. this enum must have flags feature
|
// << operator appears. this enum must have flags feature
|
||||||
mCurrentEnum.mUseFlags = true;
|
mCurrentEnum.mUseFlags = true;
|
||||||
|
|
|
@ -56,14 +56,14 @@ public class EnumsWriter {
|
||||||
EnumsHelper.EnumCollection_t prog) throws Exception {
|
EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
// write enum desc header
|
// write enum desc header
|
||||||
indent.printf("const EnumNameofArray<LibCmo::%s::%s> {} {", CommonHelper.getCKPartsNamespace(parts),
|
indent.printf("const GeneralReflectionArray<LibCmo::%s::%s> %s {", CommonHelper.getCKPartsNamespace(parts),
|
||||||
enum_t.mEnumName, enum_t.mEnumName);
|
enum_t.mEnumName, enum_t.mEnumName);
|
||||||
indent.inc();
|
indent.inc();
|
||||||
|
|
||||||
// write enum desc entries
|
// write enum desc entries
|
||||||
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
indent.printf("{ LibCmo::%s::%s::%s, \"%s\" },", parts, enum_t.mEnumName, enumEntry_t.mEntryName,
|
indent.printf("{ LibCmo::%s::%s::%s, {\"%s\"} },", CommonHelper.getCKPartsNamespace(parts),
|
||||||
enumEntry_t.mEntryName);
|
enum_t.mEnumName, enumEntry_t.mEntryName, enumEntry_t.mEntryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write enum tail
|
// write enum tail
|
||||||
|
@ -80,9 +80,13 @@ public class EnumsWriter {
|
||||||
indent.puts("#include <cstdint>");
|
indent.puts("#include <cstdint>");
|
||||||
indent.puts("#include <string>");
|
indent.puts("#include <string>");
|
||||||
indent.puts("#include <vector>");
|
indent.puts("#include <vector>");
|
||||||
indent.puts("namespace Unvirt::AccessibleValue::EnumDesc {");
|
indent.puts("namespace Unvirt::AccessibleValue::EnumReflection {");
|
||||||
indent.inc();
|
indent.inc();
|
||||||
|
|
||||||
|
indent.puts("struct GeneralReflection { const char* mName; };");
|
||||||
|
indent.puts("template<typename _Ty>;");
|
||||||
|
indent.puts("using GeneralReflectionArray = std::vector<std::pair<TEnum, GeneralReflection>>;");
|
||||||
|
|
||||||
indent.puts("namespace CK2 {");
|
indent.puts("namespace CK2 {");
|
||||||
indent.inc();
|
indent.inc();
|
||||||
writeAccessibleValue(indent, CommonHelper.CKParts.CK2, ck2_prog);
|
writeAccessibleValue(indent, CommonHelper.CKParts.CK2, ck2_prog);
|
||||||
|
|
|
@ -1,7 +1,42 @@
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The accessible values writer of CKERROR
|
* The accessible values writer of CKERROR
|
||||||
*/
|
*/
|
||||||
public class ErrorsWriter {
|
public class ErrorsWriter {
|
||||||
|
public static void writeErrors(OutputStreamWriter writer, EnumsHelper.Enum_t errors) throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer);
|
||||||
|
indent.puts("#pragma once");
|
||||||
|
indent.puts("#include \"CKEnums.hpp\"");
|
||||||
|
indent.puts("#include <cstdint>");
|
||||||
|
indent.puts("#include <string>");
|
||||||
|
indent.puts("#include <vector>");
|
||||||
|
indent.puts("namespace Unvirt::AccessibleValue::EnumReflection {");
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
indent.puts("struct CkErrorReflection { const char* mName; const char* mDescription; };");
|
||||||
|
indent.puts("using CkErrorReflectionArray = std::vector<std::pair<LibCmo::CK2::CKERROR, CkErrorReflection>>;");
|
||||||
|
|
||||||
|
indent.puts("namespace CK2 {");
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
indent.puts("const CkErrorReflectionArray CKERROR {");
|
||||||
|
indent.inc();
|
||||||
|
for (EnumsHelper.EnumEntry_t entry : errors.mEntries) {
|
||||||
|
String comment = CommonHelper.escapeString(entry.mEntryComment);
|
||||||
|
if (comment == null)
|
||||||
|
comment = "";
|
||||||
|
|
||||||
|
indent.printf("{ LibCmo::CK2::CKERROR::%s, { \"%s\", \"%s\" } },", entry.mEntryName, entry.mEntryName,
|
||||||
|
comment);
|
||||||
|
}
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,13 @@ public class IndentHelper {
|
||||||
mWriter.write(String.format(fmt, args));
|
mWriter.write(String.format(fmt, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write standard Doxygen document comment.
|
||||||
|
* <p>
|
||||||
|
* Usually be called before writing content.
|
||||||
|
* @param comment
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public void briefComment(String comment) throws Exception {
|
public void briefComment(String comment) throws Exception {
|
||||||
if (comment == null)
|
if (comment == null)
|
||||||
return;
|
return;
|
||||||
|
@ -42,6 +49,13 @@ public class IndentHelper {
|
||||||
puts(" */");
|
puts(" */");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write suffix style Doxygen document comment.
|
||||||
|
* <p>
|
||||||
|
* Usually be called after writing content.
|
||||||
|
* @param comment
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public void afterMemberComment(String comment) throws Exception {
|
public void afterMemberComment(String comment) throws Exception {
|
||||||
if (comment == null)
|
if (comment == null)
|
||||||
return;
|
return;
|
||||||
|
|
95
CodeGen/MainRunner.java
Normal file
95
CodeGen/MainRunner.java
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
|
import org.antlr.v4.runtime.*;
|
||||||
|
import org.antlr.v4.runtime.tree.*;
|
||||||
|
|
||||||
|
public class MainRunner {
|
||||||
|
|
||||||
|
private static EnumsHelper.EnumCollection_t getEnumsCollection(String infile) throws Exception {
|
||||||
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
|
CKEnumsParser parser = new CKEnumsParser(tokens);
|
||||||
|
|
||||||
|
ParseTree tree = parser.prog();
|
||||||
|
ParseTreeWalker walker = new ParseTreeWalker();
|
||||||
|
EnumsWalker worker = new EnumsWalker(tokens);
|
||||||
|
walker.walk(worker, tree);
|
||||||
|
|
||||||
|
pair.mUnderlyingStream.close();
|
||||||
|
return worker.getEnums();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EnumsHelper.Enum_t organiseDefines(String infile, String assignedEnumName) throws Exception {
|
||||||
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
|
CKDefinesParser parser = new CKDefinesParser(tokens);
|
||||||
|
|
||||||
|
ParseTree tree = parser.prog();
|
||||||
|
ParseTreeWalker walker = new ParseTreeWalker();
|
||||||
|
DefinesWalker worker = new DefinesWalker(tokens);
|
||||||
|
walker.walk(worker, tree);
|
||||||
|
|
||||||
|
pair.mUnderlyingStream.close();
|
||||||
|
|
||||||
|
EnumsHelper.Enum_t result = worker.getEnum();
|
||||||
|
result.mEnumName = assignedEnumName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EnumsHelper.Enum_t organiseClassid(String infile, String assignedEnumName) throws Exception {
|
||||||
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
|
CKDefinesParser parser = new CKDefinesParser(tokens);
|
||||||
|
|
||||||
|
ParseTree tree = parser.prog();
|
||||||
|
ParseTreeWalker walker = new ParseTreeWalker();
|
||||||
|
ClassidWalker worker = new ClassidWalker(tokens);
|
||||||
|
walker.walk(worker, tree);
|
||||||
|
|
||||||
|
pair.mUnderlyingStream.close();
|
||||||
|
|
||||||
|
EnumsHelper.Enum_t result = worker.getEnum();
|
||||||
|
result.mEnumName = assignedEnumName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// read ck2 and vxmath enum first.
|
||||||
|
// these files are originally is defined as enum
|
||||||
|
EnumsHelper.EnumCollection_t ck2Enums = getEnumsCollection("src/CKENUMS.txt"),
|
||||||
|
vxmathEnums = getEnumsCollection("src/VXENUMS.txt");
|
||||||
|
OutputStreamWriter fs = null;
|
||||||
|
// read define series and reorgainse it as a enum
|
||||||
|
// create independent classid and ckerror for specialized processing.
|
||||||
|
EnumsHelper.Enum_t classid = organiseClassid("src/CK_CLASSID.txt", "CK_CLASSID"),
|
||||||
|
ckerror = organiseDefines("src/CKERROR.txt", "CKERROR");
|
||||||
|
ck2Enums.mEnums.add(organiseDefines("src/CK_STATECHUNK_CHUNKVERSION.txt", "CK_STATECHUNK_CHUNKVERSION"));
|
||||||
|
ck2Enums.mEnums.add(organiseDefines("src/CK_STATECHUNK_DATAVERSION.txt", "CK_STATECHUNK_DATAVERSION"));
|
||||||
|
|
||||||
|
// write accessible value, except classid and ckerror.
|
||||||
|
fs = CommonHelper.openOutputFile("../Unvirt/Generated/Enums.gen.hpp");
|
||||||
|
EnumsWriter.writeAccessibleValues(fs, ck2Enums, vxmathEnums);
|
||||||
|
fs.close();
|
||||||
|
// class id and ckerror need special writer.
|
||||||
|
fs = CommonHelper.openOutputFile("../Unvirt/Generated/CkError.gen.hpp");
|
||||||
|
ErrorsWriter.writeErrors(fs, ckerror);
|
||||||
|
fs.close();
|
||||||
|
fs = CommonHelper.openOutputFile("../Unvirt/Generated/CkClassid.gen.hpp");
|
||||||
|
ClassidWriter.writeClassids(fs, classid);
|
||||||
|
fs.close();
|
||||||
|
|
||||||
|
// re-add classid and ckerror enum data.
|
||||||
|
// write ck2 and vxmath enum into file
|
||||||
|
ck2Enums.mEnums.add(ckerror);
|
||||||
|
ck2Enums.mEnums.add(classid);
|
||||||
|
fs = CommonHelper.openOutputFile("../LibCmo/Generated/Enums.gen.hpp");
|
||||||
|
EnumsWriter.writeEnums(fs, ck2Enums, vxmathEnums);
|
||||||
|
fs.close();
|
||||||
|
|
||||||
|
// print message.
|
||||||
|
System.out.println("DONE!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -76,30 +76,9 @@ typedef enum CK_PLUGIN_TYPE {
|
||||||
CKPLUGIN_EXTENSION_DLL = 7, // Generic extension (definition of new parameter types or operations for ex.)
|
CKPLUGIN_EXTENSION_DLL = 7, // Generic extension (definition of new parameter types or operations for ex.)
|
||||||
} CK_PLUGIN_TYPE;
|
} CK_PLUGIN_TYPE;
|
||||||
|
|
||||||
enum CK_STATECHUNK_DATAVERSION {
|
/***************************************************
|
||||||
CHUNKDATA_OLDVERSION= 0, // Before any version was saved
|
CHUNK_OPTIONS in Virtools header.
|
||||||
CHUNKDATA_BASEVERSION= 1, // First version
|
*************************************************/
|
||||||
CHUNK_WAVESOUND_VERSION2= 2, // Changes in wavesound format
|
|
||||||
CHUNK_WAVESOUND_VERSION3= 3, // Changes in wavesound format
|
|
||||||
CHUNK_MATERIAL_VERSION_ZTEST= 4, // Change in material save format
|
|
||||||
CHUNK_MAJORCHANGE_VERSION= 5, // Optimisations on many save functions
|
|
||||||
CHUNK_MACCHANGE_VERSION= 6, // Misc new Statechunk functions for macintosh (Big-Endian <-> Little Endian conversion )
|
|
||||||
CHUNK_WAVESOUND_VERSION4= 7, // Changes in wavesound format (Added sound length)
|
|
||||||
CHUNK_SCENECHANGE_VERSION= 8, // Changes in sceneObjectDesc format (Remove lasttimevalue)
|
|
||||||
CHUNK_MESHCHANGE_VERSION= 9, // Changes in Mesh save format (primitives)
|
|
||||||
CHUNK_DEV_2_1= 10, // Changes in wavesound reading of inside, outside angles
|
|
||||||
|
|
||||||
CHUNKDATA_CURRENTVERSION= CHUNK_DEV_2_1 ,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CK_STATECHUNK_CHUNKVERSION {
|
|
||||||
CHUNK_VERSIONBASE= 0,
|
|
||||||
CHUNK_VERSION1= 4, // equal to file version : WriteObjectID => table
|
|
||||||
CHUNK_VERSION2= 5, // add Manager Data
|
|
||||||
CHUNK_VERSION3= 6, // New ConvertToBuffer / ReadFromBuffer (file system changed to reflect this )
|
|
||||||
CHUNK_VERSION4= 7, // New WriteObjectID when saving to a file
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CK_STATECHUNK_CHUNKOPTIONS {
|
enum CK_STATECHUNK_CHUNKOPTIONS {
|
||||||
CHNK_OPTION_IDS = 0x01, // IDS are stored inside chunk
|
CHNK_OPTION_IDS = 0x01, // IDS are stored inside chunk
|
||||||
CHNK_OPTION_MAN = 0x02, // Managers ints are store inside chunk
|
CHNK_OPTION_MAN = 0x02, // Managers ints are store inside chunk
|
||||||
|
|
6
CodeGen/src/CK_STATECHUNK_CHUNKVERSION.txt
Normal file
6
CodeGen/src/CK_STATECHUNK_CHUNKVERSION.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
#define CHUNK_VERSIONBASE 0
|
||||||
|
#define CHUNK_VERSION1 4 // equal to file version : WriteObjectID => table
|
||||||
|
#define CHUNK_VERSION2 5 // add Manager Data
|
||||||
|
#define CHUNK_VERSION3 6 // New ConvertToBuffer / ReadFromBuffer (file system changed to reflect this )
|
||||||
|
#define CHUNK_VERSION4 7 // New WriteObjectID when saving to a file
|
14
CodeGen/src/CK_STATECHUNK_DATAVERSION.txt
Normal file
14
CodeGen/src/CK_STATECHUNK_DATAVERSION.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
#define CHUNKDATA_OLDVERSION 0 // Before any version was saved
|
||||||
|
#define CHUNKDATA_BASEVERSION 1 // First version
|
||||||
|
#define CHUNK_WAVESOUND_VERSION2 2 // Changes in wavesound format
|
||||||
|
#define CHUNK_WAVESOUND_VERSION3 3 // Changes in wavesound format
|
||||||
|
#define CHUNK_MATERIAL_VERSION_ZTEST 4 // Change in material save format
|
||||||
|
#define CHUNK_MAJORCHANGE_VERSION 5 // Optimisations on many save functions
|
||||||
|
#define CHUNK_MACCHANGE_VERSION 6 // Misc new Statechunk functions for macintosh (Big-Endian <-> Little Endian conversion )
|
||||||
|
#define CHUNK_WAVESOUND_VERSION4 7 // Changes in wavesound format (Added sound length)
|
||||||
|
#define CHUNK_SCENECHANGE_VERSION 8 // Changes in sceneObjectDesc format (Remove lasttimevalue)
|
||||||
|
#define CHUNK_MESHCHANGE_VERSION 9 // Changes in Mesh save format (primitives)
|
||||||
|
#define CHUNK_DEV_2_1 10 // Changes in wavesound reading of inside, outside angles
|
||||||
|
|
||||||
|
#define CHUNKDATA_CURRENTVERSION CHUNK_DEV_2_1
|
0
LibCmo/Generated/.gitkeep
Normal file
0
LibCmo/Generated/.gitkeep
Normal file
0
Unvirt/Generated/.gitkeep
Normal file
0
Unvirt/Generated/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user