Skip to content

[CSharp] ReportAttemptingFullContext() call passes null for config sets, thwarts attempts to debug grammars. #4386

@kaby76

Description

@kaby76

I don't know why but ReportAttemptingFullContext is passed null for the last parameter, the ATN config set.

For Java (the "gold standard"), the code correctly passes the ATN config set. All other runtimes also pass the ATN config set.

I use CSharp as my development environment. Besides the fact that the tools in C# are much, much better than Java, all my tools in Trash are C# based.

I need the ATN config sets to get the prediction context in order to debug grammars. I can only get the value when overriding the DiagnosticErrorListener class.

For those who don't know, the ATN config set contains the prediction context, which is a collection of ordered NFA states in the entire collection of ATN for the grammar. It corresponds to the states in a derivation. The ToString() method for an ATNConfigSet prints out integer states ids, but few can read this output. And, it's terrible because one has to constantly look in the generated .dot files for states, then trace them back to a particular rule. Instead, I use the information to devise a much more "human-readable" version that uses rule names of a derivation.

I repeat myself again and again: the runtimes are not one-to-one, and contain many sutle differences, sometimes critical. Without access to the ATN config set, I cannot debug grammars--especially when they contain actions.

IDEs and plugins do not replace essential functionality that I require from the runtime.

Comparison with other runtimes

As far as I can tell, no other runtime has the same whacky API as with CSharp: configs is always passed to the DiagnosticErrorListener methods.

When did this happen?

It seems this large commit with a one-word description "compiles" 7 years ago passed null instead of configs.

Fix

A fix can be made, but it requires a minor revision number change (i.e., 4.13.0 to 4.14.0) because the API must be changed to report this to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions