How to mix parsing strings and parse pairs in the same rule?

It is great that the Rebol PARSE dialect is generalized enough that it can match and extract patterns on symbolic structures as well as strings. Like this:

; match a single "a" character, followed by any number of "b" chars >> string-rule: ["a" some "b"] >> parse "abb" string-rule == true >> parse "aab" string-rule == false ; look for a single apple symbol, followed by any number of bananas >> block-rule: ['apple some 'banana] >> parse [apple banana banana] block-rule == true >> parse [apple apple banana] block-rule == false 

But let's say that I'm looking for a block containing an apple character, and then any number of character strings matching the string-rule :

 ; test 1 >> parse [apple "ab" "abbbbb"] mixed-rule == true ; test 2 >> parse [apple "aaaa" "abb"] mixed-rule == false ; test 3 >> parse [banana "abb" "abbb"] mixed-rule == false 

How would I formulate such a mixed-rule ? Looking at the documentation, we can assume that you can use INTO:

http://www.rebol.net/wiki/Parse_Project#INTO

It seems that the natural answer is not working:

 >> mixed-rule: ['apple some [string! into ["a" some "b"]]] 

While it passes test 1 and correctly returns false for test 3, it incorrectly returns true in test 2. Is this my mistake or error in Rebol (I use r3 A111)?

+4
source share
1 answer

The REBOL3 forum discusses:

 only the second string is checked. Should be: ['apple some [and string! into ["a" some "b" ]]] 
+3
source

All Articles