[antlr-interest] Truely, a BASIC question

Rob Greene robgreene at gmail.com
Mon Nov 21 19:38:05 PST 2005


I am most definitely new to ANTLR. I'm working out a grammar file for
a BASICish language where line endings are important. Language
statements do not end with a colon uniformly - instead it is most
likely a newline that separates statements. I haven't discovered any
tutorials that covers this and haven't located any information in the
documentation.

What I've tried:
* optionally allow the colon separator - but that allows stuff like
"goto this goto that" instead of requiring a colon/newline between
commands ("goto this : goto that").
* pulled newline out of the WS variable (?? terminology) in my grammar
file and added a separator rule of "( COLON | NEWLINE )+" to require
one or more separators and then attempt to use the rule appropriately.
This seems to work, but I get odd errors:

line 8:15: unexpected token:

line 9:9: unexpected token:

line 10:1: unexpected token:

line 11:1: unexpected token: gosub

Which appear (to the novice) to imply my separator are hosing up the
interpretation somewhere.

Are there any gotchas in the grammar rules I need to look out for?
I've included what I have at this point for the grammar file (with the
really clever name of rbasic).

Thanks!
-Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rbasic.g
Type: application/octet-stream
Size: 3559 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20051121/70bf2b9c/rbasic.obj


More information about the antlr-interest mailing list