> Hi all, > > First, as I mentioned in another thread, the exception specification > feature for rules is defined in the primary grammar ANTLR.g3, but not > implemented by the rest of the codegen. It may only apply to the Java > target for now, but this should be implemented and probably isn't > exceptionally difficult (pun intended). The big remaining question I > have is, given this rule: > > my_rule throws OperationCanceledException > : ... > ; > > Should the generated function still list RecognitionException in the > exception spec? As far as I can tell, it should, and if the grammar > redeclares RecognitionException in the exception spec, it should simply > ignore the second copy of it. Add a Set to each rule that has > RecognitionException listed by default, and add each item from a rule's > exception spec to it. It's then trivial to add them to the Java target > codegen.
That makes sense. > > Second, the public, protected, and private modifiers for rule are > ignored. I plan to implement these in the C# target in accordance to > other C# code: functions generated for rules are private by default, or > given the visibility of the modifier if specified. Makes also sense. > Third, functions should not be generated for unreferenced fragment lexer > rules. The primary application for this is preventing code bloat from > rules like the following that are used to suppress warnings. The actual solution is to finally add a grammar option to suppress certain warnings. > fragment DOC_COMMENT : ; > > Fourth, I moved the FOLLOW_* members into a static inner class Follow in > the C# 3 target. When working with larger grammars in Visual Studio (or > other IDEs), this removes a very large number of members from the > dropdowns used in navigating code. I also put #region markers around the > DFA code and the Follow code so Visual Studio can collapse them. These > may or may not apply to other languages, but are a possibility if you > are interested. That's a good idea. > Fifth, I'm working on completely rewriting the debug code in the > runtime, at least for the C# 3 target. My primary objectives are: > > * Remove the requirement of using a different base class for > debuggable grammars > > * Remove the requirement that debug grammars always be attached > to the debugger in order to run These two issues did irk me, but I never saw the root cause and thus no solution. Nice catch! Should be ported back to the Java target for 3.2. > > * In the generated code for the C# 3 target, I'm carefully using > the ConditionalAttribute so the code generated for debug grammars is the > same as that generated for non-debug grammars, with the exception of a > single #define at the top of the file. For release grammars, there is no > performance impact as a result since all calls to the conditional > functions are removed by the C# compiler. Well, for Java that may be a problem. I'm not aware of an equivalent of the ConditionalAttribute. But I suppose one could StringTemplate to get around this issue. > Sixth, there needs to be a convenient way to specify a custom > TreeAdaptor for a grammar. The current methods are rather clumsy in > general, although the C# 3 target provides a clean workaround. In the C# > 3 target, there is a virtual function Initialize() called from the > BaseRecognizer constructor (I know...), which I override in the > ANTLRParser (generated from ANTLR.g3) and a couple other grammars to set > the TreeAdaptor. What's the current method? Using a constructor parameter, right? Why is using a virtual call (even if you take care of the pitfalls) better? > Seventh, I recommend adding a grammar option to suppress line/column > numbers and the timestamp from the generated code. For the [few?] people > that care, this will immensely clean up the diff output in large > grammars. I'm one who would like this feature. Actually, I'd like it in reverse. Unless doing special debugging, this additional information is useless and doing harm in the diffs, as you stated. Johannes > Thank you, > > Sam > -- Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a _______________________________________________ antlr-dev mailing list [email protected] http://www.antlr.org/mailman/listinfo/antlr-dev
