[antlr-interest] C# @members

Austin Hastings Austin_Hastings at Yahoo.com
Fri Oct 26 21:03:16 PDT 2007


Benjamin Niemann wrote:
> Gavin Lambert wrote:
>
>   
>> At 18:52 26/10/2007, de Jong, Ron wrote:
>>  >@members { // hello }
>>  >
>>  >Basically nothing after this is correctly interpreted. I have
>>  >tried every variation but the @members just doesn't seem to
>> work.
>>
>> I would be surprised if it did.  That's a line comment you've got
>> there, and you're putting everything all on the same line.  Don't
>> do that.
>>
>> @members {
>>    // hello
>> }
>>
>> will work.
>>     
>
> Suprising that this make a difference. ANTLR does not now that // in an
> action section has any special meaning, so it should not influence the way
> the rest of the grammar is interpreted.
> Or did the OP refer to the generated code being broken, which may be the
> case when the template adds some significant code directly after it without
> an additional LF
Actually, the lexer has to parse the block, or you're left with the 
(regex-powered) lexer having to recognize a balanced set of 
opening/closing braces. I'm sure everyone on this list will all chime in 
to tell you that regexes (without perl ;) aren't powerful enough for 
that, and so ... blah blah CHOMSKY blah blah FINITE STATE AUTOMATON blah 
blah STACK blah blah ... either there's a custom lexer rule or the lexer 
tokenizes the @members declarations. Either way it's morally impure, and 
this way it's probably much easier to maintain. :)

=Austin



More information about the antlr-interest mailing list