1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Added support for #undef. #169

This commit is contained in:
jespergravgaard 2020-04-05 18:06:06 +02:00
parent c4550b5aec
commit a01c6b5680
20 changed files with 978 additions and 869 deletions

View File

@ -1,9 +1,10 @@
package dk.camelot64.kickc.parser;
import dk.camelot64.kickc.SourceLoader;
import dk.camelot64.kickc.preprocessor.CTokenSourcePreprocessor;
import dk.camelot64.kickc.preprocessor.CPreprocessor;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.preprocessor.CPreprocessorTokens;
import org.antlr.v4.runtime.*;
import java.io.File;
@ -64,7 +65,8 @@ public class CParser {
this.program = program;
this.cFiles = new LinkedHashMap<>();
this.cTokenSource = new CTokenSource();
final CTokenSourcePreprocessor preprocessor = new CTokenSourcePreprocessor(cTokenSource, CHANNEL_WHITESPACE, KickCLexer.WS, KickCLexer.DEFINE, KickCLexer.NAME, KickCLexer.PAR_BEGIN, KickCLexer.PAR_END, KickCLexer.COMMA, KickCLexer.DEFINE_CONTINUE);
final CPreprocessorTokens preprocessorTokens = new CPreprocessorTokens(CHANNEL_WHITESPACE, KickCLexer.WS, KickCLexer.DEFINE, KickCLexer.NAME, KickCLexer.DEFINE_CONTINUE, KickCLexer.UNDEF, KickCLexer.PAR_BEGIN, KickCLexer.PAR_END, KickCLexer.COMMA);
final CPreprocessor preprocessor = new CPreprocessor(cTokenSource, preprocessorTokens);
this.tokenStream = new CommonTokenStream(preprocessor);
this.parser = new KickCParser(tokenStream, this);
this.typedefs = new ArrayList<>();

View File

@ -125,6 +125,7 @@ CHAR : '\'' ('\\'['"rfn] | ~'\'' ) '\'';
// Macros
DEFINE: '#define' ;
DEFINE_CONTINUE: '\\\n' ;
UNDEF: '#undef' ;
// Numbers
NUMBER : NUMFLOAT | NUMINT ;

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -94,55 +94,56 @@ STRING=93
CHAR=94
DEFINE=95
DEFINE_CONTINUE=96
NUMBER=97
NUMFLOAT=98
BINFLOAT=99
DECFLOAT=100
HEXFLOAT=101
NUMINT=102
BININTEGER=103
DECINTEGER=104
HEXINTEGER=105
NAME=106
WS=107
COMMENT_LINE=108
COMMENT_BLOCK=109
ASM_BYTE=110
ASM_MNEMONIC=111
ASM_IMM=112
ASM_COLON=113
ASM_COMMA=114
ASM_PAR_BEGIN=115
ASM_PAR_END=116
ASM_BRACKET_BEGIN=117
ASM_BRACKET_END=118
ASM_DOT=119
ASM_SHIFT_LEFT=120
ASM_SHIFT_RIGHT=121
ASM_PLUS=122
ASM_MINUS=123
ASM_LESS_THAN=124
ASM_GREATER_THAN=125
ASM_MULTIPLY=126
ASM_DIVIDE=127
ASM_CURLY_BEGIN=128
ASM_CURLY_END=129
ASM_NUMBER=130
ASM_NUMFLOAT=131
ASM_BINFLOAT=132
ASM_DECFLOAT=133
ASM_HEXFLOAT=134
ASM_NUMINT=135
ASM_BININTEGER=136
ASM_DECINTEGER=137
ASM_HEXINTEGER=138
ASM_CHAR=139
ASM_MULTI_REL=140
ASM_MULTI_NAME=141
ASM_NAME=142
ASM_WS=143
ASM_COMMENT_LINE=144
ASM_COMMENT_BLOCK=145
UNDEF=97
NUMBER=98
NUMFLOAT=99
BINFLOAT=100
DECFLOAT=101
HEXFLOAT=102
NUMINT=103
BININTEGER=104
DECINTEGER=105
HEXINTEGER=106
NAME=107
WS=108
COMMENT_LINE=109
COMMENT_BLOCK=110
ASM_BYTE=111
ASM_MNEMONIC=112
ASM_IMM=113
ASM_COLON=114
ASM_COMMA=115
ASM_PAR_BEGIN=116
ASM_PAR_END=117
ASM_BRACKET_BEGIN=118
ASM_BRACKET_END=119
ASM_DOT=120
ASM_SHIFT_LEFT=121
ASM_SHIFT_RIGHT=122
ASM_PLUS=123
ASM_MINUS=124
ASM_LESS_THAN=125
ASM_GREATER_THAN=126
ASM_MULTIPLY=127
ASM_DIVIDE=128
ASM_CURLY_BEGIN=129
ASM_CURLY_END=130
ASM_NUMBER=131
ASM_NUMFLOAT=132
ASM_BINFLOAT=133
ASM_DECFLOAT=134
ASM_HEXFLOAT=135
ASM_NUMINT=136
ASM_BININTEGER=137
ASM_DECINTEGER=138
ASM_HEXINTEGER=139
ASM_CHAR=140
ASM_MULTI_REL=141
ASM_MULTI_NAME=142
ASM_NAME=143
ASM_WS=144
ASM_COMMENT_LINE=145
ASM_COMMENT_BLOCK=146
';'=8
'..'=11
'?'=12
@ -213,5 +214,6 @@ ASM_COMMENT_BLOCK=145
'!'=88
'#define'=95
'\\\n'=96
'.byte'=110
'#'=112
'#undef'=97
'.byte'=111
'#'=113

File diff suppressed because one or more lines are too long

View File

@ -34,18 +34,18 @@ public class KickCParser extends Parser {
ASM=75, DEFAULT=76, CASE=77, STRUCT=78, ENUM=79, SIZEOF=80, TYPEID=81,
KICKASM=82, RESOURCE=83, USES=84, CLOBBERS=85, BYTES=86, CYCLES=87, LOGIC_NOT=88,
SIGNEDNESS=89, SIMPLETYPE=90, BOOLEAN=91, KICKASM_BODY=92, STRING=93,
CHAR=94, DEFINE=95, DEFINE_CONTINUE=96, NUMBER=97, NUMFLOAT=98, BINFLOAT=99,
DECFLOAT=100, HEXFLOAT=101, NUMINT=102, BININTEGER=103, DECINTEGER=104,
HEXINTEGER=105, NAME=106, WS=107, COMMENT_LINE=108, COMMENT_BLOCK=109,
ASM_BYTE=110, ASM_MNEMONIC=111, ASM_IMM=112, ASM_COLON=113, ASM_COMMA=114,
ASM_PAR_BEGIN=115, ASM_PAR_END=116, ASM_BRACKET_BEGIN=117, ASM_BRACKET_END=118,
ASM_DOT=119, ASM_SHIFT_LEFT=120, ASM_SHIFT_RIGHT=121, ASM_PLUS=122, ASM_MINUS=123,
ASM_LESS_THAN=124, ASM_GREATER_THAN=125, ASM_MULTIPLY=126, ASM_DIVIDE=127,
ASM_CURLY_BEGIN=128, ASM_CURLY_END=129, ASM_NUMBER=130, ASM_NUMFLOAT=131,
ASM_BINFLOAT=132, ASM_DECFLOAT=133, ASM_HEXFLOAT=134, ASM_NUMINT=135,
ASM_BININTEGER=136, ASM_DECINTEGER=137, ASM_HEXINTEGER=138, ASM_CHAR=139,
ASM_MULTI_REL=140, ASM_MULTI_NAME=141, ASM_NAME=142, ASM_WS=143, ASM_COMMENT_LINE=144,
ASM_COMMENT_BLOCK=145;
CHAR=94, DEFINE=95, DEFINE_CONTINUE=96, UNDEF=97, NUMBER=98, NUMFLOAT=99,
BINFLOAT=100, DECFLOAT=101, HEXFLOAT=102, NUMINT=103, BININTEGER=104,
DECINTEGER=105, HEXINTEGER=106, NAME=107, WS=108, COMMENT_LINE=109, COMMENT_BLOCK=110,
ASM_BYTE=111, ASM_MNEMONIC=112, ASM_IMM=113, ASM_COLON=114, ASM_COMMA=115,
ASM_PAR_BEGIN=116, ASM_PAR_END=117, ASM_BRACKET_BEGIN=118, ASM_BRACKET_END=119,
ASM_DOT=120, ASM_SHIFT_LEFT=121, ASM_SHIFT_RIGHT=122, ASM_PLUS=123, ASM_MINUS=124,
ASM_LESS_THAN=125, ASM_GREATER_THAN=126, ASM_MULTIPLY=127, ASM_DIVIDE=128,
ASM_CURLY_BEGIN=129, ASM_CURLY_END=130, ASM_NUMBER=131, ASM_NUMFLOAT=132,
ASM_BINFLOAT=133, ASM_DECFLOAT=134, ASM_HEXFLOAT=135, ASM_NUMINT=136,
ASM_BININTEGER=137, ASM_DECINTEGER=138, ASM_HEXINTEGER=139, ASM_CHAR=140,
ASM_MULTI_REL=141, ASM_MULTI_NAME=142, ASM_NAME=143, ASM_WS=144, ASM_COMMENT_LINE=145,
ASM_COMMENT_BLOCK=146;
public static final int
RULE_file = 0, RULE_asmFile = 1, RULE_declSeq = 2, RULE_declOrImport = 3,
RULE_importDecl = 4, RULE_decl = 5, RULE_declVariables = 6, RULE_declVariableList = 7,
@ -89,8 +89,8 @@ public class KickCParser extends Parser {
"'break'", "'continue'", "'asm'", "'default'", "'case'", "'struct'",
"'enum'", "'sizeof'", "'typeid'", "'kickasm'", "'resource'", "'uses'",
"'clobbers'", "'bytes'", "'cycles'", "'!'", null, null, null, null, null,
null, "'#define'", "'\\\n'", null, null, null, null, null, null, null,
null, null, null, null, null, null, "'.byte'", null, "'#'"
null, "'#define'", "'\\\n'", "'#undef'", null, null, null, null, null,
null, null, null, null, null, null, null, null, "'.byte'", null, "'#'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
@ -110,16 +110,16 @@ public class KickCParser extends Parser {
"CONTINUE", "ASM", "DEFAULT", "CASE", "STRUCT", "ENUM", "SIZEOF", "TYPEID",
"KICKASM", "RESOURCE", "USES", "CLOBBERS", "BYTES", "CYCLES", "LOGIC_NOT",
"SIGNEDNESS", "SIMPLETYPE", "BOOLEAN", "KICKASM_BODY", "STRING", "CHAR",
"DEFINE", "DEFINE_CONTINUE", "NUMBER", "NUMFLOAT", "BINFLOAT", "DECFLOAT",
"HEXFLOAT", "NUMINT", "BININTEGER", "DECINTEGER", "HEXINTEGER", "NAME",
"WS", "COMMENT_LINE", "COMMENT_BLOCK", "ASM_BYTE", "ASM_MNEMONIC", "ASM_IMM",
"ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN", "ASM_PAR_END", "ASM_BRACKET_BEGIN",
"ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT", "ASM_SHIFT_RIGHT", "ASM_PLUS",
"ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN", "ASM_MULTIPLY", "ASM_DIVIDE",
"ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER", "ASM_NUMFLOAT", "ASM_BINFLOAT",
"ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT", "ASM_BININTEGER", "ASM_DECINTEGER",
"ASM_HEXINTEGER", "ASM_CHAR", "ASM_MULTI_REL", "ASM_MULTI_NAME", "ASM_NAME",
"ASM_WS", "ASM_COMMENT_LINE", "ASM_COMMENT_BLOCK"
"DEFINE", "DEFINE_CONTINUE", "UNDEF", "NUMBER", "NUMFLOAT", "BINFLOAT",
"DECFLOAT", "HEXFLOAT", "NUMINT", "BININTEGER", "DECINTEGER", "HEXINTEGER",
"NAME", "WS", "COMMENT_LINE", "COMMENT_BLOCK", "ASM_BYTE", "ASM_MNEMONIC",
"ASM_IMM", "ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN", "ASM_PAR_END",
"ASM_BRACKET_BEGIN", "ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT",
"ASM_SHIFT_RIGHT", "ASM_PLUS", "ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN",
"ASM_MULTIPLY", "ASM_DIVIDE", "ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER",
"ASM_NUMFLOAT", "ASM_BINFLOAT", "ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT",
"ASM_BININTEGER", "ASM_DECINTEGER", "ASM_HEXINTEGER", "ASM_CHAR", "ASM_MULTI_REL",
"ASM_MULTI_NAME", "ASM_NAME", "ASM_WS", "ASM_COMMENT_LINE", "ASM_COMMENT_BLOCK"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
@ -6177,7 +6177,7 @@ public class KickCParser extends Parser {
setState(784);
_errHandler.sync(this);
_la = _input.LA(1);
while (((((_la - 110)) & ~0x3f) == 0 && ((1L << (_la - 110)) & ((1L << (ASM_BYTE - 110)) | (1L << (ASM_MNEMONIC - 110)) | (1L << (ASM_MULTI_NAME - 110)) | (1L << (ASM_NAME - 110)))) != 0)) {
while (((((_la - 111)) & ~0x3f) == 0 && ((1L << (_la - 111)) & ((1L << (ASM_BYTE - 111)) | (1L << (ASM_MNEMONIC - 111)) | (1L << (ASM_MULTI_NAME - 111)) | (1L << (ASM_NAME - 111)))) != 0)) {
{
{
setState(781);
@ -6938,7 +6938,7 @@ public class KickCParser extends Parser {
_prevctx = _localctx;
setState(841);
_la = _input.LA(1);
if ( !(((((_la - 122)) & ~0x3f) == 0 && ((1L << (_la - 122)) & ((1L << (ASM_PLUS - 122)) | (1L << (ASM_MINUS - 122)) | (1L << (ASM_LESS_THAN - 122)) | (1L << (ASM_GREATER_THAN - 122)))) != 0)) ) {
if ( !(((((_la - 123)) & ~0x3f) == 0 && ((1L << (_la - 123)) & ((1L << (ASM_PLUS - 123)) | (1L << (ASM_MINUS - 123)) | (1L << (ASM_LESS_THAN - 123)) | (1L << (ASM_GREATER_THAN - 123)))) != 0)) ) {
_errHandler.recoverInline(this);
}
else {
@ -7220,7 +7220,7 @@ public class KickCParser extends Parser {
}
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0093\u0368\4\2\t"+
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0094\u0368\4\2\t"+
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
@ -7285,8 +7285,8 @@ public class KickCParser extends Parser {
"/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\7/\u0363\n/\f/\16/\u0366\13/\3/\2\t\20"+
"\34\36*DF\\\60\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64"+
"\668:<>@BDFHJLNPRTVXZ\\\2\r\3\2\26\27\5\2\21\22\30\31ZZ\4\2 ##\3\2\34"+
"\35\3\2\23\25\3\2\21\22\3\2\36#\3\2|\177\3\2z{\3\2\u0080\u0081\3\2|}\2"+
"\u03e4\2^\3\2\2\2\4a\3\2\2\2\6g\3\2\2\2\bl\3\2\2\2\nn\3\2\2\2\f\u0080"+
"\35\3\2\23\25\3\2\21\22\3\2\36#\3\2}\u0080\3\2{|\3\2\u0081\u0082\3\2}"+
"~\2\u03e4\2^\3\2\2\2\4a\3\2\2\2\6g\3\2\2\2\bl\3\2\2\2\nn\3\2\2\2\f\u0080"+
"\3\2\2\2\16\u0082\3\2\2\2\20\u0085\3\2\2\2\22\u009c\3\2\2\2\24\u00c1\3"+
"\2\2\2\26\u00c6\3\2\2\2\30\u00d0\3\2\2\2\32\u00d7\3\2\2\2\34\u00dd\3\2"+
"\2\2\36\u00fc\3\2\2\2 \u010c\3\2\2\2\"\u010f\3\2\2\2$\u011b\3\2\2\2&\u011e"+
@ -7314,13 +7314,13 @@ public class KickCParser extends Parser {
"\u009a\3\2\2\2\u009a\21\3\2\2\2\u009b\u0099\3\2\2\2\u009c\u009d\7)\2\2"+
"\u009d\u00a1\5\26\f\2\u009e\u00a0\5\30\r\2\u009f\u009e\3\2\2\2\u00a0\u00a3"+
"\3\2\2\2\u00a1\u009f\3\2\2\2\u00a1\u00a2\3\2\2\2\u00a2\u00a4\3\2\2\2\u00a3"+
"\u00a1\3\2\2\2\u00a4\u00a8\7l\2\2\u00a5\u00a7\5\32\16\2\u00a6\u00a5\3"+
"\u00a1\3\2\2\2\u00a4\u00a8\7m\2\2\u00a5\u00a7\5\32\16\2\u00a6\u00a5\3"+
"\2\2\2\u00a7\u00aa\3\2\2\2\u00a8\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9"+
"\u00ab\3\2\2\2\u00aa\u00a8\3\2\2\2\u00ab\u00ac\b\n\1\2\u00ac\23\3\2\2"+
"\2\u00ad\u00b1\7l\2\2\u00ae\u00b0\5\32\16\2\u00af\u00ae\3\2\2\2\u00b0"+
"\2\u00ad\u00b1\7m\2\2\u00ae\u00b0\5\32\16\2\u00af\u00ae\3\2\2\2\u00b0"+
"\u00b3\3\2\2\2\u00b1\u00af\3\2\2\2\u00b1\u00b2\3\2\2\2\u00b2\u00b6\3\2"+
"\2\2\u00b3\u00b1\3\2\2\2\u00b4\u00b5\7&\2\2\u00b5\u00b7\5F$\2\u00b6\u00b4"+
"\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00c2\3\2\2\2\u00b8\u00bc\7l\2\2\u00b9"+
"\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00c2\3\2\2\2\u00b8\u00bc\7m\2\2\u00b9"+
"\u00bb\5\32\16\2\u00ba\u00b9\3\2\2\2\u00bb\u00be\3\2\2\2\u00bc\u00ba\3"+
"\2\2\2\u00bc\u00bd\3\2\2\2\u00bd\u00bf\3\2\2\2\u00be\u00bc\3\2\2\2\u00bf"+
"\u00c0\7&\2\2\u00c0\u00c2\5J&\2\u00c1\u00ad\3\2\2\2\u00c1\u00b8\3\2\2"+
@ -7350,23 +7350,23 @@ public class KickCParser extends Parser {
"\u0108\7\7\2\2\u0104\u0105\f\b\2\2\u0105\u0106\7\b\2\2\u0106\u0108\7\t"+
"\2\2\u0107\u00fe\3\2\2\2\u0107\u0104\3\2\2\2\u0108\u010b\3\2\2\2\u0109"+
"\u0107\3\2\2\2\u0109\u010a\3\2\2\2\u010a\37\3\2\2\2\u010b\u0109\3\2\2"+
"\2\u010c\u010d\7P\2\2\u010d\u010e\7l\2\2\u010e!\3\2\2\2\u010f\u0111\7"+
"P\2\2\u0110\u0112\7l\2\2\u0111\u0110\3\2\2\2\u0111\u0112\3\2\2\2\u0112"+
"\2\u010c\u010d\7P\2\2\u010d\u010e\7m\2\2\u010e!\3\2\2\2\u010f\u0111\7"+
"P\2\2\u0110\u0112\7m\2\2\u0111\u0110\3\2\2\2\u0111\u0112\3\2\2\2\u0112"+
"\u0113\3\2\2\2\u0113\u0115\7\4\2\2\u0114\u0116\5$\23\2\u0115\u0114\3\2"+
"\2\2\u0116\u0117\3\2\2\2\u0117\u0115\3\2\2\2\u0117\u0118\3\2\2\2\u0118"+
"\u0119\3\2\2\2\u0119\u011a\7\5\2\2\u011a#\3\2\2\2\u011b\u011c\5\16\b\2"+
"\u011c\u011d\7\n\2\2\u011d%\3\2\2\2\u011e\u011f\7Q\2\2\u011f\u0120\7l"+
"\2\2\u0120\'\3\2\2\2\u0121\u0123\7Q\2\2\u0122\u0124\7l\2\2\u0123\u0122"+
"\u011c\u011d\7\n\2\2\u011d%\3\2\2\2\u011e\u011f\7Q\2\2\u011f\u0120\7m"+
"\2\2\u0120\'\3\2\2\2\u0121\u0123\7Q\2\2\u0122\u0124\7m\2\2\u0123\u0122"+
"\3\2\2\2\u0123\u0124\3\2\2\2\u0124\u0125\3\2\2\2\u0125\u0126\7\4\2\2\u0126"+
"\u0127\5*\26\2\u0127\u0128\7\5\2\2\u0128)\3\2\2\2\u0129\u012a\b\26\1\2"+
"\u012a\u012b\5,\27\2\u012b\u0131\3\2\2\2\u012c\u012d\f\3\2\2\u012d\u012e"+
"\7\f\2\2\u012e\u0130\5,\27\2\u012f\u012c\3\2\2\2\u0130\u0133\3\2\2\2\u0131"+
"\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132+\3\2\2\2\u0133\u0131\3\2\2\2"+
"\u0134\u0137\7l\2\2\u0135\u0136\7&\2\2\u0136\u0138\5F$\2\u0137\u0135\3"+
"\u0134\u0137\7m\2\2\u0135\u0136\7&\2\2\u0136\u0138\5F$\2\u0137\u0135\3"+
"\2\2\2\u0137\u0138\3\2\2\2\u0138-\3\2\2\2\u0139\u013d\5\26\f\2\u013a\u013c"+
"\5\30\r\2\u013b\u013a\3\2\2\2\u013c\u013f\3\2\2\2\u013d\u013b\3\2\2\2"+
"\u013d\u013e\3\2\2\2\u013e\u0140\3\2\2\2\u013f\u013d\3\2\2\2\u0140\u0141"+
"\7l\2\2\u0141\u0143\7\b\2\2\u0142\u0144\5\60\31\2\u0143\u0142\3\2\2\2"+
"\7m\2\2\u0141\u0143\7\b\2\2\u0142\u0144\5\60\31\2\u0143\u0142\3\2\2\2"+
"\u0143\u0144\3\2\2\2\u0144\u0145\3\2\2\2\u0145\u0146\7\t\2\2\u0146\u0148"+
"\7\4\2\2\u0147\u0149\58\35\2\u0148\u0147\3\2\2\2\u0148\u0149\3\2\2\2\u0149"+
"\u014a\3\2\2\2\u014a\u014b\7\5\2\2\u014b/\3\2\2\2\u014c\u0151\5\62\32"+
@ -7374,43 +7374,43 @@ public class KickCParser extends Parser {
"\u0153\3\2\2\2\u0151\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\61\3\2\2"+
"\2\u0153\u0151\3\2\2\2\u0154\u0158\5\26\f\2\u0155\u0157\5\30\r\2\u0156"+
"\u0155\3\2\2\2\u0157\u015a\3\2\2\2\u0158\u0156\3\2\2\2\u0158\u0159\3\2"+
"\2\2\u0159\u015b\3\2\2\2\u015a\u0158\3\2\2\2\u015b\u015c\7l\2\2\u015c"+
"\2\2\u0159\u015b\3\2\2\2\u015a\u0158\3\2\2\2\u015b\u015c\7m\2\2\u015c"+
"\u015f\3\2\2\2\u015d\u015f\7\\\2\2\u015e\u0154\3\2\2\2\u015e\u015d\3\2"+
"\2\2\u015f\63\3\2\2\2\u0160\u0161\7*\2\2\u0161\u0162\7+\2\2\u0162\u0163"+
"\3\2\2\2\u0163\u0164\7\b\2\2\u0164\u0169\7c\2\2\u0165\u0166\7\f\2\2\u0166"+
"\u0168\7c\2\2\u0167\u0165\3\2\2\2\u0168\u016b\3\2\2\2\u0169\u0167\3\2"+
"\3\2\2\2\u0163\u0164\7\b\2\2\u0164\u0169\7d\2\2\u0165\u0166\7\f\2\2\u0166"+
"\u0168\7d\2\2\u0167\u0165\3\2\2\2\u0168\u016b\3\2\2\2\u0169\u0167\3\2"+
"\2\2\u0169\u016a\3\2\2\2\u016a\u016c\3\2\2\2\u016b\u0169\3\2\2\2\u016c"+
"\u01ab\7\t\2\2\u016d\u016e\7*\2\2\u016e\u016f\7,\2\2\u016f\u0170\3\2\2"+
"\2\u0170\u0171\7\b\2\2\u0171\u0172\7c\2\2\u0172\u01ab\7\t\2\2\u0173\u0174"+
"\2\u0170\u0171\7\b\2\2\u0171\u0172\7d\2\2\u0172\u01ab\7\t\2\2\u0173\u0174"+
"\7*\2\2\u0174\u0175\7-\2\2\u0175\u0176\3\2\2\2\u0176\u0177\7\b\2\2\u0177"+
"\u0178\7l\2\2\u0178\u01ab\7\t\2\2\u0179\u017a\7*\2\2\u017a\u017b\7/\2"+
"\2\u017b\u017c\3\2\2\2\u017c\u017d\7\b\2\2\u017d\u017e\7l\2\2\u017e\u01ab"+
"\u0178\7m\2\2\u0178\u01ab\7\t\2\2\u0179\u017a\7*\2\2\u017a\u017b\7/\2"+
"\2\u017b\u017c\3\2\2\2\u017c\u017d\7\b\2\2\u017d\u017e\7m\2\2\u017e\u01ab"+
"\7\t\2\2\u017f\u0180\7*\2\2\u0180\u0181\7.\2\2\u0181\u0182\3\2\2\2\u0182"+
"\u0183\7\b\2\2\u0183\u0184\7_\2\2\u0184\u01ab\7\t\2\2\u0185\u0186\7*\2"+
"\2\u0186\u0187\7\60\2\2\u0187\u0188\3\2\2\2\u0188\u0189\7\b\2\2\u0189"+
"\u018a\7l\2\2\u018a\u01ab\7\t\2\2\u018b\u018c\7*\2\2\u018c\u018d\7\61"+
"\2\2\u018d\u018e\3\2\2\2\u018e\u018f\7\b\2\2\u018f\u0190\7l\2\2\u0190"+
"\u018a\7m\2\2\u018a\u01ab\7\t\2\2\u018b\u018c\7*\2\2\u018c\u018d\7\61"+
"\2\2\u018d\u018e\3\2\2\2\u018e\u018f\7\b\2\2\u018f\u0190\7m\2\2\u0190"+
"\u01ab\7\t\2\2\u0191\u0192\7*\2\2\u0192\u0193\7\62\2\2\u0193\u0194\3\2"+
"\2\2\u0194\u0195\7\b\2\2\u0195\u0196\7l\2\2\u0196\u01ab\7\t\2\2\u0197"+
"\2\2\u0194\u0195\7\b\2\2\u0195\u0196\7m\2\2\u0196\u01ab\7\t\2\2\u0197"+
"\u0198\7*\2\2\u0198\u0199\7A\2\2\u0199\u019a\3\2\2\2\u019a\u019b\7\b\2"+
"\2\u019b\u019c\7B\2\2\u019c\u01ab\7\t\2\2\u019d\u019e\7*\2\2\u019e\u019f"+
"\7C\2\2\u019f\u01a0\3\2\2\2\u01a0\u01a1\7\b\2\2\u01a1\u01a6\7l\2\2\u01a2"+
"\u01a3\7\f\2\2\u01a3\u01a5\7l\2\2\u01a4\u01a2\3\2\2\2\u01a5\u01a8\3\2"+
"\7C\2\2\u019f\u01a0\3\2\2\2\u01a0\u01a1\7\b\2\2\u01a1\u01a6\7m\2\2\u01a2"+
"\u01a3\7\f\2\2\u01a3\u01a5\7m\2\2\u01a4\u01a2\3\2\2\2\u01a5\u01a8\3\2"+
"\2\2\u01a6\u01a4\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7\u01a9\3\2\2\2\u01a8"+
"\u01a6\3\2\2\2\u01a9\u01ab\7\t\2\2\u01aa\u0160\3\2\2\2\u01aa\u016d\3\2"+
"\2\2\u01aa\u0173\3\2\2\2\u01aa\u0179\3\2\2\2\u01aa\u017f\3\2\2\2\u01aa"+
"\u0185\3\2\2\2\u01aa\u018b\3\2\2\2\u01aa\u0191\3\2\2\2\u01aa\u0197\3\2"+
"\2\2\u01aa\u019d\3\2\2\2\u01ab\65\3\2\2\2\u01ac\u01d7\7\63\2\2\u01ad\u01ae"+
"\7\66\2\2\u01ae\u01af\7\b\2\2\u01af\u01b0\7c\2\2\u01b0\u01d7\7\t\2\2\u01b1"+
"\u01b5\7;\2\2\u01b2\u01b3\7\b\2\2\u01b3\u01b4\7l\2\2\u01b4\u01b6\7\t\2"+
"\7\66\2\2\u01ae\u01af\7\b\2\2\u01af\u01b0\7d\2\2\u01b0\u01d7\7\t\2\2\u01b1"+
"\u01b5\7;\2\2\u01b2\u01b3\7\b\2\2\u01b3\u01b4\7m\2\2\u01b4\u01b6\7\t\2"+
"\2\u01b5\u01b2\3\2\2\2\u01b5\u01b6\3\2\2\2\u01b6\u01d7\3\2\2\2\u01b7\u01d7"+
"\7=\2\2\u01b8\u01d7\7>\2\2\u01b9\u01ba\7<\2\2\u01ba\u01bb\7\b\2\2\u01bb"+
"\u01bc\7c\2\2\u01bc\u01d7\7\t\2\2\u01bd\u01d7\78\2\2\u01be\u01d7\79\2"+
"\u01bc\7d\2\2\u01bc\u01d7\7\t\2\2\u01bd\u01d7\78\2\2\u01be\u01d7\79\2"+
"\2\u01bf\u01d7\7?\2\2\u01c0\u01d7\7@\2\2\u01c1\u01d7\7\64\2\2\u01c2\u01d7"+
"\7\65\2\2\u01c3\u01d7\7\67\2\2\u01c4\u01c8\7:\2\2\u01c5\u01c6\7\b\2\2"+
"\u01c6\u01c7\7l\2\2\u01c7\u01c9\7\t\2\2\u01c8\u01c5\3\2\2\2\u01c8\u01c9"+
"\u01c6\u01c7\7m\2\2\u01c7\u01c9\7\t\2\2\u01c8\u01c5\3\2\2\2\u01c8\u01c9"+
"\3\2\2\2\u01c9\u01d7\3\2\2\2\u01ca\u01cb\7+\2\2\u01cb\u01cc\7\b\2\2\u01cc"+
"\u01d1\7c\2\2\u01cd\u01ce\7\f\2\2\u01ce\u01d0\7c\2\2\u01cf\u01cd\3\2\2"+
"\u01d1\7d\2\2\u01cd\u01ce\7\f\2\2\u01ce\u01d0\7d\2\2\u01cf\u01cd\3\2\2"+
"\2\u01d0\u01d3\3\2\2\2\u01d1\u01cf\3\2\2\2\u01d1\u01d2\3\2\2\2\u01d2\u01d4"+
"\3\2\2\2\u01d3\u01d1\3\2\2\2\u01d4\u01d7\7\t\2\2\u01d5\u01d7\7B\2\2\u01d6"+
"\u01ac\3\2\2\2\u01d6\u01ad\3\2\2\2\u01d6\u01b1\3\2\2\2\u01d6\u01b7\3\2"+
@ -7444,7 +7444,7 @@ public class KickCParser extends Parser {
"\7K\2\2\u0225\u0232\7\n\2\2\u0226\u0227\7L\2\2\u0227\u0232\7\n\2\2\u0228"+
"\u022a\7M\2\2\u0229\u022b\5L\'\2\u022a\u0229\3\2\2\2\u022a\u022b\3\2\2"+
"\2\u022b\u022c\3\2\2\2\u022c\u022d\7\4\2\2\u022d\u022e\5P)\2\u022e\u022f"+
"\7\u0083\2\2\u022f\u0232\3\2\2\2\u0230\u0232\5J&\2\u0231\u01dd\3\2\2\2"+
"\7\u0084\2\2\u022f\u0232\3\2\2\2\u0230\u0232\5J&\2\u0231\u01dd\3\2\2\2"+
"\u0231\u01e0\3\2\2\2\u0231\u01e5\3\2\2\2\u0231\u01e8\3\2\2\2\u0231\u01f4"+
"\3\2\2\2\u0231\u0200\3\2\2\2\u0231\u020e\3\2\2\2\u0231\u0217\3\2\2\2\u0231"+
"\u021f\3\2\2\2\u0231\u0224\3\2\2\2\u0231\u0226\3\2\2\2\u0231\u0228\3\2"+
@ -7460,7 +7460,7 @@ public class KickCParser extends Parser {
"\f\2\u024d\u024f\5\30\r\2\u024e\u024d\3\2\2\2\u024f\u0252\3\2\2\2\u0250"+
"\u024e\3\2\2\2\u0250\u0251\3\2\2\2\u0251\u0254\3\2\2\2\u0252\u0250\3\2"+
"\2\2\u0253\u024c\3\2\2\2\u0253\u0254\3\2\2\2\u0254\u0255\3\2\2\2\u0255"+
"\u0256\7l\2\2\u0256\u0257\7\13\2\2\u0257\u0258\5F$\2\u0258\u0259\7\r\2"+
"\u0256\7m\2\2\u0256\u0257\7\13\2\2\u0257\u0258\5F$\2\u0258\u0259\7\r\2"+
"\2\u0259\u025a\5F$\2\u025a\u025c\3\2\2\2\u025b\u0245\3\2\2\2\u025b\u0253"+
"\3\2\2\2\u025cA\3\2\2\2\u025d\u025f\5\16\b\2\u025e\u025d\3\2\2\2\u025e"+
"\u025f\3\2\2\2\u025f\u0262\3\2\2\2\u0260\u0262\5D#\2\u0261\u025e\3\2\2"+
@ -7481,7 +7481,7 @@ public class KickCParser extends Parser {
"\22\u0290\u0291\7\4\2\2\u0291\u0296\5F$\2\u0292\u0293\7\f\2\2\u0293\u0295"+
"\5F$\2\u0294\u0292\3\2\2\2\u0295\u0298\3\2\2\2\u0296\u0294\3\2\2\2\u0296"+
"\u0297\3\2\2\2\u0297\u0299\3\2\2\2\u0298\u0296\3\2\2\2\u0299\u029a\7\5"+
"\2\2\u029a\u02a5\3\2\2\2\u029b\u02a5\7l\2\2\u029c\u02a5\7c\2\2\u029d\u029f"+
"\2\2\u029a\u02a5\3\2\2\2\u029b\u02a5\7m\2\2\u029c\u02a5\7d\2\2\u029d\u029f"+
"\7_\2\2\u029e\u029d\3\2\2\2\u029f\u02a0\3\2\2\2\u02a0\u029e\3\2\2\2\u02a0"+
"\u02a1\3\2\2\2\u02a1\u02a5\3\2\2\2\u02a2\u02a5\7`\2\2\u02a3\u02a5\7]\2"+
"\2\u02a4\u026e\3\2\2\2\u02a4\u0273\3\2\2\2\u02a4\u027b\3\2\2\2\u02a4\u0283"+
@ -7499,8 +7499,8 @@ public class KickCParser extends Parser {
"\f\13\2\2\u02c2\u02c3\7\16\2\2\u02c3\u02c4\5F$\2\u02c4\u02c5\7\13\2\2"+
"\u02c5\u02c6\5F$\f\u02c6\u02e1\3\2\2\2\u02c7\u02c8\f\n\2\2\u02c8\u02c9"+
"\7&\2\2\u02c9\u02e1\5F$\n\u02ca\u02cb\f\t\2\2\u02cb\u02cc\7\'\2\2\u02cc"+
"\u02e1\5F$\t\u02cd\u02ce\f \2\2\u02ce\u02cf\7\17\2\2\u02cf\u02e1\7l\2"+
"\2\u02d0\u02d1\f\37\2\2\u02d1\u02d2\7\20\2\2\u02d2\u02e1\7l\2\2\u02d3"+
"\u02e1\5F$\t\u02cd\u02ce\f \2\2\u02ce\u02cf\7\17\2\2\u02cf\u02e1\7m\2"+
"\2\u02d0\u02d1\f\37\2\2\u02d1\u02d2\7\20\2\2\u02d2\u02e1\7m\2\2\u02d3"+
"\u02d4\f\36\2\2\u02d4\u02d6\7\b\2\2\u02d5\u02d7\5H%\2\u02d6\u02d5\3\2"+
"\2\2\u02d6\u02d7\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u02e1\7\t\2\2\u02d9"+
"\u02da\f\33\2\2\u02da\u02db\7\6\2\2\u02db\u02dc\5D#\2\u02dc\u02dd\7\7"+
@ -7519,7 +7519,7 @@ public class KickCParser extends Parser {
"\u02f6\7\f\2\2\u02f6\u02f8\5N(\2\u02f7\u02f5\3\2\2\2\u02f8\u02fb\3\2\2"+
"\2\u02f9\u02f7\3\2\2\2\u02f9\u02fa\3\2\2\2\u02fa\u02fc\3\2\2\2\u02fb\u02f9"+
"\3\2\2\2\u02fc\u02fd\7\t\2\2\u02fdM\3\2\2\2\u02fe\u02ff\7U\2\2\u02ff\u030e"+
"\7_\2\2\u0300\u0301\7V\2\2\u0301\u030e\7l\2\2\u0302\u0303\7W\2\2\u0303"+
"\7_\2\2\u0300\u0301\7V\2\2\u0301\u030e\7m\2\2\u0302\u0303\7W\2\2\u0303"+
"\u030e\7_\2\2\u0304\u0305\7X\2\2\u0305\u030e\5F$\2\u0306\u0307\7Y\2\2"+
"\u0307\u030e\5F$\2\u0308\u030b\7,\2\2\u0309\u030c\7\67\2\2\u030a\u030c"+
"\5F$\2\u030b\u0309\3\2\2\2\u030b\u030a\3\2\2\2\u030c\u030e\3\2\2\2\u030d"+
@ -7528,28 +7528,28 @@ public class KickCParser extends Parser {
"\5R*\2\u0310\u030f\3\2\2\2\u0311\u0314\3\2\2\2\u0312\u0310\3\2\2\2\u0312"+
"\u0313\3\2\2\2\u0313Q\3\2\2\2\u0314\u0312\3\2\2\2\u0315\u0319\5T+\2\u0316"+
"\u0319\5V,\2\u0317\u0319\5X-\2\u0318\u0315\3\2\2\2\u0318\u0316\3\2\2\2"+
"\u0318\u0317\3\2\2\2\u0319S\3\2\2\2\u031a\u031b\7\u0090\2\2\u031b\u031f"+
"\7s\2\2\u031c\u031d\7\u008f\2\2\u031d\u031f\7s\2\2\u031e\u031a\3\2\2\2"+
"\u031e\u031c\3\2\2\2\u031fU\3\2\2\2\u0320\u0322\7q\2\2\u0321\u0323\5Z"+
"\u0318\u0317\3\2\2\2\u0319S\3\2\2\2\u031a\u031b\7\u0091\2\2\u031b\u031f"+
"\7t\2\2\u031c\u031d\7\u0090\2\2\u031d\u031f\7t\2\2\u031e\u031a\3\2\2\2"+
"\u031e\u031c\3\2\2\2\u031fU\3\2\2\2\u0320\u0322\7r\2\2\u0321\u0323\5Z"+
".\2\u0322\u0321\3\2\2\2\u0322\u0323\3\2\2\2\u0323W\3\2\2\2\u0324\u0325"+
"\7p\2\2\u0325\u032a\5\\/\2\u0326\u0327\7t\2\2\u0327\u0329\5\\/\2\u0328"+
"\7q\2\2\u0325\u032a\5\\/\2\u0326\u0327\7u\2\2\u0327\u0329\5\\/\2\u0328"+
"\u0326\3\2\2\2\u0329\u032c\3\2\2\2\u032a\u0328\3\2\2\2\u032a\u032b\3\2"+
"\2\2\u032bY\3\2\2\2\u032c\u032a\3\2\2\2\u032d\u0345\5\\/\2\u032e\u032f"+
"\7r\2\2\u032f\u0345\5\\/\2\u0330\u0331\5\\/\2\u0331\u0332\7t\2\2\u0332"+
"\u0333\7\u0090\2\2\u0333\u0345\3\2\2\2\u0334\u0335\7u\2\2\u0335\u0336"+
"\5\\/\2\u0336\u0337\7v\2\2\u0337\u0338\7t\2\2\u0338\u0339\7\u0090\2\2"+
"\u0339\u0345\3\2\2\2\u033a\u033b\7u\2\2\u033b\u033c\5\\/\2\u033c\u033d"+
"\7t\2\2\u033d\u033e\7\u0090\2\2\u033e\u033f\7v\2\2\u033f\u0345\3\2\2\2"+
"\u0340\u0341\7u\2\2\u0341\u0342\5\\/\2\u0342\u0343\7v\2\2\u0343\u0345"+
"\7s\2\2\u032f\u0345\5\\/\2\u0330\u0331\5\\/\2\u0331\u0332\7u\2\2\u0332"+
"\u0333\7\u0091\2\2\u0333\u0345\3\2\2\2\u0334\u0335\7v\2\2\u0335\u0336"+
"\5\\/\2\u0336\u0337\7w\2\2\u0337\u0338\7u\2\2\u0338\u0339\7\u0091\2\2"+
"\u0339\u0345\3\2\2\2\u033a\u033b\7v\2\2\u033b\u033c\5\\/\2\u033c\u033d"+
"\7u\2\2\u033d\u033e\7\u0091\2\2\u033e\u033f\7w\2\2\u033f\u0345\3\2\2\2"+
"\u0340\u0341\7v\2\2\u0341\u0342\5\\/\2\u0342\u0343\7w\2\2\u0343\u0345"+
"\3\2\2\2\u0344\u032d\3\2\2\2\u0344\u032e\3\2\2\2\u0344\u0330\3\2\2\2\u0344"+
"\u0334\3\2\2\2\u0344\u033a\3\2\2\2\u0344\u0340\3\2\2\2\u0345[\3\2\2\2"+
"\u0346\u0347\b/\1\2\u0347\u0348\7w\2\2\u0348\u0349\5\\/\2\u0349\u034a"+
"\7x\2\2\u034a\u0355\3\2\2\2\u034b\u034c\t\t\2\2\u034c\u0355\5\\/\n\u034d"+
"\u0355\7\u0090\2\2\u034e\u0355\7\u008e\2\2\u034f\u0350\7\u0082\2\2\u0350"+
"\u0351\7\u0090\2\2\u0351\u0355\7\u0083\2\2\u0352\u0355\7\u0084\2\2\u0353"+
"\u0355\7\u008d\2\2\u0354\u0346\3\2\2\2\u0354\u034b\3\2\2\2\u0354\u034d"+
"\u0346\u0347\b/\1\2\u0347\u0348\7x\2\2\u0348\u0349\5\\/\2\u0349\u034a"+
"\7y\2\2\u034a\u0355\3\2\2\2\u034b\u034c\t\t\2\2\u034c\u0355\5\\/\n\u034d"+
"\u0355\7\u0091\2\2\u034e\u0355\7\u008f\2\2\u034f\u0350\7\u0083\2\2\u0350"+
"\u0351\7\u0091\2\2\u0351\u0355\7\u0084\2\2\u0352\u0355\7\u0085\2\2\u0353"+
"\u0355\7\u008e\2\2\u0354\u0346\3\2\2\2\u0354\u034b\3\2\2\2\u0354\u034d"+
"\3\2\2\2\u0354\u034e\3\2\2\2\u0354\u034f\3\2\2\2\u0354\u0352\3\2\2\2\u0354"+
"\u0353\3\2\2\2\u0355\u0364\3\2\2\2\u0356\u0357\f\f\2\2\u0357\u0358\7y"+
"\u0353\3\2\2\2\u0355\u0364\3\2\2\2\u0356\u0357\f\f\2\2\u0357\u0358\7z"+
"\2\2\u0358\u0363\5\\/\r\u0359\u035a\f\13\2\2\u035a\u035b\t\n\2\2\u035b"+
"\u0363\5\\/\f\u035c\u035d\f\t\2\2\u035d\u035e\t\13\2\2\u035e\u0363\5\\"+
"/\n\u035f\u0360\f\b\2\2\u0360\u0361\t\f\2\2\u0361\u0363\5\\/\t\u0362\u0356"+

View File

@ -94,55 +94,56 @@ STRING=93
CHAR=94
DEFINE=95
DEFINE_CONTINUE=96
NUMBER=97
NUMFLOAT=98
BINFLOAT=99
DECFLOAT=100
HEXFLOAT=101
NUMINT=102
BININTEGER=103
DECINTEGER=104
HEXINTEGER=105
NAME=106
WS=107
COMMENT_LINE=108
COMMENT_BLOCK=109
ASM_BYTE=110
ASM_MNEMONIC=111
ASM_IMM=112
ASM_COLON=113
ASM_COMMA=114
ASM_PAR_BEGIN=115
ASM_PAR_END=116
ASM_BRACKET_BEGIN=117
ASM_BRACKET_END=118
ASM_DOT=119
ASM_SHIFT_LEFT=120
ASM_SHIFT_RIGHT=121
ASM_PLUS=122
ASM_MINUS=123
ASM_LESS_THAN=124
ASM_GREATER_THAN=125
ASM_MULTIPLY=126
ASM_DIVIDE=127
ASM_CURLY_BEGIN=128
ASM_CURLY_END=129
ASM_NUMBER=130
ASM_NUMFLOAT=131
ASM_BINFLOAT=132
ASM_DECFLOAT=133
ASM_HEXFLOAT=134
ASM_NUMINT=135
ASM_BININTEGER=136
ASM_DECINTEGER=137
ASM_HEXINTEGER=138
ASM_CHAR=139
ASM_MULTI_REL=140
ASM_MULTI_NAME=141
ASM_NAME=142
ASM_WS=143
ASM_COMMENT_LINE=144
ASM_COMMENT_BLOCK=145
UNDEF=97
NUMBER=98
NUMFLOAT=99
BINFLOAT=100
DECFLOAT=101
HEXFLOAT=102
NUMINT=103
BININTEGER=104
DECINTEGER=105
HEXINTEGER=106
NAME=107
WS=108
COMMENT_LINE=109
COMMENT_BLOCK=110
ASM_BYTE=111
ASM_MNEMONIC=112
ASM_IMM=113
ASM_COLON=114
ASM_COMMA=115
ASM_PAR_BEGIN=116
ASM_PAR_END=117
ASM_BRACKET_BEGIN=118
ASM_BRACKET_END=119
ASM_DOT=120
ASM_SHIFT_LEFT=121
ASM_SHIFT_RIGHT=122
ASM_PLUS=123
ASM_MINUS=124
ASM_LESS_THAN=125
ASM_GREATER_THAN=126
ASM_MULTIPLY=127
ASM_DIVIDE=128
ASM_CURLY_BEGIN=129
ASM_CURLY_END=130
ASM_NUMBER=131
ASM_NUMFLOAT=132
ASM_BINFLOAT=133
ASM_DECFLOAT=134
ASM_HEXFLOAT=135
ASM_NUMINT=136
ASM_BININTEGER=137
ASM_DECINTEGER=138
ASM_HEXINTEGER=139
ASM_CHAR=140
ASM_MULTI_REL=141
ASM_MULTI_NAME=142
ASM_NAME=143
ASM_WS=144
ASM_COMMENT_LINE=145
ASM_COMMENT_BLOCK=146
';'=8
'..'=11
'?'=12
@ -213,5 +214,6 @@ ASM_COMMENT_BLOCK=145
'!'=88
'#define'=95
'\\\n'=96
'.byte'=110
'#'=112
'#undef'=97
'.byte'=111
'#'=113

View File

@ -11,7 +11,7 @@ import java.util.*;
* <p>
* The preprocessor takes a token source as input and produces macro expanded tokens as output
*/
public class CTokenSourcePreprocessor implements TokenSource {
public class CPreprocessor implements TokenSource {
/** The token source containing the input */
private CTokenSource input;
@ -22,24 +22,10 @@ public class CTokenSourcePreprocessor implements TokenSource {
*/
private Map<String, List<Token>> defines;
/** The channel containing whitespace. */
private final int channelWhitespace;
/** The token type for tokens containing whitespace. */
private final int tokenWhitespace;
/** The token type for #define. */
private final int tokenDefine;
/** The token type for identifiers. */
private final int tokenIdentifier;
/** The token type for define multi-line. */
private final int tokenDefineMultiline;
/** The token type for parenthesis begin. */
private final int tokenParBegin;
/** The token type for parenthesis end. */
private final int tokenParEnd;
/** The token type for comma. */
private final int tokenComma;
/** The token types. */
private CPreprocessorTokens tokenTypes;
public CTokenSourcePreprocessor(TokenSource input, int channelWhitespace, int tokenWhitespace, int tokenDefine, int tokenIdentifier, int tokenParBegin, int tokenParEnd, int tokenComma, int tokenDefineMultiline) {
public CPreprocessor(TokenSource input, CPreprocessorTokens tokenTypes) {
if(input instanceof CTokenSource) {
// If possible use the input directly instead of wrapping it
this.input = (CTokenSource) input;
@ -47,14 +33,7 @@ public class CTokenSourcePreprocessor implements TokenSource {
this.input = new CTokenSource(input);
}
this.defines = new LinkedHashMap<>();
this.channelWhitespace = channelWhitespace;
this.tokenWhitespace = tokenWhitespace;
this.tokenDefine = tokenDefine;
this.tokenIdentifier = tokenIdentifier;
this.tokenParBegin = tokenParBegin;
this.tokenParEnd = tokenParEnd;
this.tokenComma = tokenComma;
this.tokenDefineMultiline = tokenDefineMultiline;
this.tokenTypes = tokenTypes;
}
@Override
@ -99,7 +78,7 @@ public class CTokenSourcePreprocessor implements TokenSource {
/**
* Perform any preprocessing needed on a token. If preprocessing is not needed nothing is done.
*
* <p>
* This method may gobble more tokens from the source (for instance if a macro is being defined) and it may push tokens at the front of the source (if a macro is being expanded).
*
* @param inputToken The token to process
@ -107,76 +86,107 @@ public class CTokenSourcePreprocessor implements TokenSource {
* @return true if the input token was preprocessed (and should not be added to the output). False if the token was not a preprocessor token
*/
private boolean preprocess(Token inputToken, CTokenSource cTokenSource) {
boolean wasPreprocessed;
if(inputToken.getType() == tokenDefine) {
// #define a new macro - find the name
skipWhitespace(cTokenSource);
String macroName = nextToken(cTokenSource, tokenIdentifier).getText();
// Examine whether the macro has parameters
skipWhitespace(cTokenSource);
if(cTokenSource.peekToken().getType() == tokenParBegin) {
// Macro has parameters - find parameter name list
throw new CompileError("Macros with parameters not supported!");
}
// Find body by gobbling tokens until the line ends
final ArrayList<Token> macroBody = new ArrayList<>();
boolean macroRead = true;
while(macroRead) {
final Token bodyToken = cTokenSource.nextToken();
if(bodyToken.getType() == tokenDefineMultiline) {
// Skip the multi-line token, add a newline token and continue reading body on the next line
final CommonToken newlineToken = new CommonToken(bodyToken);
newlineToken.setType(tokenWhitespace);
newlineToken.setChannel(channelWhitespace);
newlineToken.setText("\n");
macroBody.add(newlineToken);
continue;
}
if(bodyToken.getChannel() == channelWhitespace && bodyToken.getText().contains("\n")) {
macroRead = false;
} else {
macroBody.add(bodyToken);
}
}
defines.put(macroName, macroBody);
if(inputToken.getType() == tokenTypes.define) {
defineMacro(cTokenSource);
return true;
} else {
if(inputToken.getType() == tokenIdentifier) {
final String macroName = inputToken.getText();
List<Token> macroBody = defines.get(macroName);
if(macroBody != null) {
// Check for macro recursion
if(inputToken instanceof ExpansionToken) {
if(((ExpansionToken) inputToken).getMacroNames().contains(macroName)) {
// Detected macro recursion in the expansion - add directly to output and do not perform expansion!
macroBody = null;
}
}
}
if(macroBody != null) {
// Macro expansion is needed
List<Token> expandedBody = new ArrayList<>();
for(Token bodyToken : macroBody) {
final CommonToken expandedToken = new CommonToken(inputToken);
expandedToken.setText(bodyToken.getText());
expandedToken.setType(bodyToken.getType());
expandedToken.setChannel(bodyToken.getChannel());
Set<String> macroNames = new HashSet<>();
if(inputToken instanceof ExpansionToken) {
// Transfer macro names to the new expansion
macroNames = ((ExpansionToken) inputToken).getMacroNames();
}
macroNames.add(macroName);
expandedBody.add(new ExpansionToken(expandedToken, macroNames));
}
cTokenSource.addSource(new ListTokenSource(expandedBody));
return true;
} else if(inputToken.getType() == tokenTypes.undef) {
undefMacro(cTokenSource);
return true;
} else if(inputToken.getType() == tokenTypes.identifier) {
final boolean expanded = expandMacro(inputToken, cTokenSource);
if(expanded) return true;
}
return false;
}
/**
* Encountered an IDENTIFIER. Attempt to expand as a macro.
* @param inputToken The IDENTIFIER token
* @param cTokenSource The token source usable for getting more tokens (eg. parameter values) - and for pushing the expanded body to the front for further processing.
* @return true if a macro was expanded. False if not.
*/
private boolean expandMacro(Token inputToken, CTokenSource cTokenSource) {
final String macroName = inputToken.getText();
List<Token> macroBody = defines.get(macroName);
if(macroBody != null) {
// Check for macro recursion
if(inputToken instanceof ExpansionToken) {
if(((ExpansionToken) inputToken).getMacroNames().contains(macroName)) {
// Detected macro recursion in the expansion - add directly to output and do not perform expansion!
macroBody = null;
}
}
}
if(macroBody != null) {
// Macro expansion is needed
List<Token> expandedBody = new ArrayList<>();
for(Token bodyToken : macroBody) {
final CommonToken expandedToken = new CommonToken(inputToken);
expandedToken.setText(bodyToken.getText());
expandedToken.setType(bodyToken.getType());
expandedToken.setChannel(bodyToken.getChannel());
Set<String> macroNames = new HashSet<>();
if(inputToken instanceof ExpansionToken) {
// Transfer macro names to the new expansion
macroNames = ((ExpansionToken) inputToken).getMacroNames();
}
macroNames.add(macroName);
expandedBody.add(new ExpansionToken(expandedToken, macroNames));
}
cTokenSource.addSource(new ListTokenSource(expandedBody));
return true;
}
return false;
}
/**
* Undefine a macro.
* @param cTokenSource The token source used to get the name
*/
private void undefMacro(CTokenSource cTokenSource) {
// #define a new macro - find the name
skipWhitespace(cTokenSource);
String macroName = nextToken(cTokenSource, tokenTypes.identifier).getText();
this.defines.remove(macroName);
}
/**
* Define a macro.
* @param cTokenSource The token source used to get the macro name and body.
*/
private void defineMacro(CTokenSource cTokenSource) {
// #define a new macro - find the name
skipWhitespace(cTokenSource);
String macroName = nextToken(cTokenSource, tokenTypes.identifier).getText();
// Examine whether the macro has parameters
skipWhitespace(cTokenSource);
if(cTokenSource.peekToken().getType() == tokenTypes.parBegin) {
// Macro has parameters - find parameter name list
throw new CompileError("Macros with parameters not supported!");
}
// Find body by gobbling tokens until the line ends
final ArrayList<Token> macroBody = new ArrayList<>();
boolean macroRead = true;
while(macroRead) {
final Token bodyToken = cTokenSource.nextToken();
if(bodyToken.getType() == tokenTypes.defineMultiline) {
// Skip the multi-line token, add a newline token and continue reading body on the next line
final CommonToken newlineToken = new CommonToken(bodyToken);
newlineToken.setType(tokenTypes.whitespace);
newlineToken.setChannel(tokenTypes.channelWhitespace);
newlineToken.setText("\n");
macroBody.add(newlineToken);
continue;
}
if(bodyToken.getChannel() == tokenTypes.channelWhitespace && bodyToken.getText().contains("\n")) {
macroRead = false;
} else {
macroBody.add(bodyToken);
}
}
defines.put(macroName, macroBody);
}
/**
* Pull first token from a source and check that it matches the expected type. Any other type will produce an error.
@ -198,7 +208,7 @@ public class CTokenSourcePreprocessor implements TokenSource {
* @param cTokenSource The token iterator
*/
private void skipWhitespace(CTokenSource cTokenSource) {
while(cTokenSource.peekToken().getChannel() == channelWhitespace)
while(cTokenSource.peekToken().getChannel() == tokenTypes.channelWhitespace)
cTokenSource.nextToken();
}

View File

@ -0,0 +1,38 @@
package dk.camelot64.kickc.preprocessor;
/**
* Tokens used by the preprocessor
*/
public class CPreprocessorTokens {
/** The channel containing whitespaces. */
final int channelWhitespace;
/** The token type for tokens containing whitespace. */
final int whitespace;
/** The token type for #define. */
final int define;
/** The token type for define multi-line. */
final int defineMultiline;
/** The token type for #undef. */
final int undef;
/** The token type for identifiers. */
final int identifier;
/** The token type for parenthesis begin. */
final int parBegin;
/** The token type for parenthesis end. */
final int parEnd;
/** The token type for comma. */
final int comma;
public CPreprocessorTokens(int channelWhitespace, int whitespace, int define, int identifier, int defineMultiline, int undef, int parBegin, int parEnd, int comma) {
this.channelWhitespace = channelWhitespace;
this.whitespace = whitespace;
this.define = define;
this.identifier = identifier;
this.defineMultiline = defineMultiline;
this.undef = undef;
this.parBegin = parBegin;
this.parEnd = parEnd;
this.comma = comma;
}
}

View File

@ -40,5 +40,6 @@ SIMPLETYPE: 'char' | 'int' ;
IDENTIFIER: [a-zA-Z_]+ ;
NUMBER: [0-9]+ ;
DEFINE: '#define' ;
UNDEF: '#undef' ;
DEFINE_CONTINUE: '\\\n' ;
WHITESPACE: [ \t\r\n]+ -> channel(1) ; // Send whitespace to the hidden WS channel

View File

@ -12,6 +12,7 @@ null
null
null
'#define'
'#undef'
'\\\n'
null
@ -29,6 +30,7 @@ SIMPLETYPE
IDENTIFIER
NUMBER
DEFINE
UNDEF
DEFINE_CONTINUE
WHITESPACE
@ -39,4 +41,4 @@ expr
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 16, 51, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 7, 2, 10, 10, 2, 12, 2, 14, 2, 13, 11, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 29, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 46, 10, 4, 12, 4, 14, 4, 49, 11, 4, 3, 4, 2, 3, 6, 5, 2, 4, 6, 2, 2, 2, 56, 2, 11, 3, 2, 2, 2, 4, 14, 3, 2, 2, 2, 6, 28, 3, 2, 2, 2, 8, 10, 5, 4, 3, 2, 9, 8, 3, 2, 2, 2, 10, 13, 3, 2, 2, 2, 11, 9, 3, 2, 2, 2, 11, 12, 3, 2, 2, 2, 12, 3, 3, 2, 2, 2, 13, 11, 3, 2, 2, 2, 14, 15, 5, 6, 4, 2, 15, 16, 7, 3, 2, 2, 16, 5, 3, 2, 2, 2, 17, 18, 8, 4, 1, 2, 18, 19, 7, 8, 2, 2, 19, 20, 7, 11, 2, 2, 20, 21, 7, 9, 2, 2, 21, 29, 5, 6, 4, 11, 22, 29, 7, 12, 2, 2, 23, 29, 7, 13, 2, 2, 24, 25, 7, 8, 2, 2, 25, 26, 5, 6, 4, 2, 26, 27, 7, 9, 2, 2, 27, 29, 3, 2, 2, 2, 28, 17, 3, 2, 2, 2, 28, 22, 3, 2, 2, 2, 28, 23, 3, 2, 2, 2, 28, 24, 3, 2, 2, 2, 29, 47, 3, 2, 2, 2, 30, 31, 12, 7, 2, 2, 31, 32, 7, 4, 2, 2, 32, 46, 5, 6, 4, 8, 33, 34, 12, 6, 2, 2, 34, 35, 7, 5, 2, 2, 35, 46, 5, 6, 4, 7, 36, 37, 12, 5, 2, 2, 37, 38, 7, 6, 2, 2, 38, 46, 5, 6, 4, 6, 39, 40, 12, 4, 2, 2, 40, 41, 7, 7, 2, 2, 41, 46, 5, 6, 4, 5, 42, 43, 12, 3, 2, 2, 43, 44, 7, 10, 2, 2, 44, 46, 5, 6, 4, 4, 45, 30, 3, 2, 2, 2, 45, 33, 3, 2, 2, 2, 45, 36, 3, 2, 2, 2, 45, 39, 3, 2, 2, 2, 45, 42, 3, 2, 2, 2, 46, 49, 3, 2, 2, 2, 47, 45, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 7, 3, 2, 2, 2, 49, 47, 3, 2, 2, 2, 6, 11, 28, 45, 47]
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 17, 51, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 3, 2, 7, 2, 10, 10, 2, 12, 2, 14, 2, 13, 11, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 29, 10, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 46, 10, 4, 12, 4, 14, 4, 49, 11, 4, 3, 4, 2, 3, 6, 5, 2, 4, 6, 2, 2, 2, 56, 2, 11, 3, 2, 2, 2, 4, 14, 3, 2, 2, 2, 6, 28, 3, 2, 2, 2, 8, 10, 5, 4, 3, 2, 9, 8, 3, 2, 2, 2, 10, 13, 3, 2, 2, 2, 11, 9, 3, 2, 2, 2, 11, 12, 3, 2, 2, 2, 12, 3, 3, 2, 2, 2, 13, 11, 3, 2, 2, 2, 14, 15, 5, 6, 4, 2, 15, 16, 7, 3, 2, 2, 16, 5, 3, 2, 2, 2, 17, 18, 8, 4, 1, 2, 18, 19, 7, 8, 2, 2, 19, 20, 7, 11, 2, 2, 20, 21, 7, 9, 2, 2, 21, 29, 5, 6, 4, 11, 22, 29, 7, 12, 2, 2, 23, 29, 7, 13, 2, 2, 24, 25, 7, 8, 2, 2, 25, 26, 5, 6, 4, 2, 26, 27, 7, 9, 2, 2, 27, 29, 3, 2, 2, 2, 28, 17, 3, 2, 2, 2, 28, 22, 3, 2, 2, 2, 28, 23, 3, 2, 2, 2, 28, 24, 3, 2, 2, 2, 29, 47, 3, 2, 2, 2, 30, 31, 12, 7, 2, 2, 31, 32, 7, 4, 2, 2, 32, 46, 5, 6, 4, 8, 33, 34, 12, 6, 2, 2, 34, 35, 7, 5, 2, 2, 35, 46, 5, 6, 4, 7, 36, 37, 12, 5, 2, 2, 37, 38, 7, 6, 2, 2, 38, 46, 5, 6, 4, 6, 39, 40, 12, 4, 2, 2, 40, 41, 7, 7, 2, 2, 41, 46, 5, 6, 4, 5, 42, 43, 12, 3, 2, 2, 43, 44, 7, 10, 2, 2, 44, 46, 5, 6, 4, 4, 45, 30, 3, 2, 2, 2, 45, 33, 3, 2, 2, 2, 45, 36, 3, 2, 2, 2, 45, 39, 3, 2, 2, 2, 45, 42, 3, 2, 2, 2, 46, 49, 3, 2, 2, 2, 47, 45, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 7, 3, 2, 2, 2, 49, 47, 3, 2, 2, 2, 6, 11, 28, 45, 47]

View File

@ -10,8 +10,9 @@ SIMPLETYPE=9
IDENTIFIER=10
NUMBER=11
DEFINE=12
DEFINE_CONTINUE=13
WHITESPACE=14
UNDEF=13
DEFINE_CONTINUE=14
WHITESPACE=15
';'=1
'*'=2
'/'=3
@ -21,4 +22,5 @@ WHITESPACE=14
')'=7
','=8
'#define'=12
'\\\n'=13
'#undef'=13
'\\\n'=14

View File

@ -12,6 +12,7 @@ null
null
null
'#define'
'#undef'
'\\\n'
null
@ -29,6 +30,7 @@ SIMPLETYPE
IDENTIFIER
NUMBER
DEFINE
UNDEF
DEFINE_CONTINUE
WHITESPACE
@ -45,6 +47,7 @@ SIMPLETYPE
IDENTIFIER
NUMBER
DEFINE
UNDEF
DEFINE_CONTINUE
WHITESPACE
@ -56,4 +59,4 @@ mode names:
DEFAULT_MODE
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 16, 84, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 55, 10, 10, 3, 11, 6, 11, 58, 10, 11, 13, 11, 14, 11, 59, 3, 12, 6, 12, 63, 10, 12, 13, 12, 14, 12, 64, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 6, 15, 79, 10, 15, 13, 15, 14, 15, 80, 3, 15, 3, 15, 2, 2, 16, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 3, 2, 5, 5, 2, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 2, 87, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 3, 31, 3, 2, 2, 2, 5, 33, 3, 2, 2, 2, 7, 35, 3, 2, 2, 2, 9, 37, 3, 2, 2, 2, 11, 39, 3, 2, 2, 2, 13, 41, 3, 2, 2, 2, 15, 43, 3, 2, 2, 2, 17, 45, 3, 2, 2, 2, 19, 54, 3, 2, 2, 2, 21, 57, 3, 2, 2, 2, 23, 62, 3, 2, 2, 2, 25, 66, 3, 2, 2, 2, 27, 74, 3, 2, 2, 2, 29, 78, 3, 2, 2, 2, 31, 32, 7, 61, 2, 2, 32, 4, 3, 2, 2, 2, 33, 34, 7, 44, 2, 2, 34, 6, 3, 2, 2, 2, 35, 36, 7, 49, 2, 2, 36, 8, 3, 2, 2, 2, 37, 38, 7, 45, 2, 2, 38, 10, 3, 2, 2, 2, 39, 40, 7, 47, 2, 2, 40, 12, 3, 2, 2, 2, 41, 42, 7, 42, 2, 2, 42, 14, 3, 2, 2, 2, 43, 44, 7, 43, 2, 2, 44, 16, 3, 2, 2, 2, 45, 46, 7, 46, 2, 2, 46, 18, 3, 2, 2, 2, 47, 48, 7, 101, 2, 2, 48, 49, 7, 106, 2, 2, 49, 50, 7, 99, 2, 2, 50, 55, 7, 116, 2, 2, 51, 52, 7, 107, 2, 2, 52, 53, 7, 112, 2, 2, 53, 55, 7, 118, 2, 2, 54, 47, 3, 2, 2, 2, 54, 51, 3, 2, 2, 2, 55, 20, 3, 2, 2, 2, 56, 58, 9, 2, 2, 2, 57, 56, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 59, 60, 3, 2, 2, 2, 60, 22, 3, 2, 2, 2, 61, 63, 9, 3, 2, 2, 62, 61, 3, 2, 2, 2, 63, 64, 3, 2, 2, 2, 64, 62, 3, 2, 2, 2, 64, 65, 3, 2, 2, 2, 65, 24, 3, 2, 2, 2, 66, 67, 7, 37, 2, 2, 67, 68, 7, 102, 2, 2, 68, 69, 7, 103, 2, 2, 69, 70, 7, 104, 2, 2, 70, 71, 7, 107, 2, 2, 71, 72, 7, 112, 2, 2, 72, 73, 7, 103, 2, 2, 73, 26, 3, 2, 2, 2, 74, 75, 7, 94, 2, 2, 75, 76, 7, 12, 2, 2, 76, 28, 3, 2, 2, 2, 77, 79, 9, 4, 2, 2, 78, 77, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 80, 78, 3, 2, 2, 2, 80, 81, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 83, 8, 15, 2, 2, 83, 30, 3, 2, 2, 2, 7, 2, 54, 59, 64, 80, 3, 2, 3, 2]
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 17, 93, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 57, 10, 10, 3, 11, 6, 11, 60, 10, 11, 13, 11, 14, 11, 61, 3, 12, 6, 12, 65, 10, 12, 13, 12, 14, 12, 66, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 6, 16, 88, 10, 16, 13, 16, 14, 16, 89, 3, 16, 3, 16, 2, 2, 17, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 3, 2, 5, 5, 2, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 2, 96, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 3, 33, 3, 2, 2, 2, 5, 35, 3, 2, 2, 2, 7, 37, 3, 2, 2, 2, 9, 39, 3, 2, 2, 2, 11, 41, 3, 2, 2, 2, 13, 43, 3, 2, 2, 2, 15, 45, 3, 2, 2, 2, 17, 47, 3, 2, 2, 2, 19, 56, 3, 2, 2, 2, 21, 59, 3, 2, 2, 2, 23, 64, 3, 2, 2, 2, 25, 68, 3, 2, 2, 2, 27, 76, 3, 2, 2, 2, 29, 83, 3, 2, 2, 2, 31, 87, 3, 2, 2, 2, 33, 34, 7, 61, 2, 2, 34, 4, 3, 2, 2, 2, 35, 36, 7, 44, 2, 2, 36, 6, 3, 2, 2, 2, 37, 38, 7, 49, 2, 2, 38, 8, 3, 2, 2, 2, 39, 40, 7, 45, 2, 2, 40, 10, 3, 2, 2, 2, 41, 42, 7, 47, 2, 2, 42, 12, 3, 2, 2, 2, 43, 44, 7, 42, 2, 2, 44, 14, 3, 2, 2, 2, 45, 46, 7, 43, 2, 2, 46, 16, 3, 2, 2, 2, 47, 48, 7, 46, 2, 2, 48, 18, 3, 2, 2, 2, 49, 50, 7, 101, 2, 2, 50, 51, 7, 106, 2, 2, 51, 52, 7, 99, 2, 2, 52, 57, 7, 116, 2, 2, 53, 54, 7, 107, 2, 2, 54, 55, 7, 112, 2, 2, 55, 57, 7, 118, 2, 2, 56, 49, 3, 2, 2, 2, 56, 53, 3, 2, 2, 2, 57, 20, 3, 2, 2, 2, 58, 60, 9, 2, 2, 2, 59, 58, 3, 2, 2, 2, 60, 61, 3, 2, 2, 2, 61, 59, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 22, 3, 2, 2, 2, 63, 65, 9, 3, 2, 2, 64, 63, 3, 2, 2, 2, 65, 66, 3, 2, 2, 2, 66, 64, 3, 2, 2, 2, 66, 67, 3, 2, 2, 2, 67, 24, 3, 2, 2, 2, 68, 69, 7, 37, 2, 2, 69, 70, 7, 102, 2, 2, 70, 71, 7, 103, 2, 2, 71, 72, 7, 104, 2, 2, 72, 73, 7, 107, 2, 2, 73, 74, 7, 112, 2, 2, 74, 75, 7, 103, 2, 2, 75, 26, 3, 2, 2, 2, 76, 77, 7, 37, 2, 2, 77, 78, 7, 119, 2, 2, 78, 79, 7, 112, 2, 2, 79, 80, 7, 102, 2, 2, 80, 81, 7, 103, 2, 2, 81, 82, 7, 104, 2, 2, 82, 28, 3, 2, 2, 2, 83, 84, 7, 94, 2, 2, 84, 85, 7, 12, 2, 2, 85, 30, 3, 2, 2, 2, 86, 88, 9, 4, 2, 2, 87, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 87, 3, 2, 2, 2, 89, 90, 3, 2, 2, 2, 90, 91, 3, 2, 2, 2, 91, 92, 8, 16, 2, 2, 92, 32, 3, 2, 2, 2, 7, 2, 56, 61, 66, 89, 3, 2, 3, 2]

View File

@ -20,8 +20,8 @@ public class MacrosLexer extends Lexer {
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PAR_BEGIN=6, PAR_END=7, COMMA=8,
SIMPLETYPE=9, IDENTIFIER=10, NUMBER=11, DEFINE=12, DEFINE_CONTINUE=13,
WHITESPACE=14;
SIMPLETYPE=9, IDENTIFIER=10, NUMBER=11, DEFINE=12, UNDEF=13, DEFINE_CONTINUE=14,
WHITESPACE=15;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@ -33,7 +33,8 @@ public class MacrosLexer extends Lexer {
private static String[] makeRuleNames() {
return new String[] {
"T__0", "T__1", "T__2", "T__3", "T__4", "PAR_BEGIN", "PAR_END", "COMMA",
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "DEFINE_CONTINUE", "WHITESPACE"
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "UNDEF", "DEFINE_CONTINUE",
"WHITESPACE"
};
}
public static final String[] ruleNames = makeRuleNames();
@ -41,14 +42,15 @@ public class MacrosLexer extends Lexer {
private static String[] makeLiteralNames() {
return new String[] {
null, "';'", "'*'", "'/'", "'+'", "'-'", "'('", "')'", "','", null, null,
null, "'#define'", "'\\\n'"
null, "'#define'", "'#undef'", "'\\\n'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, null, null, null, null, "PAR_BEGIN", "PAR_END", "COMMA",
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "DEFINE_CONTINUE", "WHITESPACE"
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "UNDEF", "DEFINE_CONTINUE",
"WHITESPACE"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
@ -112,28 +114,30 @@ public class MacrosLexer extends Lexer {
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\20T\b\1\4\2\t\2\4"+
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\21]\b\1\4\2\t\2\4"+
"\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+
"\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3"+
"\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\5\n\67"+
"\n\n\3\13\6\13:\n\13\r\13\16\13;\3\f\6\f?\n\f\r\f\16\f@\3\r\3\r\3\r\3"+
"\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\17\6\17O\n\17\r\17\16\17P\3\17\3\17"+
"\2\2\20\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17"+
"\35\20\3\2\5\5\2C\\aac|\3\2\62;\5\2\13\f\17\17\"\"\2W\2\3\3\2\2\2\2\5"+
"\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2"+
"\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33"+
"\3\2\2\2\2\35\3\2\2\2\3\37\3\2\2\2\5!\3\2\2\2\7#\3\2\2\2\t%\3\2\2\2\13"+
"\'\3\2\2\2\r)\3\2\2\2\17+\3\2\2\2\21-\3\2\2\2\23\66\3\2\2\2\259\3\2\2"+
"\2\27>\3\2\2\2\31B\3\2\2\2\33J\3\2\2\2\35N\3\2\2\2\37 \7=\2\2 \4\3\2\2"+
"\2!\"\7,\2\2\"\6\3\2\2\2#$\7\61\2\2$\b\3\2\2\2%&\7-\2\2&\n\3\2\2\2\'("+
"\7/\2\2(\f\3\2\2\2)*\7*\2\2*\16\3\2\2\2+,\7+\2\2,\20\3\2\2\2-.\7.\2\2"+
".\22\3\2\2\2/\60\7e\2\2\60\61\7j\2\2\61\62\7c\2\2\62\67\7t\2\2\63\64\7"+
"k\2\2\64\65\7p\2\2\65\67\7v\2\2\66/\3\2\2\2\66\63\3\2\2\2\67\24\3\2\2"+
"\28:\t\2\2\298\3\2\2\2:;\3\2\2\2;9\3\2\2\2;<\3\2\2\2<\26\3\2\2\2=?\t\3"+
"\2\2>=\3\2\2\2?@\3\2\2\2@>\3\2\2\2@A\3\2\2\2A\30\3\2\2\2BC\7%\2\2CD\7"+
"f\2\2DE\7g\2\2EF\7h\2\2FG\7k\2\2GH\7p\2\2HI\7g\2\2I\32\3\2\2\2JK\7^\2"+
"\2KL\7\f\2\2L\34\3\2\2\2MO\t\4\2\2NM\3\2\2\2OP\3\2\2\2PN\3\2\2\2PQ\3\2"+
"\2\2QR\3\2\2\2RS\b\17\2\2S\36\3\2\2\2\7\2\66;@P\3\2\3\2";
"\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\3\2\3\2\3\3\3\3\3\4"+
"\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3"+
"\n\5\n9\n\n\3\13\6\13<\n\13\r\13\16\13=\3\f\6\fA\n\f\r\f\16\fB\3\r\3\r"+
"\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17"+
"\3\17\3\20\6\20X\n\20\r\20\16\20Y\3\20\3\20\2\2\21\3\3\5\4\7\5\t\6\13"+
"\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21\3\2\5\5\2C\\"+
"aac|\3\2\62;\5\2\13\f\17\17\"\"\2`\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2"+
"\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3"+
"\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2"+
"\2\2\37\3\2\2\2\3!\3\2\2\2\5#\3\2\2\2\7%\3\2\2\2\t\'\3\2\2\2\13)\3\2\2"+
"\2\r+\3\2\2\2\17-\3\2\2\2\21/\3\2\2\2\238\3\2\2\2\25;\3\2\2\2\27@\3\2"+
"\2\2\31D\3\2\2\2\33L\3\2\2\2\35S\3\2\2\2\37W\3\2\2\2!\"\7=\2\2\"\4\3\2"+
"\2\2#$\7,\2\2$\6\3\2\2\2%&\7\61\2\2&\b\3\2\2\2\'(\7-\2\2(\n\3\2\2\2)*"+
"\7/\2\2*\f\3\2\2\2+,\7*\2\2,\16\3\2\2\2-.\7+\2\2.\20\3\2\2\2/\60\7.\2"+
"\2\60\22\3\2\2\2\61\62\7e\2\2\62\63\7j\2\2\63\64\7c\2\2\649\7t\2\2\65"+
"\66\7k\2\2\66\67\7p\2\2\679\7v\2\28\61\3\2\2\28\65\3\2\2\29\24\3\2\2\2"+
":<\t\2\2\2;:\3\2\2\2<=\3\2\2\2=;\3\2\2\2=>\3\2\2\2>\26\3\2\2\2?A\t\3\2"+
"\2@?\3\2\2\2AB\3\2\2\2B@\3\2\2\2BC\3\2\2\2C\30\3\2\2\2DE\7%\2\2EF\7f\2"+
"\2FG\7g\2\2GH\7h\2\2HI\7k\2\2IJ\7p\2\2JK\7g\2\2K\32\3\2\2\2LM\7%\2\2M"+
"N\7w\2\2NO\7p\2\2OP\7f\2\2PQ\7g\2\2QR\7h\2\2R\34\3\2\2\2ST\7^\2\2TU\7"+
"\f\2\2U\36\3\2\2\2VX\t\4\2\2WV\3\2\2\2XY\3\2\2\2YW\3\2\2\2YZ\3\2\2\2Z"+
"[\3\2\2\2[\\\b\20\2\2\\ \3\2\2\2\7\28=BY\3\2\3\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {

View File

@ -10,8 +10,9 @@ SIMPLETYPE=9
IDENTIFIER=10
NUMBER=11
DEFINE=12
DEFINE_CONTINUE=13
WHITESPACE=14
UNDEF=13
DEFINE_CONTINUE=14
WHITESPACE=15
';'=1
'*'=2
'/'=3
@ -21,4 +22,5 @@ WHITESPACE=14
')'=7
','=8
'#define'=12
'\\\n'=13
'#undef'=13
'\\\n'=14

View File

@ -20,8 +20,8 @@ public class MacrosParser extends Parser {
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PAR_BEGIN=6, PAR_END=7, COMMA=8,
SIMPLETYPE=9, IDENTIFIER=10, NUMBER=11, DEFINE=12, DEFINE_CONTINUE=13,
WHITESPACE=14;
SIMPLETYPE=9, IDENTIFIER=10, NUMBER=11, DEFINE=12, UNDEF=13, DEFINE_CONTINUE=14,
WHITESPACE=15;
public static final int
RULE_stmtSeq = 0, RULE_stmt = 1, RULE_expr = 2;
private static String[] makeRuleNames() {
@ -34,14 +34,15 @@ public class MacrosParser extends Parser {
private static String[] makeLiteralNames() {
return new String[] {
null, "';'", "'*'", "'/'", "'+'", "'-'", "'('", "')'", "','", null, null,
null, "'#define'", "'\\\n'"
null, "'#define'", "'#undef'", "'\\\n'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, null, null, null, null, "PAR_BEGIN", "PAR_END", "COMMA",
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "DEFINE_CONTINUE", "WHITESPACE"
"SIMPLETYPE", "IDENTIFIER", "NUMBER", "DEFINE", "UNDEF", "DEFINE_CONTINUE",
"WHITESPACE"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
@ -506,7 +507,7 @@ public class MacrosParser extends Parser {
}
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\20\63\4\2\t\2\4\3"+
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\21\63\4\2\t\2\4\3"+
"\t\3\4\4\t\4\3\2\7\2\n\n\2\f\2\16\2\r\13\2\3\3\3\3\3\3\3\4\3\4\3\4\3\4"+
"\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4\35\n\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3"+
"\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\7\4.\n\4\f\4\16\4\61\13\4\3\4\2\3\6\5\2"+

View File

@ -1,7 +1,8 @@
package dk.camelot64.kickc.parsing.macros;
import dk.camelot64.kickc.preprocessor.CTokenSourcePreprocessor;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.preprocessor.CPreprocessor;
import dk.camelot64.kickc.preprocessor.CPreprocessorTokens;
import org.antlr.v4.runtime.*;
import org.junit.Test;
@ -74,6 +75,16 @@ public class TestMacrosParser {
assertEquals("name:a;+(name:b,num:1);", parse("#define A a;\\\nb\nA+1;"));
}
/**
* Test define and undef
*/
@Test
public void testUndef() {
// A simple unused define
assertEquals("name:a;name:A;", parse("#define A a\nA;\n#undef A\nA;"));
}
/**
* Test define with parameters
*/
@ -106,7 +117,8 @@ public class TestMacrosParser {
}
});
final CTokenSourcePreprocessor expandedTokenSource = new CTokenSourcePreprocessor(lexer, CHANNEL_WHITESPACE, MacrosLexer.WHITESPACE, MacrosLexer.DEFINE, MacrosLexer.IDENTIFIER, MacrosLexer.PAR_BEGIN, MacrosLexer.PAR_END, MacrosLexer.COMMA, MacrosLexer.DEFINE_CONTINUE);
final CPreprocessorTokens preprocessorTokens = new CPreprocessorTokens(CHANNEL_WHITESPACE, MacrosLexer.WHITESPACE, MacrosLexer.DEFINE, MacrosLexer.IDENTIFIER, MacrosLexer.DEFINE_CONTINUE, MacrosLexer.UNDEF, MacrosLexer.PAR_BEGIN, MacrosLexer.PAR_END, MacrosLexer.COMMA);
final CPreprocessor expandedTokenSource = new CPreprocessor(lexer, preprocessorTokens);
MacrosParser parser = new MacrosParser(new CommonTokenStream(expandedTokenSource));
parser.setBuildParseTree(true);
parser.addErrorListener(new BaseErrorListener() {

View File

@ -37,9 +37,10 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testPreprocessor0() throws IOException, URISyntaxException {
compileAndCompare("preprocessor-0");
public void testPreprocessor2() throws IOException, URISyntaxException {
compileAndCompare("preprocessor-2", log());
}
@Test
@ -47,6 +48,11 @@ public class TestPrograms {
compileAndCompare("preprocessor-1");
}
@Test
public void testPreprocessor0() throws IOException, URISyntaxException {
compileAndCompare("preprocessor-0");
}
@Test
public void testMaCoalesceProblem() throws IOException, URISyntaxException {
compileAndCompare("ma_coalesce_problem");

View File

@ -0,0 +1,12 @@
// Test the preprocessor
// #define and #undef - expected output on screen is xa
char * SCREEN = 0x0400;
void main() {
char a = 'a';
#define a 'x'
SCREEN[0] = a;
#undef a
SCREEN[1] = a;
}