tags:

views:

27

answers:

1

If i have a subrule like the following:

.. (~']' ~']')* ...

will it only match an even number of characters?

+1  A: 

(Assuming the dots are not meant as meta characters)

Not quite, it will match zero, or an even number of characters.

EDIT

To match a quote block, do something like this:

QUOTE
    :    '[[' (options {greedy=false;} : . )*  ']]'
    ;

Assuming [[ some text here ]] is a quote block.

Bart Kiers
Oh. Well i am trying to match the end of a quote block, how would you do it? i'm very new to ANTLR :)
RCIX
I'm trying this `(options{greedy=false;}:.)*`, will it work in my intended role?
RCIX
Yes, see my edit.
Bart Kiers
Thanks for the help, much appreciated :)
RCIX
Also, somehow you hit on lua's exact syntax for string literals and it just so happens that i used the same rule to parse it, so i have a question: would you mind waiving that pesky CC-Wiki license for this little bit of code?
RCIX
You're welcome to use whatever I post on SO in whatever way you see fit.
Bart Kiers
Cool, thanks, it's highly appreciated, and i'll add a credit to my grammar file thanking you :D
RCIX