Skip Menu |
 
Report information
Id: 60716
Status: resolved
Priority: 0/
Queue: perl6

Owner: pmichaud <pmichaud [at] pobox.com>
Requestors: chris [at] chrisdolan.net
Cc:
AdminCc:

Severity: (no value)
Tag: Patch
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [PATCH] invoke multi-level namespace grammars from rules
Date: Thu, 20 Nov 2008 21:58:37 -0600
To: rakudobug [...] perl.org
From: Chris Dolan <chris [...] chrisdolan.net>
Download (untitled) / with headers
text/plain 827b
This code works in Rakudo rev 32970: grammar GrammarOne { token foo { 'foo' }; } grammar GrammarTwo { token foobar { <GrammarOne::foo> 'bar' }; } 'foobar' ~~ GrammarTwo::foobar or die 'failed one-level namespace grammar'; But this code does dies: grammar Grammar::A { token foo { 'foo' }; } grammar Grammar::B { token foobar { <Grammar::A::foo> 'bar' }; } 'foobar' ~~ Grammar::B::foobar or die 'failed two-level namespace grammar'; The attached patch fixes the latter problem. The patch changes the implementation of !keyword_grammar to be much more like ! keyword_class, which has had more recent attention. If this patch is applied, I recommend that somebody do the analogous work for ! keyword_role too. guts.pir | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-)

Message body is not shown because sender requested not to inline it.

Subject: [TODO] Remove improper regex invocation syntax
RT-Send-CC: perl6-compiler [...] perl.org
On Thu Nov 20 19:59:03 2008, chris@chrisdolan.net wrote: Show quoted text
> This code works in Rakudo rev 32970: > > grammar GrammarOne { token foo { 'foo' }; } > grammar GrammarTwo { token foobar { <GrammarOne::foo> 'bar' }; } > 'foobar' ~~ GrammarTwo::foobar or die 'failed one-level namespace > grammar'; > > But this code does dies: > > grammar Grammar::A { token foo { 'foo' }; } > grammar Grammar::B { token foobar { <Grammar::A::foo> 'bar' }; } > 'foobar' ~~ Grammar::B::foobar or die 'failed two-level namespace > grammar'; > > The attached patch fixes the latter problem.
Patch rejected, as neither 'foobar' ~~ GrammarTwo::foobar nor 'foobar' ~~ Grammar::B::foobar are correct syntax for invoking a regex inside of a grammar. We don't know what the correct syntax is yet, but we know that this isn't it. Rakudo implements the first syntax from an earlier synopsis spec that has since been changed. We should probably adjust Rakudo so that it doesn't accept that form either. So, I'm converting this ticket to indicate a "todo" of remove the incorrect regex invocation syntax. Thanks! Pm
Subject: [PATCH] invoke multi-level namespace grammars from within rules
On Tue Nov 25 13:37:09 2008, pmichaud wrote: Show quoted text
> On Thu Nov 20 19:59:03 2008, chris@chrisdolan.net wrote:
> > This code works in Rakudo rev 32970: > > > > grammar GrammarOne { token foo { 'foo' }; } > > grammar GrammarTwo { token foobar { <GrammarOne::foo> 'bar' }; } > > 'foobar' ~~ GrammarTwo::foobar or die 'failed one-level namespace > > grammar'; > > > > But this code does dies: > > > > grammar Grammar::A { token foo { 'foo' }; } > > grammar Grammar::B { token foobar { <Grammar::A::foo> 'bar' }; } > > 'foobar' ~~ Grammar::B::foobar or die 'failed two-level namespace > > grammar'; > > > > The attached patch fixes the latter problem.
> > Patch rejected, as neither > > 'foobar' ~~ GrammarTwo::foobar > > nor > > 'foobar' ~~ Grammar::B::foobar > > are correct syntax for invoking a regex inside of a grammar. We don't > know what the correct syntax is yet, but we know that this isn't it. > > Rakudo implements the first syntax from an earlier synopsis spec that > has since been changed. We should probably adjust Rakudo so that it > doesn't accept that form either. > > So, I'm converting this ticket to indicate a "todo" of remove the > incorrect regex invocation syntax. > > Thanks! > > Pm
I appreciate the feedback, and you're right, but I believe your comment focuses on an incidental detail of my report (the smart match), not on the actual problem addressed. So, let me rephrase, with apologies for the distraction: Without my patch, the first of the following succeeds but the second fails. With the patch, they both succeed. My patch allows you to use more than one "::" in a <> element *inside* a regex. grammar GrammarOne { token foo { 'foo' }; } grammar GrammarTwo { token TOP { <GrammarOne::foo> 'bar' }; } 'foobar' ~~ GrammarTwo or die 'failed one-level namespace grammar'; grammar Grammar::Deep { token foo { 'foo' }; } grammar GrammarShallow { token TOP { <Grammar::Deep::foo> 'bar' }; } 'foobar' ~~ GrammarShallow or die 'failed mixed-level namespace grammar'; So, the feature enabled by this patch is the <Grammar::Deep::foo>
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 771b
On Sat Nov 29 08:34:39 2008, chrisdolan wrote: Show quoted text
> Without my patch, the first of the following succeeds but the second > fails. With the patch, they both succeed. My patch allows you to use > more than one "::" in a <> element *inside* a regex. > > grammar Grammar::Deep { token foo { 'foo' }; } > grammar GrammarShallow { token TOP { <Grammar::Deep::foo> 'bar' }; }
Yup, this patch is needed, so applied in r34045. Show quoted text
> 'foobar' ~~ GrammarShallow or die 'failed mixed-level namespace grammar'; > > So, the feature enabled by this patch is the <Grammar::Deep::foo>
'foobar' ~~ GrammarShallow isn't spec'd as doing this (we have a ticket on that elsewhere), so the test I added does 'foobar' ~~ /<GrammarShallow::TOP>/ which is, uh, spec'dish... ;-) Thanks! Jonathan


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org