diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 index 224962298..c277c84ca 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 +++ b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 @@ -6,11 +6,10 @@ tokens { TYPEDEFNAME } @header { } -@lexer::members { +@members { /** The C-Parser. Used for importing C-files and communicating with the Parser about typedefs. */ CParser cParser; - /** True of the next string is the name of a C-file to import*/ boolean importEnter = false; /** True if the next CURLY starts ASM_MODE */ @@ -35,7 +34,7 @@ SEMICOLON: ';' ; COLON: ':'; COMMA: ',' ; RANGE : '..' ; -QUESTION : '?' ; +CONDITION : '?' ; DOT : '.' ; ARROW : '->' ; PLUS: '+'; @@ -128,7 +127,7 @@ fragment BINDIGIT : [0-1]; fragment DECDIGIT : [0-9]; fragment HEXDIGIT : [0-9a-fA-F]; -//Names +// Names NAME : NAME_START NAME_CHAR* {if(cParser.isTypedef(getText())) setType(TYPEDEFNAME); }; fragment NAME_START : [a-zA-Z_]; fragment NAME_CHAR : [a-zA-Z0-9_]; diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java index fab99f3de..c7553d7be 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.java @@ -20,7 +20,7 @@ public class KickCLexer extends Lexer { new PredictionContextCache(); public static final int TYPEDEFNAME=1, CURLY_BEGIN=2, CURLY_END=3, BRACKET_BEGIN=4, BRACKET_END=5, - PAR_BEGIN=6, PAR_END=7, SEMICOLON=8, COLON=9, COMMA=10, RANGE=11, QUESTION=12, + PAR_BEGIN=6, PAR_END=7, SEMICOLON=8, COLON=9, COMMA=10, RANGE=11, CONDITION=12, DOT=13, ARROW=14, PLUS=15, MINUS=16, ASTERISK=17, DIVIDE=18, MODULO=19, INC=20, DEC=21, AND=22, BIT_NOT=23, BIT_XOR=24, BIT_OR=25, SHIFT_LEFT=26, SHIFT_RIGHT=27, EQUAL=28, NOT_EQUAL=29, LESS_THAN=30, LESS_THAN_EQUAL=31, @@ -55,7 +55,7 @@ public class KickCLexer extends Lexer { public static final String[] ruleNames = { "CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END", "PAR_BEGIN", - "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "QUESTION", "DOT", + "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION", "DOT", "ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC", "DEC", "AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT", "EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL", "GREATER_THAN", @@ -96,7 +96,7 @@ public class KickCLexer extends Lexer { }; private static final String[] _SYMBOLIC_NAMES = { null, "TYPEDEFNAME", "CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END", - "PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "QUESTION", + "PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION", "DOT", "ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC", "DEC", "AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT", "EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL", @@ -155,7 +155,6 @@ public class KickCLexer extends Lexer { /** The C-Parser. Used for importing C-files and communicating with the Parser about typedefs. */ CParser cParser; - /** True of the next string is the name of a C-file to import*/ boolean importEnter = false; /** True if the next CURLY starts ASM_MODE */ diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens index a927b3e3a..c1a5d096f 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens +++ b/src/main/java/dk/camelot64/kickc/parser/KickCLexer.tokens @@ -9,7 +9,7 @@ SEMICOLON=8 COLON=9 COMMA=10 RANGE=11 -QUESTION=12 +CONDITION=12 DOT=13 ARROW=14 PLUS=15 diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 b/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 index 55c69767b..f13c41f91 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 +++ b/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 @@ -7,7 +7,7 @@ options { tokenVocab=KickCLexer; } } -@parser::members { +@members { CParser cParser; public KickCParser(TokenStream input, CParser cParser) { diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCParser.java b/src/main/java/dk/camelot64/kickc/parser/KickCParser.java index 78dc6e919..ff8308e56 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCParser.java +++ b/src/main/java/dk/camelot64/kickc/parser/KickCParser.java @@ -20,7 +20,7 @@ public class KickCParser extends Parser { new PredictionContextCache(); public static final int TYPEDEFNAME=1, CURLY_BEGIN=2, CURLY_END=3, BRACKET_BEGIN=4, BRACKET_END=5, - PAR_BEGIN=6, PAR_END=7, SEMICOLON=8, COLON=9, COMMA=10, RANGE=11, QUESTION=12, + PAR_BEGIN=6, PAR_END=7, SEMICOLON=8, COLON=9, COMMA=10, RANGE=11, CONDITION=12, DOT=13, ARROW=14, PLUS=15, MINUS=16, ASTERISK=17, DIVIDE=18, MODULO=19, INC=20, DEC=21, AND=22, BIT_NOT=23, BIT_XOR=24, BIT_OR=25, SHIFT_LEFT=26, SHIFT_RIGHT=27, EQUAL=28, NOT_EQUAL=29, LESS_THAN=30, LESS_THAN_EQUAL=31, @@ -83,7 +83,7 @@ public class KickCParser extends Parser { }; private static final String[] _SYMBOLIC_NAMES = { null, "TYPEDEFNAME", "CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END", - "PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "QUESTION", + "PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION", "DOT", "ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC", "DEC", "AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT", "EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL", @@ -4741,7 +4741,7 @@ public class KickCParser extends Parser { setState(581); if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); setState(582); - match(QUESTION); + match(CONDITION); setState(583); expr(0); setState(584); diff --git a/src/main/java/dk/camelot64/kickc/parser/KickCParser.tokens b/src/main/java/dk/camelot64/kickc/parser/KickCParser.tokens index a927b3e3a..c1a5d096f 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickCParser.tokens +++ b/src/main/java/dk/camelot64/kickc/parser/KickCParser.tokens @@ -9,7 +9,7 @@ SEMICOLON=8 COLON=9 COMMA=10 RANGE=11 -QUESTION=12 +CONDITION=12 DOT=13 ARROW=14 PLUS=15