Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

parse oddity

 [1/3] from: fantam::mailandnews::com at: 23-Mar-2001 21:54


Hello, Is the following behavior expected?
>> parse "html" ["html" | "htm"]
== true and
>> parse "html" ["htm" | "html"]
== false (the above is what bothers me) while:
>> parse "htm" ["html" | "htm"]
== true and
>> parse "htm" ["htm" | "html"]
== true thanks in advance, fantam

 [2/3] from: jamesh:volition-inc at: 26-Mar-2001 13:17


> >> parse "html" ["htm" | "html"] > == false > (the above is what bothers me)
Two things to note: 1. When you match against a group of strings, the first possible match is the one you get. In your case, the "htm" is matching before the "html", which is correct. 2. parse only returns true if the entire string is parsed. In your example, html is matched with "htm", so you have the "l" remaining unparsed. This gives a result of false. If you change your example to: parse "html" [["htm" | "html"] to end] Then you'll get true instead. James

 [3/3] from: agem:crosswinds at: 26-Mar-2001 21:17


> Hello, > > Is the following behavior expected?
yes
>>> parse "html" ["html" | "htm"] >== true > >and > >>> parse "html" ["htm" | "html"] >== false >(the above is what bothers me) >
["htm"] eats "htm", rest "l". ["htm"] has eaten, so [| "html"] is ignored. there is a rest, so 'false . had similar case with ["s" | "sw"] which has to be ["sw"|"s"] generally longest case first.