Skip to content
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

Grammar.parse talks about :c but it is actually :pos #1583

Closed
AlexDaniel opened this issue Sep 29, 2017 · 6 comments
Closed

Grammar.parse talks about :c but it is actually :pos #1583

AlexDaniel opened this issue Sep 29, 2017 · 6 comments
Labels
docs Documentation issue (primary issue type)

Comments

@AlexDaniel
Copy link
Member

grammar G { regex TOP { \d } }; my $str = 123; my $g = G.new; for ^3 { $g.parse($str, :pos(2)).say }
「3」
「3」
「3」

Same with .subparse.

Also, maybe we should provide a .subparse example? For example:

grammar G { regex TOP { \d } }; my $str = 123; my $g = G.new; for ^3 { $g.subparse($str, :pos($/.to // 0)).say }
@AlexDaniel AlexDaniel added the docs Documentation issue (primary issue type) label Sep 29, 2017
@softmoth
Copy link
Contributor

softmoth commented Nov 1, 2017

:c() and :pos() should both work. They don't do the same function (:pos() implicitly anchors the search at the position, :c() does not).

@tisonkun
Copy link
Member

tisonkun commented Nov 1, 2017

@AlexDaniel where is its location? I cannot see this sentence inside the doc grammar or grammar_tutorial now

@AlexDaniel
Copy link
Member Author

I think the issue was about this:

Additional named arguments are used as options for matching, so you can specify things like :c(4) to start parsing from the fourth character

https://docs.perl6.org/routine/parse#(Grammar)_method_parse

https://github.com/perl6/doc/blob/0b5126a5772e5047cbd9acda83be81e4b9da8d10/doc/Type/Grammar.pod6#L44

@tisonkun
Copy link
Member

tisonkun commented Nov 3, 2017

@AlexDaniel #1645 , how about other adverbs, I cannot figure it out

@AlexDaniel
Copy link
Member Author

@W4anD0eR96 I think this can be closed? The original issue says that it should not talk about “:c(123)” and it no longer does, so that is it? I don't know about %opts, maybe create another issue for it?

@tisonkun
Copy link
Member

tisonkun commented Nov 4, 2017

@AlexDaniel , agree with you.

@tisonkun tisonkun closed this as completed Nov 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type)
Projects
None yet
Development

No branches or pull requests

3 participants