[antlr-interest] ANN: kcsparse - an ANTLR C# parser with optional Flex lexer

Micheal J open.zone at virgin.net
Sat Dec 10 01:40:45 PST 2005


Hi,

We have uploaded a new ANTLR grammar to the ANTLR website. kcsparse'
contains a modular set of ANTLR grammars that can be used to build a fully
unicode compliant lexer and parser for the ECMA-334 C# language (or C#
v1.0). You can find kscparse on the ANTLR website at
http://www.antlr.org/grammar/list.

kscparse is built for ANTLR 2.7.6 but can be made to work with previous
versions of ANTLR 2.7.x. It does not include a full C# preprocessor but it
does support "sanitized" usage of all C# preprocessor directives. By this we
mean this: if what is left after simply deleting all lines that contain
preprocessing directives from a source file is a legal C# program, then that
original file has sanitized use of preprocessing directives and can be
parsed by kcsparse.

A couple of novel features of kcsparse is that it (a) includes a flex lexer
and, (b) has a basic pretty printer implemented as a treewalker. The flex
lexer isn't as complaint as the ANTLR lexer particularly in respect to full
unicode compliance (all versions of C# flex tested exhibited either serious
performance problems and/or buggy output when fed a specification that had
the full unicode support of the ANTLR lexer). It is nevertheless a
substantial example of integrating a Flex lexer with an ANTLR parser in C#.
The pretty printer is hopefully a useful example of treeparsing and basic
prettyprinting.

Known issues:
- kcsparse's build file won't find antlr.runtime.dll and antlr.astframe.dll
when used with ANTLR v2.7.6rc1 and earlier (use the attached build file
instead or edit the supplied one)

Please address queries, patches and other similar questions to the ANTLR
mailing list. Given enough interest and support, kcsparse may evolve a full
C# preprocessor, full C# 2.0 support and hopefully an alternative TreeDL
based syntax tree and prettyprinter.


Cheers,


Micheal

-------------- next part --------------
A non-text attachment was scrubbed...
Name: csharp_v1.build
Type: application/octet-stream
Size: 5658 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20051210/f923c753/csharp_v1.obj


More information about the antlr-interest mailing list