[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optional Semicolon Ending with BETA Grammar



Hi all,

I'm new to SableCC and parser generators in general. I'm wondering how
to change the attached grammar (also at
http://paste.pocoo.org/show/209978/) so that semicolons are not
required at the end of a line containing an attribute or imperative.
They should, however, be required between attributes or imperatives
that are on the same line. Basically I think CR/LF/CRLF should be
another option instead of semicolon, but my efforts to implement that
did not work. I had tried removing the helper eol (CR | LF | CRLF)
from the token "blank" which is in the Ignored Tokens section and then
making the semicolon rule be ';' | eol. Any tips on the right way to
do this? An example of a semicolon that should be optional is line 9
on the attached file called "test5.bet". I also attached a file called
"Translator.java" that will run use the generated code, if anyone
really wants to play around with this example.

A note to anyone who might actually want to use this BETA grammar: I'm
just beginning with this project, and I don't have a deep
understanding of BETA or parser generators, so there are likely
significant bugs aside from the semicolon issue.

Thanks,

Kyle

Attachment: beta.sable
Description: Binary data

Attachment: test5.bet
Description: Binary data

Attachment: Translator.java
Description: Binary data