[antlr-interest] C#3 questions

Sam Harwell sharwell at pixelminegames.com
Thu Nov 3 08:00:38 PDT 2011


Hi Eric & Andy,

 

The C# 3 target was created due to a license incompatibility with the C# 2
target. As such, it was created completely from scratch (working from the
Java code only). The C# 3 target uses the same 3-clause BSD license as the
Java version.

 

As of the latest release, the C# 3 and C# 2 targets use the same runtime
(the one previously used by just the C# 3 port).

 

I've tested the following options.

 

.         -o

.         -lib

.         -dfa

.         -nfa

.         -XdbgST (now launches the TemplateVisualizer)

.         -language

.         -message-format

.         REMOVED: -Xconversiontimeout (also removed from the Java version,
so it's a bug if it still prints in the help text)

 

The C# targets do not support the -debug or -profile options. These days I
debug my grammars in Visual Studio. Since nearly all of my grammars are used
for creating Visual Studio extensions, I use a custom debugger for ASTs
that's integrated into Visual Studio. When I was working on standalone
grammars, the visualizers in Antlr3.Runtime.Visualizer worked great. At this
point our emphasis is on the debugging support in ANTLR 4 and ANTLRWorks 2,
and it's going to make all the existing ones look primitive at best. Right
now I'm leading the AW2 development with full intention to provide the same
experience and feature set in a Visual Studio 2010 extension sometime after
an ANTLR 4 beta is released.

 

I have used the generated DOT files. To display them I used to use
standalone ZGRViewer, but now I use a custom (experimental) NetBeans
extension that displays the zvtm/ZGRViewer UI in NetBeans. I'm developing
this with the latest NetBeans 7.1 built from source. It may work with
NetBeans 7.0 or 7.1 beta, but I'm not 100% sure. After installing all of the
modules in the following archive (via Tools > Plugins > Downloaded > Add
Plugins. and then Install), you'll need to open up (Tools > Options >
Miscellaneous > GraphViz) and configure your options and the path to dot.exe
(other paths are optional and currently unused). I have antialiasing enabled
but the other options disabled.

http://www.tunnelvisionlabs.com/downloads/netbeans/ZGRNBViewer.zip

 

The documentation on the wiki only goes into the basics. Most of what I've
learned over the years isn't features so much as best practices for using
ANTLR in general.

 

I'm working with Ter to clean up the API especially for ANTLR 4. At this
point ANTLR 3 has gone into maintenance mode - new features will be used in
ANTLR 4. There are a handful of bugs we've fixed since the 3.4 release, so
those should eventually appear in a patch release (3.4.1 for Java?).

 

I haven't talked with Johannes in some time. Everything we do for ANTLR is
volunteer, and typically only happens because we're using ANTLR ourselves
and need something (fix or feature) not already offered by the existing
ports.

 

Antlr3.exe includes a number of unique optimizations in the generated code
when used with the C# 2 or C# 3 target. Antlr3.exe should work with any of
the targets, but I only test it on the C# targets.

 

Ter and I talk almost on a daily basis. We don't always talk before making
changes in our own builds (C# for me, Java for him), but we always do when
one of our changes impacts the other.

 

Sam

 

From: Eric [mailto:researcher0x00 at gmail.com] 
Sent: Thursday, November 03, 2011 7:32 AM
To: Sam Harwell
Cc: Andy Voelkel
Subject: C#3 questions

 

Hi Sam,

 

I am starting to regularly use your ANTLR C#3 target and need to get some
things nailed down for my sanity.

 

If you could give feed back on the following it would be appreciated.

 

How was the C#3 target created? Was it copied from C#2 and then modified or
was it a clean start? What was the philosophy and reason to create another
C# target?

 

For the C#3 ANTLR3 executable what is the status of each option? i.e. which
options works, which options are accepted but don't work, which options are
known not to work?

 

-o outputDir specify output directory where all output is generated

-fo outputDir same as -o but force even files with relative paths to dir

-lib dir specify location of token files

-depend generate file dependencies

-report print out a report about the grammar(s) processed

-print print out the grammar without actions

-debug generate a parser that emits debugging events

-profile generate a parser that computes profiling information

-trace generate a recognizer that traces rule entry/exit

-nfa generate an NFA for each rule

-dfa generate a DFA for each decision point

-message-format name specify output style for messages

-verbose generate ANTLR version and other information

-make only build if generated files older than grammar

-version print the version of ANTLR and exit.

-language L override language grammar option; generate L

-X display extended argument list

-Xgrtree print the grammar AST

-Xdfa print DFA as text 

-Xnoprune test lookahead against EBNF block exit branches

-Xnocollapse collapse incident edges into DFA states

-Xdbgconversion dump lots of info during NFA conversion

-Xconversiontimeout use to restrict NFA conversion exponentiality (This is a
org.antlr.Tool option but is not an Antlr3.exe option)

-Xmultithreaded run the analysis in 2 threads

-Xnomergestopstates do not merge stop states

-Xdfaverbose generate DFA states in DOT with NFA configs

-Xwatchconversion print a message for each NFA before converting

-XdbgST put tags at start/stop of all templates in output

-Xnfastates for nondeterminisms, list NFA states for each path

-Xm m max number of rule invocations during conversion [4]

-Xmaxdfaedges m max "comfortable" number of edges for single DFA state
[65534]

-Xmaxinlinedfastates m max DFA states before table used rather than inlining
[60]

-Xmaxswitchcaselabels m don't generate switch() statements for dfas bigger
than m [300]

-Xminswitchalts m don't generate switch() statements for dfas smaller than m
[3]

-Xsavelexer don't delete temporary lexers generated from combined grammars

 

The Antlr3.Runtime.Visualizer code exist but you no longer use or support
it? Note, I haven't used Antlr4.StringTemplate.Visualizer yet.

Are there any parts of the C#3 release that we should not use?

ANTLR C#3 will not work with ANTLRWorks debugger?

How do you debug an Antlr C#3 target lexer and parser? i.e. Do you only use
Visual Studio and step through the code because you understand how the lexer
are parser work in great detail. I can do that, but for Andy it will be a
learning curve.

ANTLR C#3 can generage DOT files. Do you use them? If so, what do you use to
display them in Windows? 

Is there any thing about C#3 we should be aware of outside of the document
at
http://www.tunnelvisionlabs.com/downloads/antlr/ANTLRCSharpDocumentation-900
4.xps ?

It appears that Ter likes some of the coding methodologies you use for C#3
and is back porting them into future versions of the Java target, is this
true? I ask because then I will know what Ter has bolted onto the Java
version as opposed to it being built in?

It also appears that the C# and C#2 targets are no longer supported by
Johannes Luber? Do you stay in touch with him regarding the C# targets?

Even though the Java version can target C#3 code, the C#3 target in the Java
version is not maintained by you and should not be used? One should only use
your Antlr3.exe to generate C#3 code?

Even though Antlr3.exe can target C#2 and other languages, only the C#3
target is kept current?

Do you and Ter talk about bug fixes before implementing the fixes?

 

Thanks, Eric

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



More information about the antlr-interest mailing list