At 23:41 15/09/2009, Kevin Twidle wrote:
>I have been using my PonderTalk (Smalltalk like) language for a 
>while now and I have just noticed that leaving a block empty 
>causes a parser error. This is with ANTLRWorks 1.2.3. I have 
>refined the grammar to show the point. The problem line is 
>^(statements). With that taken out the parsing works.
[...]
>sentence:WORD | block;
>block:'[' sentences ']'
>-> ^(sentences)
>;

You should define an imaginary token to use as the root 
here.  Things go a little strange when you try to use a 
multi-token rule as the root, especially (as you've found) if it's 
optional.

tokens { BLOCK; }

block : '[' sentences ']'
   -> ^(BLOCK sentences)
   ;

Using imaginary tokens to indicate structure like this also helps 
when reading the tree (either via a tree parser or directly). 


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 il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to