[antlr-interest] C# Grammar

Robin Debreuil robin at debreuil.com
Thu Feb 19 06:59:57 PST 2004


> does anyone know where I can get a working C# grammar file, the on
> on antlr.org does not work.

I am working on one based more directly on the C# spec, but it is competing
with other 'real' work at the moment, so it will take a bit more time... I
have the lexer, types, expressions, namespaces, enums, and attributes more
or less done so far, so a ways to go still...

Actually I have a question too - attribute arguments in C#  have the format:
(positional_arguments COMMA named_arguments)
which inside the parens look something like:

(expression (COMMA^ expression)*)
COMMA
(IDENTIFIER ASSIGN expression (COMMA! IDENTIFIER ASSIGN expression)*)

This does get weird, because (x=5), x==5, or x+=5 can be considered
positional arguments, yet x=5 can't. Also assignment expressions (id=expr)
are naturally valid expressions, so you have to somehow exclude those until
the second half, and then allow only them. I can get all the things parsed
(in fact using only positional_arguments will parse everything), but I'm
having trouble disallowing sets that aren't in the right order, say like:

( 5, 6, x=7, 8) // the last two args needed to be switched

So anyway, mostly my question is - are there cases where you just give up on
parsing with grammar, and break into code and check things manually? Or is
that the kind of check that is better left to a later pass? Or is there just
some magic cleverness I'm missing? I've tried with different groups of LA
lookahead, =>,  greedy settings, and extra rules, but I can't seem to get
the right combo going.

All and any general guidance muchly appreciated : ).

Cheers,
robin




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list