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 grammar can be made not to inherit from Grammar in Rakudo #2078
Comments
From @masakFrom <http://use.perl.org/~JonathanWorthington/journal/39856>​: ] Added handling of the grammar package declarator back in. Now the <masak> rakudo: class A {}; grammar G is A { regex TOP { foo } }; G.parse("foo") |
From @cognominalpatch attached |
From @cognominal0001-fixes-77322-changed-sub-compose-in-GrammarHOW.pir-so.patchFrom 4bfe94e440eccb22490fe7b97064428b204e00f2 Mon Sep 17 00:00:00 2001
From: Stephane cognominal Payrard <cognominal@gmail.com>
Date: Sat, 21 Aug 2010 11:10:01 +0200
Subject: [PATCH] fixes #77322 : changed sub compose in GrammarHOW.pir so that grammars always inherit from Grammar
---
src/metamodel/GrammarHOW.pir | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/metamodel/GrammarHOW.pir b/src/metamodel/GrammarHOW.pir
index 6c36a64..c5b7110 100644
--- a/src/metamodel/GrammarHOW.pir
+++ b/src/metamodel/GrammarHOW.pir
@@ -26,20 +26,28 @@ Grammar by default.
=item compose(meta)
-If there is no explicit parent, makes Grammar the default parent and then
+If none of the parents is a Grammar, add Grammar as a parent and then
delegates to ClassHOW.
=cut
.sub 'compose' :method
.param pmc obj
- .local pmc parrotclass
+ .local pmc parrotclass, grammarclass
+ grammarclass = get_hll_global 'Grammar'
parrotclass = getattribute self, 'parrotclass'
$P0 = inspect parrotclass, 'parents'
- if $P0 goto have_parents
- $P0 = get_hll_global 'Grammar'
- self.'add_parent'(obj, $P0)
- have_parents:
+ unless $P0 goto add_grammar_as_parent
+ $P1 = iter $P0
+loop_on_parents:
+ unless $P1 goto add_grammar_as_parent
+ $P2 = shift $P1
+ $I0 = $P2.'isa'(grammarclass)
+ if $I0 goto loop_on_parents_done
+ goto loop_on_parents
+ add_grammar_as_parent:
+ self.'add_parent'(obj, grammarclass)
+ loop_on_parents_done:
$P0 = get_hll_global 'ClassHOW'
$P0 = find_method $P0, 'compose'
.tailcall $P0(self, obj)
--
1.7.0.3.291.g5e4f6
|
The RT System itself - Status changed from 'new' to 'open' |
From @moritzthanks, applied the patch, and added tests to S05-grammar/inheritance.t |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#77322 (status was 'resolved')
Searchable as RT77322$
The text was updated successfully, but these errors were encountered: