New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<ws> poorly defined #1729
Comments
|
FWIW rakudo/rakudo#1222 |
|
Language/grammars in the middle of the section on The sigspace section of Language/regexes first implies the same idea saying
and then shows, if you knew what you were looking for in the first place, that it is not talking about
which is correct but neither In the stack overflow article moritz says the moritz stackoverflow: https://stackoverflow.com/questions/47728466/perl-6-grammar-doesnt-match-like-i-think-it-should#comment82426178_47728653 I think it might be helpful for the The idea that say so "I used a Photoshop(photo shop)" ~~ m:i:s/ photo shop /;'Or a stronger hint could be added to the second example by adding a '.' period at the end of the sentence: say so "I used a photo shop." ~~ m:i:s/ photo shop /;In the grammars
and the block of examples just below it might be moved to the top and again @moritz simplification of the The two sections should also point to each other. So I was confused about Thanks to @AlexDaniel for his patience helping to explain some of this on IRC #perl6. |
|
Maybe this issue #2211 will also solve this one? At any rate, can you please check now for the definition? |
|
@tisonkun if I got the Rakudo bug correctly, the main problem is when re-defining ws in a Grammar, not in the definition of ws itself, which this issue is about, right? |
|
Added the external label since it's waiting for this issue to be solved (via @tisonkun ) |
In Language/grammars.pod ws is defined at line 209 as one or more whitepace characters or a word boundary, i.e.
/ \s+ | <|w> /If, however, you define in a grammar,
token ws { \s+ | <|w> }, you may find that your previously working parser no longer parses.After looking in Language/regexes, I found there are some examples of redefining ws but no definition of how ws is defined by default. Those examples provided a clue that, perhaps ws is actually defined as,
token ws { <!ww> | \s+ }. Searching further, I found in stackoverflow a comment by moritz that ws is, in fact defined astoken ws { <!ww> | \s+ }. https://stackoverflow.com/questions/47728466/perl-6-grammar-doesnt-match-like-i-think-it-shouldThe default definition of ws should be corrected in grammars.pod and added to the sigspace section of regexes.pod.
One other point that might be made clear is that a grammar that explicitly defines ws behaves a bit differently than one which uses the default definition. Using the default, ws gets thrown away. When ws is explicitly defined, whatever it parses gets put into the parse tree.
The text was updated successfully, but these errors were encountered: