[antlr-interest] C# 2.0 ANTLR grammar
Lloyd Dupont
ld at galador.net
Mon Jul 16 05:26:10 PDT 2007
You probably have to use semantic predicate.
I'm building a C#/XAML expressions grammar for a home project.
I have somethin like that:
================
compare
: (shift -> shift)
(
( op=(LT | GT | LTE | GTE) s=shift -> ^($op $compare $s) )
// not really a comparison, but same priority
| ( is='is' i=identifier -> ^( IS[$is] $compare $i ) )
| ( as='as' i=identifier -> ^( AS[$as] $compare $i ) )
)?
;
//....................................
// here XAML like name definition, I had too much problem with the DOTs....
classname
: (
{ IsClass(input.LT(3).getText(), input.LT(1).getText()) }? xaml=ID COLON
id0=ID -> ^( CLASSNAME $id0 $xaml )
| { IsClass(input.LT(1).getText()) }? id1=ID -> ^( CLASSNAME $id1 )
)
(
( genericparam )=> genericparam -> ^( CLASSNAME $id0? ^(XAMLNS $xaml)?
$id1? genericparam )
|
)
;
// obviously genericparam is never ever called from somewhere else that
classname
genericparam
: LT classname (COMMA classname)* GT -> ^(GENERICTYPE classname+)
;
================
----- Original Message -----
From: "Yury Serdyuk" <Yury at serdyuk.botik.ru>
To: <antlr-interest at antlr.org>
Sent: Monday, July 16, 2007 7:43 PM
Subject: [antlr-interest] C# 2.0 ANTLR grammar
> Hi !
>
> Does a version of C# 2.0 antlr grammar exist?
> Namely, how to support generics in it without
> conflicts with "<" ( or ">" ) operators ?
>
> Best wishes,
> Yury Serdyuk
>
More information about the antlr-interest
mailing list