Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Parse using Skip with a range
Pages: [1] Print
Author Topic: Parse using Skip with a range  (Read 227 times)
jmatro
Newbie
*
Offline Offline

Posts: 7


View Profile
Parse using Skip with a range
« on: November 08, 2004, 12:02:20 PM »

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
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Parse using Skip with a range
« Reply #1 on: November 09, 2004, 08:26:27 AM »

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:

Code:
>> non-b: complement charset "b"
== make bitset! #{
FFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
}
>> parse "axxb" ["a" 1 3 non-b "b"]
== true
Logged
jmatro
Newbie
*
Offline Offline

Posts: 7


View Profile
Parse using Skip with a range
« Reply #2 on: November 10, 2004, 12:16:04 PM »

The light bulb just clicked on - thanks again.
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Parse using Skip with a range
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 06:18:50 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2285 Posts in 594 Topics by 3708 Members
Latest Member: cialissactiv

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc