javacc / javacc-8

New JavaCC design with a core front end and language generator back ends
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

C# DebugToken Manager Problem #3

Open skfcz opened 1 month ago

skfcz commented 1 month ago

Hello All,

I generated a C# parser with debug tokenmanager enabled and get a problem with the generated code

The exception is

System.IndexOutOfRangeException : Der Index war außerhalb des Arraybereichs. bei prostep.aveva.vol.SimpleCharStream.getBeginLine() in C:\home\cz\OPS\opdm-aveva-val-parser\aveva-vol-csharp\src\CharStream.cs:Zeile 238. bei prostep.aveva.vol.VOLParserTokenManager.getNextToken() in C:\home\cz\OPS\opdm-aveva-val-parser\aveva-vol-csharp\src\VOLParserTokenManager.cs:Zeile 394. bei prostep.aveva.vol.VOLParser.jj_scan_token(Int32 kind) in C:\home\cz\OPS\opdm-aveva-val-parser\aveva-vol-csharp\src\VOLParser.cs:Zeile 1517. ....

and the generated code

for (;;) { // First see if we have any input at all. try { curChar = input_stream.BeginToken(); } catch(System.Exception) { if (lexStateNames.Length > 1) { System.Console.Error.Write("<" + lexStateNames[curLexState] + "> "); } System.Console.Error.WriteLine("Reached EOF at " + input_stream.getBeginLine() + ":" + input_stream.getBeginColumn());

At the input_stream is out of range and throws the IndexOutOfRangeException exception. My proposal ist to change the template for the EOF case.

kaikalur commented 1 month ago

Are you using javacc8?

kaikalur commented 1 month ago

But also we know there are some issues with debug token manager :( You can try using the JavaCCInterpreter to debug it better.

MarcMazas commented 1 month ago

I've been able to reproduce the problem. I'll try to find its origin.