Home   Archive   Permalink



Parse skip and a space character

Hi! I was playing with Parse using skip. I was trying:
    
rule: ["a" skip "b"]
    
When I do
    
parse "axb" rule
    
I get "true" but if I use a space character, as in:
    
parse "a b" rule
    
I get false. I thought that the skip would advance a character in the input string and consequently would not care what kind of character it was skipping. But clearly this space character makes it behave differently. Why is this?
    
Thanks in advance!

posted by:   brother damian       5-Sep-2017/15:06:40-7:00



I barely understand parsing with rules, but this gives "true" in both cases. I always get hung up on the "parse" versus "parse/all."
    
R E B O L []
    
rule: ["a" skip "b"]
    
probe result1: parse/all "axb" rule
probe result2: parse/all "a b" rule
    
halt

posted by:   Steven White       5-Sep-2017/16:16:09-7:00



Oh, you are right! The refinement forces the function to parse "all" characters, including those that are normally delimiters, like the space, tab, coma or semicolon. I guess skip is bound to this condition as well.

posted by:   brother damian       6-Sep-2017/3:44:59-7:00



The /ALL refinement came from an era where it was thought to be common or convenient to gloss over whitespace for most purposes. Seems as if empirically, this turned out to not be true...most parse tasks care about whitespace.
    
Additionally, it becomes a bit complex to document and define some operations as "ignoring whitespace". It adds a dimension to the definition that is not super clear.
    
R3-Alpha made /ALL the default behavior but did not remove the refinement, so it just had no effect. Ren-C and Red have removed it entirely.

posted by:   Fork       6-Sep-2017/10:16:38-7:00



Name:


Message:


Type the reverse of this captcha text: "! d r o w - t e g"



Home