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. 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. 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. 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. 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 * 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. 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. 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. Thank you, Sam
_______________________________________________ antlr-dev mailing list [email protected] http://www.antlr.org/mailman/listinfo/antlr-dev
