Skip to content

Weird error #2498

Closed
Closed

Description

@IdkGoodName
  • 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;

Activity

  1. IdkGoodName commented on Feb 17, 2019

    @IdkGoodName
    Author

    I fixed this. If you are having same error, change '\`', '\'', '\"' to [`], ['], ["].

  2. KvanTTT commented on Jun 29, 2021

    @KvanTTT
    Member

    Please reopen. This error should be reported correctly instead of throwing RuntimeException.

  3. added a commit that references this issue on Oct 17, 2021
    03344ec
  4. reopened this on Oct 17, 2021
  5. added this to the 4.9.3 milestone on Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions