Is it possibe to skip a rule by validating it using ruby code in treetop?
Say there is somethi开发者_如何转开发ng like this:
rule short_words
  [a-z]+ {
    def method1
      text_value
    end
    ...
  }
end
And I want the words size to be from 2 to 5 letters. Can I exit rule if I find that the length of text_value is not between 2 and 5?
Treetop's syntax supports {min,max} bounds on matches. (Excerpt from http://treetop.rubyforge.org/syntactic_recognition.html)
Repetition count
A generalised repetition count (minimum, maximum) is also available.
* '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
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论