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

Rakudo stores a grammar in $/ after .parse #648

Closed
p6rt opened this issue Jan 24, 2009 · 5 comments
Closed

Rakudo stores a grammar in $/ after .parse #648

p6rt opened this issue Jan 24, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jan 24, 2009

Migrated from rt.perl.org#62704 (status was 'resolved')

Searchable as RT62704$

@p6rt
Copy link
Author

p6rt commented Jan 24, 2009

From @masak

r35957​:

$ perl6 -e 'grammar G { regex TOP { ^ } }; G.parse(""); say $/.WHAT;
say $/ ~~ Match'
G
0

What I usually expect in $/ is a Match object that I can query for
matched tokens. I don't know how to do that with a G object; neither
does Rakudo.

@p6rt
Copy link
Author

p6rt commented Jan 27, 2009

From @masak

On Sat Jan 24 08​:42​:32 2009, masak wrote​:

r35957​:

$ perl6 -e 'grammar G { regex TOP { ^ } }; G.parse(""); say $/.WHAT;
say $/ ~~ Match'
G
0

What I usually expect in $/ is a Match object that I can query for
matched tokens. I don't know how to do that with a G object; neither
does Rakudo.

Turns out this isn't .parse-specific​:

$ perl6 -e 'grammar G { regex TOP { ^ <token>* $ }; regex token { <foo>
| <bar> }; regex foo { foo }; regex bar { bar } }; "foobar" ~~
/<G​::TOP>/ or die "AOUCH"; say .WHAT for $<G​::TOP><token>'
G
G

I'd like for these to be Match objects, as well.

@p6rt
Copy link
Author

p6rt commented Jan 27, 2009

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 1, 2009

From @pmichaud

Now fixed in 0bbdb57​:

$ ./perl6 -e 'grammar G { regex TOP { ^ }; }; G.parse(""); say $/ ~~ Match'
1

Note that in PGE (and Rakudo), Grammar objects are subclasses of Match
objects. We do this in order to get subrule/method inheritance correct
during the match. So, if you perform G.parse(), then the result you get
back will be of type 'G' (which is now properly a subclass of Rakudo's
Match type -- previously it was a subclass of something else).

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Mar 1, 2009

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 1, 2009
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

1 participant