Author: pmichaud
Date: Wed Oct 3 13:59:42 2007
New Revision: 21799
Modified:
branches/pdd15oo/compilers/pge/PGE/Exp.pir
branches/pdd15oo/compilers/pge/PGE/Match.pir
branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir
branches/pdd15oo/config/gen/makefiles/pge.in
branches/pdd15oo/t/compilers/pge/02-match.t
branches/pdd15oo/t/compilers/pge/03-optable.t
branches/pdd15oo/t/compilers/pge/04-compile.t
Log:
[pge]:
* Some updates to match pdd15oo model.
* More things work than before, but many tests still fail.
* More updates soon.
Modified: branches/pdd15oo/compilers/pge/PGE/Exp.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Exp.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Exp.pir Wed Oct 3 13:59:42 2007
@@ -33,7 +33,7 @@
$P1 = subclass $P0, ['PGE';'Exp';'Alt']
$P1 = subclass $P0, ['PGE';'Exp';'Conj']
$P1 = subclass $P0, ['PGE';'Exp';'Group']
- $P1 = subclass $P0, ['PGE';'Exp';'CGroup']
+ $P1 = subclass $P1, ['PGE';'Exp';'CGroup']
$P1 = subclass $P0, ['PGE';'Exp';'Subrule']
$P1 = subclass $P0, ['PGE';'Exp';'Cut']
$P1 = subclass $P0, ['PGE';'Exp';'Quant']
@@ -52,8 +52,7 @@
=cut
-.sub 'compile'
- .param pmc source
+.sub 'compile' :method
.param pmc adverbs :slurpy :named
.local string target
@@ -62,17 +61,26 @@
if target == 'parse' goto return_exp
if target == 'pge::exp' goto return_exp
- .local string grammar
- .local string nsformat
- nsformat = '.namespace'
- grammar = adverbs['grammar']
- if grammar == '' goto pir
- nsformat = ".namespace ['%0']"
- pir:
.local pmc code
code = new 'CodeString'
- code.'emit'(nsformat, grammar)
- $P0 = source.'root_pir'(adverbs :flat :named)
+
+ .local string grammar
+
+ grammar = adverbs['grammar']
+ if grammar goto have_grammar
+ code.'emit'('.namespace')
+ goto done_grammar
+ have_grammar:
+ .local pmc grammar_key
+ grammar_key = split '::', grammar
+ $S0 = code.'key'(grammar_key :flat)
+ code.'emit'('.namespace %0', $S0)
+ push_eh done_grammar
+ $P0 = subclass ['PGE';'Grammar'], grammar_key
+ clear_eh
+ done_grammar:
+
+ $P0 = self.'root_pir'(adverbs :flat :named)
code .= $P0
if target != 'pir' goto bytecode
.return (code)
@@ -80,15 +88,10 @@
bytecode:
$P0 = compreg 'PIR'
$P1 = $P0(code)
- make_grammar:
- push_eh end
- $P0 = subclass ['PGE';'Grammar'], grammar
- clear_eh
- end:
.return ($P1)
return_exp:
- .return (source)
+ .return (self)
.end
Modified: branches/pdd15oo/compilers/pge/PGE/Match.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Match.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Match.pir Wed Oct 3 13:59:42 2007
@@ -116,7 +116,7 @@
unless $I0 goto with_grammar
grammar = adverbs['grammar']
$P0 = split '::', grammar
- $P1 = get_namespace $P0
+ $P1 = get_hll_namespace $P0
gclass = get_class $P1
with_grammar:
with_adverbs:
Modified: branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir Wed Oct 3 13:59:42 2007
@@ -156,8 +156,6 @@
.include 'cclass.pasm'
-.namespace ['PGE';'Perl6Regex']
-
.sub '__onload' :load
.local pmc optable
@@ -271,7 +269,7 @@
# Create an array for holding stop tokens
$P0 = new 'ResizablePMCArray'
- set_hll_global '@!stopstack', $P0
+ set_global '@!stopstack', $P0
$P0 = get_global 'compile_perl6regex'
compreg 'PGE::Perl6Regex', $P0
@@ -299,7 +297,7 @@
lastpos = length target
.local string stop
- $P0 = get_hll_global '@!stopstack'
+ $P0 = get_global '@!stopstack'
stop = $P0[-1]
$I0 = is_cclass .CCLASS_WHITESPACE, target, pos
@@ -491,7 +489,7 @@
.local pmc key
.local int pos, lastpos
key = mob['KEY']
- (mob, pos) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
lastpos = length target
@@ -707,7 +705,7 @@
.local string key
key = mob['KEY']
mobsave = mob
- (mob, pos) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Subrule')
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Subrule')
lastpos = length target
.local string subname
Modified: branches/pdd15oo/config/gen/makefiles/pge.in
==============================================================================
--- branches/pdd15oo/config/gen/makefiles/pge.in (original)
+++ branches/pdd15oo/config/gen/makefiles/pge.in Wed Oct 3 13:59:42 2007
@@ -7,23 +7,12 @@
PARROT = ../../[EMAIL PROTECTED]@
TOOL_DIR = ../..
CP = @cp@
-BUILD = $(PERL) @build_dir@/tools/build/dynpmc.pl
-O = @o@
-LOAD_EXT = @load_ext@
-PARROT_DYNEXT = @build_dir@/runtime/parrot/dynext
-PMCDIR = PGE/pmc
# Where to put things
PARROT_LIBRARY = ../../runtime/parrot/library
# the default target
-all: $(PMCDIR)/pge_group$(LOAD_EXT) $(PARROT_LIBRARY)/PGE.pbc
-
-PMCS = \
- codestring
-
-PMC_SOURCES = \
- $(PMCDIR)/codestring.pmc
+all: $(PARROT_LIBRARY)/PGE.pbc
SOURCES = PGE.pir \
PGE/Exp.pir \
@@ -33,8 +22,7 @@
PGE/Perl6Regex.pir \
PGE/OPTable.pir \
PGE/P5Regex.pir \
- PGE/builtins.pg \
- pgc.pir \
+ $(PARROT_LIBRARY)/PGE/Perl6Grammar.pir \
$(PARROT_LIBRARY)/PGE.pbc: PGE.pbc
$(CP) PGE.pbc $(PARROT_LIBRARY)
@@ -43,14 +31,6 @@
$(RM_RF) PGE.pbc $(PARROT_LIBRARY)/PGE.pbc
$(PERL) -e "" >PGE/builtins_gen.pir
$(PARROT) -o PGE.pbc --output-pbc PGE.pir
- $(PARROT) pgc.pir --output=PGE/builtins_gen.pir PGE/builtins.pg
- $(PARROT) -o PGE.pbc --output-pbc PGE.pir
-
-$(PMCDIR)/pge_group$(LOAD_EXT): $(PARROT) $(PMC_SOURCES)
- cd $(PMCDIR) && $(BUILD) generate $(PMCS)
- cd $(PMCDIR) && $(BUILD) compile $(PMCS)
- cd $(PMCDIR) && $(BUILD) linklibs $(PMCS)
- cd $(PMCDIR) && $(BUILD) copy --destination=$(PARROT_DYNEXT) $(PMCS)
# This is a listing of all targets, that are meant to be called by users
help:
@@ -88,16 +68,6 @@
PGE.pbc \
$(PARROT_LIBRARY)/PGE.pbc \
PGE/builtins_gen.pir \
- $(PMCDIR)/*.h \
- $(PMCDIR)/*.c \
- $(PMCDIR)/*.dump \
- $(PMCDIR)/*.pdb \
- $(PMCDIR)/*.lib \
- $(PMCDIR)/*.exp \
- $(PMCDIR)/*.ilk \
- $(PMCDIR)/*.manifest \
- $(PMCDIR)/*$(O) \
- $(PMCDIR)/*$(LOAD_EXT)
realclean: clean
$(RM_RF) Makefile
Modified: branches/pdd15oo/t/compilers/pge/02-match.t
==============================================================================
--- branches/pdd15oo/t/compilers/pge/02-match.t (original)
+++ branches/pdd15oo/t/compilers/pge/02-match.t Wed Oct 3 13:59:42 2007
@@ -27,7 +27,7 @@
.sub main :main
load_bytecode 'PGE.pbc'
- $P0 = compreg 'PGE::P6Regex'
+ $P0 = compreg 'PGE::Perl6Regex'
$P1 = $P0('.+')
$P2 = $P1('world')
@@ -49,7 +49,7 @@
.sub main :main
.local pmc match, str, arr
load_bytecode 'PGE.pbc'
- match = new 'PGE::Match'
+ match = new ['PGE';'Match']
str = new 'String'
str = 'foo'
push match, str
Modified: branches/pdd15oo/t/compilers/pge/03-optable.t
==============================================================================
--- branches/pdd15oo/t/compilers/pge/03-optable.t (original)
+++ branches/pdd15oo/t/compilers/pge/03-optable.t Wed Oct 3 13:59:42 2007
@@ -92,7 +92,7 @@
load_bytecode 'PGE/Dumper.pir'
.local pmc optable
- optable = new 'PGE::OPTable'
+ optable = new ['PGE';'OPTable']
optable.newtok('infix:+', 'precedence'=>'=')
optable.newtok('infix:-', 'equiv'=>'infix:+')
@@ -110,7 +110,7 @@
optable.newtok('postfix:--', 'equiv'=>'prefix:++')
.local pmc ident
- ident = find_global 'PGE::Match', 'ident'
+ ident = get_global ['PGE';'Match'], 'ident'
optable.newtok('term:', 'tighter'=>'prefix:++', 'parsed'=>ident)
optable.newtok('circumfix:( )', 'equiv'=>'term:')
optable.newtok('circumfix:[ ]', 'equiv'=>'term:')
Modified: branches/pdd15oo/t/compilers/pge/04-compile.t
==============================================================================
--- branches/pdd15oo/t/compilers/pge/04-compile.t (original)
+++ branches/pdd15oo/t/compilers/pge/04-compile.t Wed Oct 3 13:59:42 2007
@@ -62,7 +62,7 @@
.local pmc p6compiler
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'PGE::Test')
- $P2 = get_hll_global ['PGE::Test'], 'xyz'
+ $P2 = get_hll_global ['PGE';'Test'], 'xyz'
$P3 = $P2('ok 1')
say $P3
.end
@@ -78,7 +78,7 @@
p6compiler = compreg 'PGE::Perl6Regex'
$P1 = p6compiler('.+', 'name'=>'abc', 'grammar'=>'PGE::Test')
$P1 = p6compiler('.+', 'name'=>'xyz', 'grammar'=>'PGE::Test')
- $P2 = get_hll_global ['PGE::Test'], 'abc'
+ $P2 = get_hll_global ['PGE';'Test'], 'abc'
$P3 = $P2('ok 1')
say $P3
.end