I shortened and reduced my the grammar affecting the file mentioned above and found that 1 parser rule was causing the Slowdown/Hanging in C#.
I have included fully working examples in both Java and C# that replicate this issue.
In JAVA, both the "Slow" and "Fast" grammars run in less than a second
However, in C# the "Slow" grammar does not finish at all and throws a StackOverflow Exception, while the "Fast version finished in 350ms.
I marked which rule is causing this issue for C# in the slow grammar file.
procedure_division:
PROCEDURE DIVISION DOT sentence* paragraph* section* #ProcedureDivisionWithSections
| PROCEDURE DIVISION DOT sentence* paragraph* #ProcedureDivisionWithOutSections
;
If this rule is changed to:
procedure_division:
PROCEDURE DIVISION DOT sentence* paragraph* section* #ProcedureDivisionWithSections
;
Then C# is able to parse through the file successfully.
I hope this is useful to determine the cause of the error,