[antlr-interest] C# target problems and suggestions

Johannes Luber jaluber at gmx.de
Wed Jul 18 15:18:31 PDT 2007


Hello!

I've stumbled upon some difficulties while using the debug option. The
first it, that the debug parser for tree grammars doesn't expose the
constructor with the port. The second is that the member variable dbg is
reset in all constructors to null, even in the constructor, which is
supposed to set this variable. (Without access to the source code I'd
never found that out.) Considering, that both in the normal parser and
in the tree parser this variable is accessed a few 100 times, it is
clear that this behavior is simple unacceptable.

This could be prevented, if instead null the BlankDebugListener would be
used. Another bug seems to lurk here in DebugTreeParser.cs:

"public IDebugEventListener DebugListener
        {
            get
            {
                return this.dbg;
            }
            set
            {
                if (base.input is DebugTreeNodeStream)
                {
                    ((DebugTreeNodeStream)
base.input).SetDebugListener(this.dbg);
                }
                this.dbg = value;
            }
        }
"

It seems, that the setter should use "((DebugTreeNodeStream)
base.input).SetDebugListener(*value*);" instead, because this.dbg has
still the previous value there.

Another suggestion: Certain constructors and properties are only
available in debug mode. This makes it difficult to use one single
source file, unless one uses the preprocessor. Instead forcing the
grammar authors to employ this technique (and to regenerate the files
with different options) how about putting everything debug specific
between #ifdefs?

And now to some suggestions for Terence: While improving the error
reporting, it would be nice if the tree parser would say, if it
encounters an unexpected token, what kind of token it wants to see and
what kind of token it actually saw, instead simply saying: "Not the
right token encountered."

Also I'd be interested in allowing regions within regions. I wanted to
insert a snippet in a constructor, which was inserted by a region itself.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list