[antlr-interest] Multiple Lines with Implicit Endings in ANTLR
consiliens at gmail.com
consiliens at gmail.com
Sun Feb 21 23:55:47 PST 2010
I'm attempting to enhance a simple grammar to support entries longer
than one line. The Eclipse project with all the code is
http://tinyurl.com/yj62hqe
Using ANTLR and Eclipse was easy thanks to the excellent JavaDude
screencasts[0].
Quiz.java correctly identifies the question (q), correct answer (c), and
incorrect answer (i) for single line entries.
q : 1. hi
c : *a. hi
i : b. bye
q : 1. bye
i : a. hi
c : *b. bye
The quiz language is similar to grammars found in jbehave[1] and
Gherkin[2][3]. In these grammars there are no explicit end keywords. I
also looked at the wiki example from tpdsl[4], however that fails on the
most basic wiki input such as
* 1
* 2
MQuiz.g contains my failed attempt at using ideas from the Gherkin
Ragel[5] grammar to support multiple lines. Does anyone know how to
support multiline properly in this grammar with ANTLR?
Thanks.
[0] http://javadude.com/articles/antlr3xtut/
[1] http://jbehave.org/reference/latest/grammar.html
[2]
http://github.com/aslakhellesoy/gherkin/blob/master/ragel/lexer.java.rl.erb
[3]
http://github.com/aslakhellesoy/gherkin/blob/master/ragel/lexer_common.rl.erb
[4] http://media.pragprog.com/titles/tpdsl/code/tpdsl-code.tgz
[5] http://www.complang.org/ragel/
More information about the antlr-interest
mailing list