If explicit endings are introduced then the problem is trivial to solve.

MC_QUESTION  :
   NL INT ('.'|')') NOT_END+ ']' { out.print("q : "); };

fragment NOT_END :
   ~(']');

The most similar grammar I've found that deals with implicit endings is 
the gherkin ragel lexer.  Ideas for solving this without requiring an 
end keyword are much appreciated.

On 10-02-22 12:55 AM, [email protected] wrote:
> 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/


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