How to determine {min, max} matches at the top of the top

With Ruby regexes, I could write / [0-9] {3,} / I can't figure out how to write this in treetop other than:

rule at_least_three_digit_number
  [0-9] [0-9] [0-9]+
end

      

Is there a match [at least | most] n 'rules for the top of the tops?

+2


source to share


2 answers


It looks like PEG lacks some of the RE-RE statements, but you get a much more powerful matching layout in return.



+1


source


http://treetop.rubyforge.org/syntactic_recognition.html



A generalized number of repetitions (minimum, maximum) is also available.

'foo' 2 .. matches 'foo' two or more times

'foo' 3..5 matches 'foo' three to five times

'foo' .. 4 matches 'foo' zero to four times

+1


source







All Articles