Getting error when i have tried to update RPGLE Grammar 4.5.3 to 4.7(Antlr )

56 views
Skip to first unread message

Om Ujjawal

unread,
Nov 27, 2017, 2:18:09 AM11/27/17
to antlr-discussion
When i have tried to update RPGLE Grammar 4.5.3 to Antlr 4.7 getting below error on line no 1346 inside RpgleLexer.g4. Please see the below line no and error.

Line No - 1346 :-  CS_FieldLength: [+\\- 0-9][+\\- 0-9][+\\- 0-9][+\\- 0-9][+\\- 0-9]  {getCharPositionInLine()==68}?;

error(174): RpgLexer.g4:1346:16: string literals and sets cannot be empty: '\\'..' '
error(174): RpgLexer.g4:1346:26: string literals and sets cannot be empty: '\\'..' '
error(174): RpgLexer.g4:1346:36: string literals and sets cannot be empty: '\\'..' '
error(174): RpgLexer.g4:1346:46: string literals and sets cannot be empty: '\\'..' '
error(174): RpgLexer.g4:1346:56: string literals and sets cannot be empty: '\\'..' '

After fixed this issue [+\\- 0-9] to [+\\ - 0-9] gettting below error or also when i deleted the line 1346 inside the RpgleLexer.g4 getting the same error. please see the below:-

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.codegen.model.SerializedATN.<init>(SerializedATN.java:22)
        at org.antlr.v4.codegen.model.Recognizer.<init>(Recognizer.java:64)
        at org.antlr.v4.codegen.model.Lexer.<init>(Lexer.java:27)
        at org.antlr.v4.codegen.OutputModelController.lexer(OutputModelController.java:151)
        at org.antlr.v4.codegen.OutputModelController.buildLexerOutputModel(OutputModelController.java:104)
        at org.antlr.v4.codegen.CodeGenerator.generateLexer(CodeGenerator.java:119)
        at org.antlr.v4.codegen.CodeGenPipeline.process(CodeGenPipeline.java:54)
        at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:404)
        at org.antlr.v4.Tool.process(Tool.java:362)
        at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:321)
        at org.antlr.v4.Tool.main(Tool.java:168)
Please guide me....

Ivan Kochurkin

unread,
Nov 27, 2017, 7:31:28 AM11/27/17
to antlr-discussion
As I understand you should escape minus character:

[+\\\- 0-9]

It recognized as a range operator (like on the digitals range).

понедельник, 27 ноября 2017 г., 10:18:09 UTC+3 пользователь Om Ujjawal написал:

Om Ujjawal

unread,
Nov 28, 2017, 5:56:28 AM11/28/17
to antlr-discussion
Thanks Ivan Kochurkin, 

It's work for me. i have one more problem. getting the same error from below code inside lexer:-

FROM_POSITION: WORD5 [a-zA-Z0-9\+\- ][a-zA-Z0-9 ]{getCharPositionInLine()==32}?;

When i have made the changed above code (FROM_POSITION: WORD5 [a-zA-Z0-9\\+\\\- ][a-zA-Z0-9 ]{getCharPositionInLine()==32}?;) getting below warning.

 warning(180): RpgLexer.g4:824:21: chars '\\' used multiple times in set [a-zA-Z0-9\\+\\\- ]

It is correct, Please guide...

Ivan Kochurkin

unread,
Nov 29, 2017, 6:49:02 PM11/29/17
to antlr-discussion
Just remove one escaped backslash \\

[a-zA-Z0-9\\+\- ]

вторник, 28 ноября 2017 г., 13:56:28 UTC+3 пользователь Om Ujjawal написал:

Om Ujjawal

unread,
Nov 29, 2017, 11:29:34 PM11/29/17
to antlr-discussion
Thanks Ivan Kochurkin for your suggestion, It's working for me.

only one doubt is renaming related to the below code:-

CS_FactorContent: (~[\r\n'\'' :]
{(getCharPositionInLine()>=12 && getCharPositionInLine()<=25)
|| (getCharPositionInLine()>=36 && getCharPositionInLine()<=49)
}?
)+;
CS_ResultContent: (~[\r\n'\'' :]
{(getCharPositionInLine()>=50 && getCharPositionInLine()<=63)}?
)+ -> type(CS_FactorContent);

getting below error :

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.codegen.model.SerializedATN.<init>(SerializedATN.java:22)
        at org.antlr.v4.codegen.model.Recognizer.<init>(Recognizer.java:64)
        at org.antlr.v4.codegen.model.Lexer.<init>(Lexer.java:27)
        at org.antlr.v4.codegen.OutputModelController.lexer(OutputModelController.java:151)
        at org.antlr.v4.codegen.OutputModelController.buildLexerOutputModel(OutputModelController.java:104)
        at org.antlr.v4.codegen.CodeGenerator.generateLexer(CodeGenerator.java:119)
        at org.antlr.v4.codegen.CodeGenPipeline.process(CodeGenPipeline.java:54)
        at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:404)
        at org.antlr.v4.Tool.process(Tool.java:362)
        at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:321)
        at org.antlr.v4.Tool.main(Tool.java:168)

when i have made the change inside the code please see below:

CS_FactorContent: (~[\r\n'\\'' :]
{(getCharPositionInLine()>=12 && getCharPositionInLine()<=25)
|| (getCharPositionInLine()>=36 && getCharPositionInLine()<=49)
}?
)+;
CS_ResultContent: (~[\r\n'\\'' :]
{(getCharPositionInLine()>=50 && getCharPositionInLine()<=63)}?
)+ -> type(CS_FactorContent);

getting below warning:-

warning(180): RpgLexer.g4:1147:20: chars '\'' used multiple times in set [\r\n'\\'' :]
warning(180): RpgLexer.g4:1147:20: chars '\'' used multiple times in set [\r\n'\\'' :]
warning(180): RpgLexer.g4:1152:20: chars '\'' used multiple times in set [\r\n'\\'' :]
warning(180): RpgLexer.g4:1152:20: chars '\'' used multiple times in set [\r\n'\\'' :]

Please guide.

Ivan Kochurkin

unread,
Nov 30, 2017, 7:44:46 PM11/30/17
to antlr-discussion
You are using several quotes ' inside one in range:

warning(180): RpgLexer.g4:1147:20: chars '\'' used multiple times in set [\r\n'\\'' :]

понедельник, 27 ноября 2017 г., 10:18:09 UTC+3 пользователь Om Ujjawal написал:
When i have tried to update RPGLE Grammar 4.5.3 to Antlr 4.7 getting below error on line no 1346 inside RpgleLexer.g4. Please see the below line no and error.

Om Ujjawal

unread,
Dec 2, 2017, 12:51:18 AM12/2/17
to antlr-discussion
Thanks Ivan Kochurkin 
Reply all
Reply to author
Forward
0 new messages