treetop で ruby コードを使用して検証することにより、ルールをスキップすることは可能ですか?
次のようなものがあるとします。
rule short_words
[a-z]+ {
def method1
text_value
end
...
}
end
単語のサイズは 2 ~ 5 文字にしてください。text_value の長さが 2 から 5 の間にない場合、ルールを終了できますか?
Treetopの構文は、一致の{min、max}境界をサポートします。( http://treetop.rubyforge.org/syntactic_recognition.htmlからの抜粋)
繰り返し回数
一般化された繰り返し回数(最小、最大)も利用できます。
* 'foo' 2.. matches 'foo' two or more times
* 'foo' 3..5 matches 'foo' from three to five times
* 'foo' ..4 matches 'foo' from zero to four times