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

/<a foo bar>/ parses, but is that a valid syntax? #1634

Closed
zoffixznet opened this issue Mar 20, 2018 · 2 comments
Closed

/<a foo bar>/ parses, but is that a valid syntax? #1634

zoffixznet opened this issue Mar 20, 2018 · 2 comments

Comments

@zoffixznet
Copy link
Contributor

Stumbled on this calling form that seems to parse the space separated stuff as regexes and then calls the token with ForeignCode that appears to be some regex stuff.

Is this valid syntax for some feature or is this an error that should be throwing?

16:42 	camelia 	rakudo-moar 8e1366e7a: OUTPUT: «ForeignCode.new␤»
16:42 	Zoffix 	m: grammar { token TOP { <a foobarber> }; method a($_) { .perl.say; exit } }.parse: ""
16:42 	camelia 	rakudo-moar 8e1366e7a: OUTPUT: «ForeignCode.new␤»
16:42 	Zoffix 	m: grammar { token TOP { <a foobarber zef> }; method a($_) { .perl.say; exit } }.parse: ""
16:42 	camelia 	rakudo-moar 8e1366e7a: OUTPUT: «Potential difficulties:␤    Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)␤    at <tmp>:1␤    ------> 3grammar { token TOP { <a foobarb…»

16:46 	Zoffix 	m: say grammar { token TOP { <a alpha> }; token a($_) { . { say $_(Match.^lookup("!cursor_init")(Match, "abc", :0c)) } } }.parse: "abc"
16:46 	camelia 	rakudo-moar 8e1366e7a: OUTPUT: «#<failed match>␤Nil␤»
@jnthn
Copy link
Member

jnthn commented Mar 20, 2018

Yes, it is the syntax that lets us parse <before abc> and similar. Unlike with <foo: ...> and <foo(...)>, where the args are parsed by the MAIN language, the <foo ...> form parses the rest of the assertion using the regex language, wraps it in a closure, and passes it to foo. Thus it's a general syntax for higher-order regex operators - which is just what before/after are.

@zoffixznet
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants