You can also check the example grammars for Python (newlines are 
significant, unless they appear within parenthases) and JavaScript (with 
quite complicated rules for when the newlines are significant).

When I was writing the parser for my DSL I checked the JavaScript 
solution, decided it's not worth the bother, and opted for Python 
version (it's quite easy, it only requires a bracket level counter in 
the lexer).


> I do actually want to allow new lines everywhere. I'm starting to
> think it's not worth the trouble of allowing them. Seems to make the
> grammar much more complicated for little benefit.
> 
> Thanks for your help,
> Nick
> 
> On Fri, May 8, 2009 at 10:38 AM, Iztok Kavkler
> <[email protected]> wrote:
>> Since it appears that newlines can only appear between statements I would
>> recomend not sending them to the hidden channel but matching them like this:
>>
>> terminator: ';' NEWLINE* | NEWLINE+ | EOF;
>>
>> configItem: ID '=' VALUE terminator ;
>>
>> (You will have to also match NEWLINE* at the beginning of the script,
>> otherwise you will get errors for empty lines at the beginning.)
>>
>> Cheers, Iztok
>>


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to