-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Milestone
Description
- I am not submitting a question on how to use ANTLR
- I have done a search of the existing issues to make sure I'm not sending in a duplicate
This is error I am getting:
Exception in thread "main" java.lang.RuntimeException: set is empty
at org.antlr.v4.runtime.misc.IntervalSet.getMaxElement(IntervalSet.java:421)
at org.antlr.v4.runtime.atn.ATNSerializer.serialize(ATNSerializer.java:169)
at org.antlr.v4.runtime.atn.ATNSerializer.getSerialized(ATNSerializer.java:601)
at org.antlr.v4.Tool.generateInterpreterData(Tool.java:745)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:400)
at org.antlr.v4.Tool.process(Tool.java:361)
at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:328)
at org.antlr.v4.Tool.main(Tool.java:172)
This is not first time I am getting this error. Of course, this is error in my Grammar file. But thing is, I cannot know which line is producing this error.
This is my grammar file:
grammar RedTea;
//>-> Lexer <-<
//=> Ignored
Comment : ('//' ~[\r\n\u2028\u2029]* | '/*' .*? '*/') -> channel(HIDDEN);
Whitespace : [\r\n \t] -> channel(HIDDEN);
//=> Types
StringLiteral : '\'' ((~[\'\\] | (Escape '\'' | AnyES))*) '\'' | '"' ((~[\"\\] | (Escape '"' | AnyES))*) '"';
SymbolLiteral : '`' ((~[`\\] | (Escape '`' | AnyES))) '`';
NumberLiteral : [0-9]+;
BooleanLiteral : ('true' | 'false');
NullLiteral : 'null';
Identifier : [A-Za-z_][A-Za-z_0-9]*;
//=> Keywords
//-> Variable declaration
Const : 'const';
Let : 'let';
Var : 'var';
//-> Declarations
Class : 'class';
Function : 'function';
Namespace : 'namespace';
Enum : 'enum';
Interface : 'interface';
Structure : 'struct';
//-> Import
Import : 'import';
As : 'as';
From : 'from';
//-> Class
This : 'this';
Static : 'static';
Abstract : 'abstract';
Protected : 'protected';
Private : 'private';
Public : 'public';
Readonly : 'readonly';
//=> Operators
// Prefix
New : 'new';
Params : '...';
Tilde : '~';
Not : '!';
At : '@';
Escape : '\\';
// Infix
Plus : '+';
Minus : '-';
Star : '*';
Devide : '/';
Dot : '.';
Colon : ':';
DColon : '::';
Modulus : '%';
XOr : '^';
And : '&';
Or : '|';
LoAnd : '&&';
LoOr : '||';
Exponentiation : '**';
Question : '?';
Mt : '>';
Lt : '<';
Equal : '=';
Equals : '==';
NEquals : '!=';
MtEquals : '>=';
LtEquals : '<=';
PlusEquals : '+=';
MinusEquals : '-=';
StarEquals : '*=';
DevideEquals : '/=';
ModulusEquals : '%=';
XOrEquals : '^=';
OrEquals : '|=';
AndEquals : '&=';
ExpEquals : '**=';
// Postfix
Comma : ',';
Semicolon : ';';
Increment : '++';
Decrement : '--';
Sharp : '#';
// Brackets
OpenParan : '(';
CloseParan : ')';
OpenBrack : '[';
CloseBrack : ']';
OpenBrace : '{';
CloseBrace : '}';
//=> Other
// Escape sequences
HexDigit : [0-9a-fA-F];
AnyES : UnicodeES | Unicode2ES | HexES | CharES;
HexES : Escape [xX] HexDigit HexDigit;
UnicodeES : Escape [uU] HexDigit HexDigit HexDigit HexDigit;
Unicode2ES : Escape [uU] OpenBrace HexDigit+ CloseBrace;
CharES : Escape . | Escape Escape;
// >-> Parser <-<
// Code
inlineCode : varDeclaration | value;
blockStatement : (inlineCode Semicolon)*;
// Management
importNamespace : Identifier (DColon Identifier)*;
imports : Import (As? Identifier)? From importNamespace;
// Values
valueProperty : (Dot Identifier | valueIndex | valueCaller);
valueCaller : OpenParan value (Comma value)* CloseParan;
valueIndex : OpenBrack value CloseBrack;
valueNumber : NumberLiteral (Dot NumberLiteral)? Identifier?;
valueString : Identifier? StringLiteral;
valueSymbol : Identifier? SymbolLiteral;
valueMain : (OpenParan value CloseParan | Identifier | valueString | valueSymbol) valueProperty*;
value : valueNumber | valueMain | NullLiteral;
// Declarations
varDeclaration : (Var | Let | Const) Identifier Equal value;