|
Pages: [1]
|
 |
|
Author
|
Topic: Parse using Skip with a range (Read 227 times)
|
|
jmatro
|
As I understand the docs, it seems like
parse "axxb" ["a" 1 3 skip "b"]
should return True -- "a", followed by 1 to 3 characters (of any value) that we will skip, followed by "b". But it returns False.
Note that
parse "axx" ["a" 1 3 skip end]
parse "axxb" ["a" 1 3 "x" "b"]
each return True.
Comments welcome.
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Gabriele
|
PARSE does not automatically backtrack. This means that 1 3 skip will always skip 3 characters (unless the string is shorter), independently of what follows it. PARSE is not a pattern matcher, but a grammar parser. Depending on what you need exactly, there are various ways to express it as a grammar. For your simple example, one way is: >> non-b: complement charset "b" == make bitset! #{ FFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF } >> parse "axxb" ["a" 1 3 non-b "b"] == true
|
|
|
|
|
Logged
|
|
|
|
|
jmatro
|
The light bulb just clicked on - thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |