Author: pmichaud
Date: Fri Oct 5 00:07:27 2007
New Revision: 21881
Modified:
branches/pdd15oo/compilers/pge/PGE/Exp.pir
branches/pdd15oo/compilers/pge/PGE/Match.pir
branches/pdd15oo/compilers/pge/PGE/OPTable.pir
branches/pdd15oo/compilers/pge/PGE/P5Regex.pir
branches/pdd15oo/compilers/pge/PGE/P6Regex.pir
branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir
branches/pdd15oo/compilers/pge/PGE/Regex.pir
branches/pdd15oo/config/gen/makefiles/pge.in
branches/pdd15oo/runtime/parrot/library/PGE/Text.pir
branches/pdd15oo/runtime/parrot/library/PGE/Util.pir
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]:
* Revert PGE sources to current trunk (eliminating nested namespace
code), so that we can easily apply pdd15oo changes to the trunk
source.
Modified: branches/pdd15oo/compilers/pge/PGE/Exp.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Exp.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Exp.pir Fri Oct 5 00:07:27 2007
@@ -4,7 +4,7 @@
=cut
-.namespace ['PGE';'Exp']
+.namespace [ "PGE::Exp" ]
.include "interpinfo.pasm"
.include "cclass.pasm"
@@ -21,25 +21,25 @@
.local pmc optable
.local pmc term
- $P0 = get_class ['PGE';'Match']
- $P0 = subclass $P0, ['PGE';'Exp']
- $P1 = subclass $P0, ['PGE';'Exp';'Literal']
- $P1 = subclass $P0, ['PGE';'Exp';'Scalar']
- $P1 = subclass $P0, ['PGE';'Exp';'CCShortcut']
- $P1 = subclass $P0, ['PGE';'Exp';'Newline']
- $P1 = subclass $P0, ['PGE';'Exp';'EnumCharList']
- $P1 = subclass $P0, ['PGE';'Exp';'Anchor']
- $P1 = subclass $P0, ['PGE';'Exp';'Concat']
- $P1 = subclass $P0, ['PGE';'Exp';'Alt']
- $P1 = subclass $P0, ['PGE';'Exp';'Conj']
- $P1 = subclass $P0, ['PGE';'Exp';'Group']
- $P1 = subclass $P1, ['PGE';'Exp';'CGroup']
- $P1 = subclass $P0, ['PGE';'Exp';'Subrule']
- $P1 = subclass $P0, ['PGE';'Exp';'Cut']
- $P1 = subclass $P0, ['PGE';'Exp';'Quant']
- $P1 = subclass $P0, ['PGE';'Exp';'Modifier']
- $P1 = subclass $P0, ['PGE';'Exp';'Closure']
- $P1 = subclass $P0, ['PGE';'Exp';'Action']
+ $P0 = getclass "PGE::Match"
+ $P0 = subclass $P0, "PGE::Exp"
+ $P1 = subclass $P0, "PGE::Exp::Literal"
+ $P1 = subclass $P0, "PGE::Exp::Scalar"
+ $P1 = subclass $P0, "PGE::Exp::CCShortcut"
+ $P1 = subclass $P0, 'PGE::Exp::Newline'
+ $P1 = subclass $P0, "PGE::Exp::EnumCharList"
+ $P1 = subclass $P0, "PGE::Exp::Anchor"
+ $P1 = subclass $P0, "PGE::Exp::Concat"
+ $P1 = subclass $P0, "PGE::Exp::Alt"
+ $P1 = subclass $P0, "PGE::Exp::Conj"
+ $P1 = subclass $P0, "PGE::Exp::Group"
+ $P1 = subclass $P1, "PGE::Exp::CGroup"
+ $P1 = subclass $P0, "PGE::Exp::Subrule"
+ $P1 = subclass $P0, "PGE::Exp::Cut"
+ $P1 = subclass $P0, "PGE::Exp::Quant"
+ $P1 = subclass $P0, "PGE::Exp::Modifier"
+ $P1 = subclass $P0, "PGE::Exp::Closure"
+ $P1 = subclass $P0, "PGE::Exp::Action"
.end
@@ -48,11 +48,12 @@
=item C<compile(PMC source, PMC adverbs :slurpy :named)>
Compile the C<source> expression into PIR or a subroutine,
-according to the C<target> adverb.
+according to the C<target> adverb.
=cut
-.sub 'compile' :method
+.sub 'compile'
+ .param pmc source
.param pmc adverbs :slurpy :named
.local string target
@@ -61,26 +62,17 @@
if target == 'parse' goto return_exp
if target == 'pge::exp' goto return_exp
- .local pmc code
- code = new 'CodeString'
-
.local string grammar
-
+ .local string nsformat
+ nsformat = '.namespace'
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)
+ 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)
code .= $P0
if target != 'pir' goto bytecode
.return (code)
@@ -88,10 +80,15 @@
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 (self)
+ .return (source)
.end
@@ -116,7 +113,7 @@
.local pmc exp
.local string explabel
exp = self
- set_hll_global ['PGE';'Exp'], '$!group', exp
+ set_hll_global ['PGE::Exp'], '$!group', exp
exp = exp.reduce(self)
## we don't need a coroutine if :ratchet is set
@@ -152,7 +149,7 @@
.local string target :unique_reg
.local pmc mfrom, mpos :unique_reg
.local int cpos, iscont :unique_reg
- $P0 = get_hll_global ['PGE'], 'Match'
+ $P0 = getclass 'PGE::Match'
(mob, cpos, target, mfrom, mpos, iscont) = $P0.'new'(mob, adverbs
:flat :named)
$P0 = interpinfo %1
setattribute mob, '&!corou', $P0
@@ -169,7 +166,7 @@
.local string target :unique_reg
.local pmc mfrom, mpos :unique_reg
.local int cpos, iscont :unique_reg
- $P0 = get_hll_global ['PGE'], 'Match'
+ $P0 = getclass 'PGE::Match'
(mob, cpos, target, mfrom, mpos, iscont) = $P0.'new'(mob, adverbs
:flat :named)
CODE
@@ -235,7 +232,7 @@
code.emit(" .end")
.return (code)
.end
-
+
.sub 'getargs' :method
.param pmc label
@@ -307,7 +304,7 @@
.end
-.namespace ['PGE';'Exp';'Literal']
+.namespace [ 'PGE::Exp::Literal' ]
.sub 'reduce' :method
.param pmc next
@@ -349,7 +346,7 @@
.end
-.namespace ['PGE';'Exp';'Concat']
+.namespace [ 'PGE::Exp::Concat' ]
.sub 'reduce' :method
.param pmc next
@@ -376,10 +373,10 @@
inc i
if i >= n goto concat_lit_end
exp1 = children[i]
- $I1 = isa exp1, ['PGE';'Exp';'Literal']
+ $I1 = isa exp1, 'PGE::Exp::Literal'
if $I1 == 0 goto concat_lit_shift
exp0 = children[j]
- $I0 = isa exp0, ['PGE';'Exp';'Literal']
+ $I0 = isa exp0, 'PGE::Exp::Literal'
if $I0 == 0 goto concat_lit_shift
$I0 = exp0['ignorecase']
$I1 = exp1['ignorecase']
@@ -430,7 +427,7 @@
.end
-.namespace ['PGE';'Exp';'Quant']
+.namespace [ 'PGE::Exp::Quant' ]
.sub 'reduce' :method
.param pmc next
@@ -468,7 +465,7 @@
if $I0 == 0 goto outer_quant
.return ()
- outer_quant:
+ outer_quant:
.local pmc args
args = self.'getargs'(label, next, 'quant' => self)
@@ -593,7 +590,7 @@
.end
-.namespace ['PGE';'Exp';'Group']
+.namespace [ 'PGE::Exp::Group' ]
.sub 'reduce' :method
.param pmc next
@@ -604,9 +601,9 @@
## This group is non-backtracking, so concatenate a "cut group"
## node (PGE::Exp::Cut) to its child.
exp = self[0]
- $P0 = new ['PGE';'Exp';'Concat']
+ $P0 = new 'PGE::Exp::Concat'
$P0[0] = exp
- $P1 = new ['PGE';'Exp';'Cut']
+ $P1 = new 'PGE::Exp::Cut'
$P0[1] = $P1
self[0] = $P0
@@ -614,11 +611,11 @@
.local pmc group
## Temporarily store this group as the current group. Any
## cut nodes we encounter will set a cutmark into this group.
- group = get_hll_global ['PGE';'Exp'], '$!group'
- set_hll_global ['PGE';'Exp'], '$!group', self
+ group = get_hll_global ['PGE::Exp'], '$!group'
+ set_hll_global ['PGE::Exp'], '$!group', self
exp = self[0]
exp = exp.reduce(next)
- set_hll_global ['PGE';'Exp'], '$!group', group
+ set_hll_global ['PGE::Exp'], '$!group', group
$I0 = self['cutmark']
if $I0 > 0 goto keep_group
$I0 = self['iscapture']
@@ -656,7 +653,7 @@
.end
-.namespace ['PGE';'Exp';'CGroup']
+.namespace [ 'PGE::Exp::CGroup' ]
.sub 'pir' :method
.param pmc code
@@ -689,7 +686,7 @@
isscope_end:
code.emit(<<" CODE", captgen, captsave, captback, 'E'=>explabel,
args :flat :named)
- %L: # capture
+ %L: # capture
%0
captob = captscope.'new'(captscope, 'pos'=>pos)
push gpad, captscope
@@ -724,7 +721,7 @@
.end
-.namespace ['PGE';'Exp';'Subrule']
+.namespace [ 'PGE::Exp::Subrule' ]
.sub 'reduce' :method
.param pmc next
@@ -840,7 +837,7 @@
goto fail\n
CODE
goto end
- .return()
+ .return()
subrule_negated:
## This handles negative subrule matches; if a subrule fails, then
@@ -858,9 +855,9 @@
end:
.return()
.end
+
-
-.namespace ['PGE';'Exp';'Alt']
+.namespace [ 'PGE::Exp::Alt' ]
.sub 'reduce' :method
.param pmc next
@@ -899,13 +896,13 @@
.end
-.namespace ['PGE';'Exp';'Anchor']
+.namespace [ 'PGE::Exp::Anchor' ]
.sub 'reduce' :method
.param pmc next
.return (self)
.end
-
+
.sub 'pir' :method
.param pmc code
.param pmc label
@@ -1013,7 +1010,7 @@
.end
-.namespace ['PGE';'Exp';'CCShortcut']
+.namespace [ 'PGE::Exp::CCShortcut' ]
.sub 'reduce' :method
.param pmc next
@@ -1043,7 +1040,7 @@
goto end
newline:
self['cclass'] = .CCLASS_NEWLINE
- end:
+ end:
.return (self)
.end
@@ -1092,9 +1089,9 @@
if negate == 0 goto emit_pir
negstr = ''
- emit_pir:
+ emit_pir:
code.emit(<<" CODE", token, negstr, cclass, args :flat :named)
- %L: # cclass %0 %Q
+ %L: # cclass %0 %Q
$I0 = find%1_cclass %2, target, pos, lastpos
rep = $I0 - pos
%Mif rep < %m goto fail
@@ -1105,7 +1102,7 @@
if backtrack == PGE_BACKTRACK_NONE goto bt_none
if backtrack == PGE_BACKTRACK_EAGER goto bt_eager
-
+
bt_greedy:
code.emit(<<" CODE", args :flat :named)
pos += rep
@@ -1121,7 +1118,7 @@
dec rep
goto %L_2
CODE
- .return (1)
+ .return (1)
bt_none:
code.emit(" pos += rep\n goto %0\n", next)
@@ -1143,10 +1140,10 @@
dec rep
goto %L_2
CODE
-
+
.end
-.namespace ['PGE';'Exp';'Cut']
+.namespace [ 'PGE::Exp::Cut' ]
.sub 'reduce' :method
.param pmc next
@@ -1158,7 +1155,7 @@
## This node is cutting a group. We need to
## get the current group's cutmark, or set
## one if it doesn't already have one.
- group = get_hll_global ['PGE';'Exp'], '$!group'
+ group = get_hll_global ['PGE::Exp'], '$!group'
cutmark = group['cutmark']
if cutmark > 0 goto has_cutmark
$P1 = new 'CodeString'
@@ -1198,7 +1195,7 @@
.end
-.namespace ['PGE';'Exp';'Scalar']
+.namespace [ 'PGE::Exp::Scalar' ]
.sub 'reduce' :method
.param pmc next
@@ -1213,7 +1210,7 @@
.local string cname
cname = self['cname']
code.emit(<<" CODE", label, next, cname)
- %0: # scalar %2
+ %0: # scalar %2
$P0 = mob[%2]
$I0 = does $P0, 'array'
if $I0 == 0 goto %0_1
@@ -1232,7 +1229,7 @@
.end
-.namespace ['PGE';'Exp';'EnumCharList']
+.namespace [ 'PGE::Exp::EnumCharList' ]
.sub 'reduce' :method
.param pmc next
@@ -1273,8 +1270,8 @@
.return ()
.end
-
-.namespace ['PGE';'Exp';'Newline']
+
+.namespace [ 'PGE::Exp::Newline' ]
.sub 'reduce' :method
.param pmc next
@@ -1299,7 +1296,7 @@
.end
-.namespace ['PGE';'Exp';'Conj']
+.namespace [ 'PGE::Exp::Conj' ]
.sub 'reduce' :method
.param pmc next
@@ -1357,7 +1354,7 @@
.return ()
.end
-.namespace ['PGE';'Exp';'Closure']
+.namespace [ "PGE::Exp::Closure" ]
.sub 'reduce' :method
.param pmc next
@@ -1378,7 +1375,7 @@
$S0 = concat %2, ':"'
$S1 = %3
$S0 .= $S1
- $P0 = get_hll_global ['PGE';'Match'], '%!cache'
+ $P0 = get_hll_global ['PGE::Match'], '%!cache'
$I0 = exists $P0[$S0]
if $I0 goto %0_1
$P1 = compreg %2
@@ -1399,8 +1396,8 @@
CODE
.return ()
.end
-
-.namespace ['PGE';'Exp';'Action']
+
+.namespace [ "PGE::Exp::Action" ]
.sub 'reduce' :method
.param pmc next
Modified: branches/pdd15oo/compilers/pge/PGE/Match.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Match.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Match.pir Fri Oct 5 00:07:27 2007
@@ -8,11 +8,11 @@
=cut
-.namespace ['PGE';'Match']
+.namespace [ 'PGE::Match' ]
.sub '__onload' :load
.local pmc base
- base = subclass 'Hash', ['PGE';'Match']
+ base = subclass 'Hash', 'PGE::Match'
addattribute base, '$.target' # target
addattribute base, '$.from' # start of match
addattribute base, '$.pos' # current match position
@@ -20,13 +20,69 @@
addattribute base, '@!capt' # subpattern captures
addattribute base, '$!result' # result object
- # create PGE::Match proto-object
- $P0 = new ['PGE';'Match']
+ $P0 = new 'PGE::Match'
set_hll_global ['PGE'], 'Match', $P0
.return ()
.end
+=head2 Functions
+
+=over 4
+
+=item C<newfrom(PMC mob [, int from [, string grammar]])>
+
+Creates a new Match object, based on C<mob>. If C<grammar> is
+specified then the newly created object is an instance of that class,
+otherwise if C<isa mob, 'PGE::Match'> then the new object is the
+same class as C<mob>, otherwise the new object is a 'PGE::Match'
+object. The optional C<from> parameter says how to initialize
+the C<$.from> attribute of the new object if it can't start from
+the current position of C<mob>.
+
+=cut
+
+.sub 'newfrom'
+ .param pmc mob
+ .param int fromd :optional # default from for new
+ .param int has_fromd :opt_flag
+ .param string grammar :optional # grammar to use
+ .param int has_grammar :opt_flag
+ .local pmc me, target, from, pos
+
+ newfrom_1:
+ $I0 = isa mob, 'PGE::Match'
+ if $I0 goto newfrom_mob
+ target = new 'String'
+ assign target, mob
+ from = new 'Integer'
+ from = -1
+ if has_grammar goto new_me
+ grammar = 'PGE::Match'
+ goto new_me
+ newfrom_mob:
+ if has_grammar goto newfrom_2
+ grammar = classname mob
+ newfrom_2:
+ target = getattribute mob, '$.target'
+ from = getattribute mob, '$.pos'
+ from = clone from
+ new_me:
+ me = new grammar
+ setattribute me, '$.target', target
+ setattribute me, '$.from', from
+ pos = new 'Integer'
+ pos = -1
+ setattribute me, '$.pos', pos
+ if has_fromd == 0 goto end
+ if from >= 0 goto end
+ from = fromd
+ end:
+ .return (me, target, from, pos)
+.end
+
+=back
+
=head2 Methods
=over 4
@@ -65,22 +121,22 @@
## set values based on src param
.local int issrcmatch, pos, iscont
.local string grammar
- .local pmc target, gclass
- issrcmatch = isa src, ['PGE';'Match']
+ .local pmc target
+ issrcmatch = isa src, 'PGE::Match'
if issrcmatch goto target_from_src
.local pmc target
target = new 'String'
target = src
pos = 0
iscont = 1
- gclass = typeof self
+ grammar = classname self
goto adverb_pos
target_from_src:
target = getattribute src, '$.target'
$P0 = getattribute src, '$.pos'
pos = $P0
iscont = 0
- gclass = typeof self
+ grammar = classname src
if pos >= 0 goto adverb_pos
pos = 0
@@ -115,15 +171,12 @@
$I0 = exists adverbs['grammar']
unless $I0 goto with_grammar
grammar = adverbs['grammar']
- $P0 = split '::', grammar
- $P1 = get_hll_namespace $P0
- gclass = get_class $P1
with_grammar:
with_adverbs:
## create the new match object
.local pmc mob, mfrom, mpos
- mob = new gclass
+ mob = new grammar
setattribute mob, '$.target', target
mfrom = new 'Integer'
mfrom = pos
Modified: branches/pdd15oo/compilers/pge/PGE/OPTable.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/OPTable.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/OPTable.pir Fri Oct 5 00:07:27 2007
@@ -10,7 +10,7 @@
=cut
-.namespace ['PGE';'OPTable']
+.namespace [ "PGE::OPTable" ]
.const int PGE_OPTABLE_EXPECT_TERM = 0x01
.const int PGE_OPTABLE_EXPECT_OPER = 0x02
@@ -34,8 +34,8 @@
.sub '__onload' :load
.local pmc base
.local pmc sctable
- $P0 = get_class 'Hash'
- base = subclass $P0, ['PGE';'OPTable']
+ $P0 = getclass 'Hash'
+ base = subclass $P0, 'PGE::OPTable'
addattribute base, '%!key'
addattribute base, '%!klen'
addattribute base, '&!ws'
@@ -77,8 +77,8 @@
tokentable = self
keytable = new 'Hash'
klentable = new 'Hash'
- setattribute self, '%!key', keytable
- setattribute self, '%!klen', klentable
+ setattribute self, "PGE::OPTable\x0%!key", keytable
+ setattribute self, "PGE::OPTable\x0%!klen", klentable
.end
@@ -93,7 +93,7 @@
key = substr name, $I0
.local pmc sctable, token
- sctable = get_global '%!sctable'
+ sctable = get_hll_global ["PGE::OPTable"], "%!sctable"
$I0 = exists sctable[syncat]
if $I0 == 0 goto token_hash
token = sctable[syncat]
@@ -119,7 +119,7 @@
token[$P1] = $P2
goto args_loop
args_end:
-
+
$S0 = token['match']
if $S0 > '' goto with_match
token['match'] = 'PGE::Match'
@@ -173,8 +173,8 @@
add_key:
.local pmc keytable, klentable
- keytable = getattribute self, '%!key'
- klentable = getattribute self, '%!klen'
+ keytable = getattribute self, "PGE::OPTable\x0%!key"
+ klentable = getattribute self, "PGE::OPTable\x0%!klen"
$I1 = length key
$S0 = substr key, 0, 1
$I0 = klentable[$S0]
@@ -226,8 +226,8 @@
.local int circumnest
tokentable = self
- keytable = getattribute self, '%!key'
- klentable = getattribute self, '%!klen'
+ keytable = getattribute self, "PGE::OPTable\x0%!key"
+ klentable = getattribute self, "PGE::OPTable\x0%!klen"
unless null adverbs goto with_adverbs
adverbs = new 'Hash'
@@ -279,7 +279,7 @@
tighter = token['precedence']
with_tighter:
- ws = getattribute self, '&!ws'
+ ws = getattribute self, "PGE::OPTable\x0&!ws"
tokenstack = new 'ResizablePMCArray'
operstack = new 'ResizablePMCArray'
termstack = new 'ResizablePMCArray'
@@ -366,7 +366,7 @@
$I0 = expect & PGE_OPTABLE_EXPECT_TERM
if $I0 == 0 goto end
## otherwise, let's add a "dummy" term to the stack for reduction
- oper = mob.'new'(mob, 'pos'=>pos)
+ oper = mob.'new'(mob)
push termstack, oper
## if the current operator doesn't allow nullterm, end match
unless tokenstack goto end
@@ -465,7 +465,7 @@
wspos = -1
$P0 = pop termstack
if topcat != PGE_OPTABLE_CIRCUMFIX goto reduce_end
- oper = mob.'new'(mob, 'pos'=>pos)
+ oper = mob.'new'(mob)
push termstack, oper
goto reduce_end
reduce_close:
@@ -519,7 +519,7 @@
$I0 = exists token['parsed']
if $I0 goto token_match_sub
$S0 = token['match']
- oper = mob.'new'(mob, 'pos'=>pos, 'grammar'=>$S0)
+ oper = mob.'new'(mob, 'grammar'=>$S0)
$I0 = length key
$I0 += pos
oper.'to'($I0)
@@ -532,9 +532,10 @@
mpos = $I0
oper = $P0(mob, 'action'=>action)
delete mob['KEY']
- oper.'from'(pos)
+ $P0 = oper.from()
+ $P0 = pos
token_match_success:
- $P0 = token['name']
+ $P0 = token["name"]
$P0 = clone $P0
oper['type'] = $P0
oper['top'] = token
Modified: branches/pdd15oo/compilers/pge/PGE/P5Regex.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/P5Regex.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/P5Regex.pir Fri Oct 5 00:07:27 2007
@@ -60,7 +60,7 @@
.sub "__onload" :load
.local pmc optable
- optable = new ['PGE';'OPTable']
+ optable = new 'PGE::OPTable'
set_hll_global ["PGE::P5Regex"], "$optable", optable
$P0 = get_hll_global ["PGE::P5Regex"], "parse_lit"
@@ -127,14 +127,11 @@
.sub "parse_lit"
.param pmc mob
- .local pmc newfrom
.local string target
.local int pos, lastpos
.local int litstart, litlen
.local string initchar
- newfrom = get_hll_global ["PGE";"Match"], "newfrom"
- (mob, target, $P0, $P1) = newfrom(mob, 0, "PGE::Exp::Literal")
- pos = $P0
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
lastpos = length target
initchar = substr target, pos, 1
unless initchar == '*' goto initchar_ok
@@ -175,8 +172,7 @@
mob.'result_object'($S0)
goto end
end:
- $P0 = getattribute mob, ['PGE';'Match'], "$.pos"
- $P0 = pos
+ mob.'to'(pos)
.return (mob)
.end
@@ -185,12 +181,9 @@
.local string target
.local int min, max, backtrack
.local int pos, lastpos
- .local pmc mfrom, mpos
.local string key
key = mob['KEY']
- $P0 = get_hll_global ["PGE";"Match"], "newfrom"
- (mob, target, mfrom, mpos) = $P0(mob, 0, "PGE::Exp::Quant")
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
lastpos = length target
min = 0
max = PGE_INF
@@ -232,7 +225,7 @@
mob["min"] = min
mob["max"] = max
mob["backtrack"] = backtrack
- mpos = pos
+ mob.'to'(pos)
.return (mob)
err_range:
parse_error(mob, pos, "Error in quantified range")
@@ -242,11 +235,8 @@
.sub parse_group
.param pmc mob
.local string target
- .local pmc mfrom, mpos
.local int pos, lastpos
- $P0 = get_hll_global ["PGE";"Match"], "newfrom"
- (mob, target, mfrom, mpos) = $P0(mob, 0, "PGE::Exp::CGroup")
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::CGroup')
inc pos
$S0 = substr target, pos, 2
if $S0 == "?:" goto nocapture
@@ -254,22 +244,19 @@
nocapture:
pos += 2
end:
- mpos = pos
+ mob.'to'(pos)
.return (mob)
.end
.sub "parse_enumclass"
.param pmc mob
.local string target
- .local pmc mfrom, mpos
.local int pos, lastpos
.local int isrange
.local string charlist
.local string key
key = mob['KEY']
- $P0 = get_hll_global ["PGE";"Match"], "newfrom"
- (mob, target, mfrom, mpos) = $P0(mob, 0, "PGE::Exp::EnumCharList")
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::EnumCharList')
if key == '.' goto dot
lastpos = length target
charlist = ""
@@ -325,7 +312,7 @@
charlist = "\n"
mob["isnegated"] = 1
end:
- mpos = pos
+ mob.'to'(pos)
mob.'result_object'(charlist)
.return (mob)
Modified: branches/pdd15oo/compilers/pge/PGE/P6Regex.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/P6Regex.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/P6Regex.pir Fri Oct 5 00:07:27 2007
@@ -80,7 +80,7 @@
## If we're passed the results of a previous parse, use it.
.local pmc match, exp
- $I0 = isa source, ['PGE';'Match']
+ $I0 = isa source, 'PGE::Match'
if $I0 == 0 goto parse
$P0 = source['expr']
if null $P0 goto parse
@@ -91,7 +91,7 @@
parse:
## Let's parse the source as a regex
- $P0 = get_hll_global ['PGE';'Grammar'], 'regex'
+ $P0 = get_hll_global ['PGE::Grammar'], 'regex'
match = $P0(source, adverbs :flat :named)
if source == '' goto err_null
if target != 'parse' goto check
@@ -131,7 +131,7 @@
=cut
-.namespace [ 'PGE';'Grammar' ]
+.namespace [ 'PGE::Grammar' ]
.sub 'regex'
.param pmc mob
@@ -165,7 +165,7 @@
.sub '__onload' :load
.local pmc optable
- optable = new ['PGE';'OPTable']
+ optable = new 'PGE::OPTable'
set_global '$optable', optable
$P0 = get_global 'parse_term'
@@ -330,10 +330,10 @@
$I0 = length initchar
if $I0 < 2 goto term_literal
term_charlist:
- (mob, $P99, $P99, $P0) = mob.newfrom(0, 'PGE::Exp::EnumCharList')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::EnumCharList')
+ mob.'to'(pos)
mob.'result_object'(initchar)
mob['isnegated'] = isnegated
- $P0 = pos
.return (mob)
term_backslash_o:
@@ -396,16 +396,16 @@
$I0 = pos - litstart
$S0 = substr target, litstart, $I0
$S0 = concat initchar, $S0
- (mob, $S99, $P99, $P0) = mob.newfrom(0, 'PGE::Exp::Literal')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
mob.'result_object'($S0)
- $P0 = pos
+ mob.'to'(pos)
.return (mob)
term_ws:
.return 'parse_term_ws'(mob)
end_noterm:
- (mob) = mob.newfrom(0, 'PGE::Exp::Literal')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
.return (mob)
err_backslash_digit:
@@ -426,10 +426,8 @@
.sub 'parse_term_ws'
.param pmc mob
.local string target
- .local pmc mfrom, mpos
.local int pos, lastpos
- (mob, target, mfrom, mpos) = mob.newfrom(0, 'PGE::Exp::WS')
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::WS')
lastpos = length target
term_ws_loop:
@@ -451,7 +449,7 @@
if pos > 0 goto term_ws_loop
pos = lastpos
end:
- mpos = pos
+ mob.'to'(pos)
.return (mob)
.end
@@ -466,15 +464,12 @@
.sub 'parse_quant'
.param pmc mob
.local string target
- .local pmc mfrom, mpos
.local pmc key
.local int pos, lastpos
key = mob['KEY']
- (mob, target, mfrom, mpos) = mob.newfrom(0, 'PGE::Exp::Quant')
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
lastpos = length target
-
.local int min, max, suffixpos
.local string suffix
min = 1
@@ -548,7 +543,7 @@
quant_set:
mob['min'] = min
mob['max'] = max
- mpos = pos
+ mob.'to'(pos)
end:
.return (mob)
@@ -582,9 +577,7 @@
.param pmc mob
.local string target
.local int pos, lastpos
- .local pmc newfrom, mfrom, mpos
.local string cname
- newfrom = get_hll_global ['PGE';'Match'], 'newfrom'
$P0 = getattribute mob, '$.target'
target = $P0
$P0 = getattribute mob, '$.pos'
@@ -598,32 +591,32 @@
if $I0 > pos goto scalar
eos_anchor:
- (mob, $P0, mfrom, mpos) = newfrom(mob, 0, 'PGE::Exp::Anchor')
- mpos = pos
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Anchor')
+ mob.'to'(pos)
.return (mob)
scalar:
- (mob, $P0, mfrom, mpos) = newfrom(mob, 0, 'PGE::Exp::Scalar')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
dec pos
$I1 = $I0 - pos
cname = substr target, pos, $I1
cname = concat '"', cname
cname = concat cname, '"'
mob["cname"] = cname
- mpos = $I0
+ mob.'to'($I0)
.return (mob)
numeric:
- (mob, $P0, mfrom, mpos) = newfrom(mob, 0, 'PGE::Exp::Scalar')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
$I1 = $I0 - pos
cname = substr target, pos, $I1
mob["cname"] = cname
- mpos = $I0
+ mob.'to'($I0)
.return (mob)
name:
inc pos
- (mob, $P0, mfrom, mpos) = newfrom(mob, 0, "PGE::Exp::Scalar")
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
$I0 = index target, ">", pos
if $I0 < pos goto err_close
name_1:
@@ -634,7 +627,7 @@
cname = concat cname, '"'
mob["cname"] = cname
pos = $I0 + 1
- mpos = pos
+ mob.'to'(pos)
.return (mob)
err_close:
@@ -684,13 +677,12 @@
.sub 'parse_subrule'
.param pmc mob
.local string target
- .local pmc mobsave, mfrom, mpos
+ .local pmc mobsave
.local int pos, lastpos
.local string key
key = mob['KEY']
mobsave = mob
- (mob, target, mfrom, mpos) = mob.newfrom(0, 'PGE::Exp::Subrule')
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Subrule')
lastpos = length target
.local string subname
@@ -717,15 +709,15 @@
if $S0 != ' ' goto subrule_end
subrule_pattern_arg:
inc pos
- mpos = pos
+ mob.'to'(pos)
.local pmc regex
- regex = get_hll_global ['PGE';'Grammar'], 'regex'
+ regex = get_hll_global ['PGE::Grammar'], 'regex'
$P1 = regex(mob, 'stop'=>'>')
unless $P1 goto end
$S0 = $P1
mob['arg'] = $S0
pos = $P1.to()
- mpos = -1
+ mob.'to'(-1)
goto subrule_end
subrule_text_arg:
pos += 2
@@ -739,7 +731,7 @@
$S0 = substr target, pos, 1
if $S0 != '>' goto end
inc pos
- mpos = pos
+ mob.'to'(pos)
$I0 = mob['iscapture']
if $I0 == 0 goto end
$S0 = escape subname
@@ -767,7 +759,7 @@
$P0 = getattribute mob, '$.target'
target = $P0
- pos = mob.to()
+ pos = mob.'to'()
lastpos = length target
op = mob['KEY']
@@ -835,7 +827,7 @@
enum_close:
inc pos
## create a node for the charlist
- (term) = mob.'newfrom'(0, 'PGE::Exp::EnumCharList')
+ term = mob.'new'(mob, 'grammar'=>'PGE::Exp::EnumCharList')
term.'to'(pos)
term.'result_object'(charlist)
goto combine
@@ -845,7 +837,7 @@
.local string subname
(subname, pos) = 'parse_subname'(target, $I0)
if pos == $I0 goto err
- (term) = mob.'newfrom'(0, 'PGE::Exp::Subrule')
+ term = mob.'new'(mob, 'grammar'=>'PGE::Exp::Subrule')
term.'from'($I0)
term.'to'(pos)
term['subname'] = subname
@@ -862,10 +854,10 @@
term['iszerowidth'] = 1
if op == '<!' goto combine_init
## token is '<-', we need to match a char by concat dot
- $P0 = mob.'newfrom'(0, 'PGE::Exp::CCShortcut')
+ $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
$P0.'to'(pos)
$P0.'result_object'('.')
- mob = mob.'newfrom'(0, 'PGE::Exp::Concat')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Concat')
mob.'to'(pos)
mob[0] = term
mob[1] = $P0
@@ -877,7 +869,7 @@
combine_plus:
## <a+b> ==> <a> | <b>
- ($P0) = mob.'newfrom'(0, 'PGE::Exp::Alt')
+ $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::Alt')
$P0.'to'(pos)
$P0[0] = mob
$P0[1] = term
@@ -888,7 +880,7 @@
## <a-b> ==> <!b> <a>
term['isnegated'] = 1
term['iszerowidth'] = 1
- ($P0) = mob.'newfrom'(0, 'PGE::Exp::Concat')
+ $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::Concat')
$P0.'to'(pos)
$P0[0] = term
$P0[1] = mob
@@ -930,7 +922,7 @@
.param pmc mob
.local int pos, lastpos
.local string target
- (mob, target, pos) = mob.newfrom(0, 'PGE::Exp::Literal')
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
lastpos = length target
lastpos -= 2
.local string lit
@@ -968,11 +960,9 @@
.param pmc mob
.local int pos, lastpos
.local string target, value
- .local pmc mfrom, mpos
.local string key
key = mob['KEY']
- (mob, target, mfrom, mpos) = mob.newfrom(0, 'PGE::Exp::Modifier')
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Modifier')
lastpos = length target
value = "1"
$I0 = pos
@@ -997,20 +987,16 @@
inc pos
end:
### XXX pos = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
- mpos = pos
+ mob.'to'(pos)
.return (mob)
.end
.sub 'parse_closure'
.param pmc mob
- .local pmc newfrom
.local string target
- .local pmc mfrom, mpos
.local int pos, len
- $P0 = get_hll_global ["PGE";"Match"], "newfrom"
- (mob, target, mfrom, mpos) = $P0(mob, 0, "PGE::Exp::Closure")
- pos = mfrom
+ (mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Closure')
len = 2
init:
$S0 = substr target, pos, 1
@@ -1026,7 +1012,7 @@
$S1 = substr target, pos, $I1
mob.'result_object'($S1)
pos = $I0 + len
- mpos = pos
+ mob.'to'(pos)
.return (mob)
err_noclose:
parse_error(mob, pos, "Missing closing braces for closure")
@@ -1372,12 +1358,12 @@
goto end
add_cgroup:
- .local pmc cexp, mfrom, mpos
- (cexp, $P99, mfrom, mpos) = self.newfrom(0, 'PGE::Exp::CGroup')
+ .local pmc cexp
+ cexp = self.'new'(self, 'grammar'=>'PGE::Exp::CGroup')
$I0 = self.from()
- mfrom = $I0
+ cexp.'from'($I0)
$I0 = self.to()
- mpos = $I0
+ cexp.'to'($I0)
cexp[0] = exp1
cexp['isscope'] = 0
cexp['iscapture'] = 1
Modified: branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Perl6Regex.pir Fri Oct 5 00:07:27 2007
@@ -18,7 +18,7 @@
=cut
-.namespace ['PGE';'Perl6Regex']
+.namespace [ 'PGE::Perl6Regex' ]
.sub 'compile_perl6regex'
.param pmc source
@@ -80,11 +80,11 @@
## If we're passed the results of a previous parse, use it.
.local pmc match, exp
- $I0 = isa source, ['PGE';'Match']
+ $I0 = isa source, 'PGE::Match'
if $I0 == 0 goto parse
$P0 = source['expr']
if null $P0 goto parse
- $I0 = isa $P0, ['PGE';'Exp']
+ $I0 = isa $P0, 'PGE::Exp'
if $I0 == 0 goto parse
match = source
goto analyze
@@ -156,98 +156,100 @@
.include 'cclass.pasm'
+.namespace [ 'PGE::Perl6Regex' ]
+
.sub '__onload' :load
.local pmc optable
- $P0 = subclass ['PGE';'Exp';'Subrule'], ['PGE';'Exp';'WS']
- $P0 = subclass ['PGE';'Exp'], ['PGE';'Exp';'Alias']
+ $P0 = subclass 'PGE::Exp::Subrule', 'PGE::Exp::WS'
+ $P0 = subclass 'PGE::Exp', 'PGE::Exp::Alias'
- optable = new ['PGE';'OPTable']
+ optable = new 'PGE::OPTable'
set_global '$optable', optable
$P0 = get_global 'parse_term'
- optable.'newtok'('term:', 'precedence'=>'=', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:', 'precedence'=>'=', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_term_ws'
- optable.'newtok'('term:#', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:#', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_term_backslash'
- optable.'newtok'("term:\\", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok("term:\\", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:^', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:^^', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:$$', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:\b', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:\B', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:<<', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'('term:>>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'(unicode:"term:\xab", 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
- optable.'newtok'(unicode:"term:\xbb", 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
-
- optable.'newtok'('term:.', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\d', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\D', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\s', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\S', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\w', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\W', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\N', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
- optable.'newtok'('term:\n', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Newline')
+ optable.newtok('term:^', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:^^', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:$$', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:\b', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:\B', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:<<', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok('term:>>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok(unicode:"term:\xab", 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+ optable.newtok(unicode:"term:\xbb", 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Anchor')
+
+ optable.newtok('term:.', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\d', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\D', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\s', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\S', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\w', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\W', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\N', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CCShortcut')
+ optable.newtok('term:\n', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Newline')
$P0 = get_global 'parse_dollar'
- optable.'newtok'('term:$', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:$', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_subrule'
- optable.'newtok'('term:<', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:<?', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:<!', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<?', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<!', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_enumcharclass'
- optable.'newtok'('term:<[', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:<+', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:<-', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:<![', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<[', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<+', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<-', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('term:<![', 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_quoted_literal'
- optable.'newtok'("term:'", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok("term:'", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('term:::', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
- optable.'newtok'('term::::', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
- optable.'newtok'('term:<cut>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
- optable.'newtok'('term:<commit>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
+ optable.newtok('term:::', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
+ optable.newtok('term::::', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
+ optable.newtok('term:<cut>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
+ optable.newtok('term:<commit>', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Cut')
$P0 = get_global 'parse_closure'
- optable.'newtok'("term:{{", 'equiv'=>'term:', 'nows'=>1,
'parsed'=>$P0)
+ optable.newtok("term:{{", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
$P0 = get_global 'parse_action'
- optable.'newtok'("term:{*}", 'equiv'=>'term:', 'nows'=>1,
'parsed'=>$P0)
+ optable.newtok("term:{*}", 'equiv'=>'term:', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('circumfix:[ ]', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Group')
- optable.'newtok'('circumfix:( )', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CGroup')
+ optable.newtok('circumfix:[ ]', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::Group')
+ optable.newtok('circumfix:( )', 'equiv'=>'term:', 'nows'=>1,
'match'=>'PGE::Exp::CGroup')
$P0 = get_global 'parse_quant'
- optable.'newtok'('postfix:*', 'looser'=>'term:', 'parsed'=>$P0)
- optable.'newtok'('postfix:+', 'equiv'=>'postfix:*', 'parsed'=>$P0)
- optable.'newtok'('postfix:?', 'equiv'=>'postfix:*', 'parsed'=>$P0)
- optable.'newtok'('postfix::', 'equiv'=>'postfix:*', 'parsed'=>$P0)
- optable.'newtok'('postfix:**', 'equiv'=>'postfix:*', 'parsed'=>$P0)
+ optable.newtok('postfix:*', 'looser'=>'term:', 'parsed'=>$P0)
+ optable.newtok('postfix:+', 'equiv'=>'postfix:*', 'parsed'=>$P0)
+ optable.newtok('postfix:?', 'equiv'=>'postfix:*', 'parsed'=>$P0)
+ optable.newtok('postfix::', 'equiv'=>'postfix:*', 'parsed'=>$P0)
+ optable.newtok('postfix:**', 'equiv'=>'postfix:*', 'parsed'=>$P0)
$P0 = get_global 'parse_quant_error'
- optable.'newtok'('term:*', 'equiv'=>'term:', 'parsed'=>$P0)
- optable.'newtok'('term:+', 'equiv'=>'term:', 'parsed'=>$P0)
- optable.'newtok'('term:?', 'equiv'=>'term:', 'parsed'=>$P0)
-
- optable.'newtok'('infix:', 'looser'=>'postfix:*', 'assoc'=>'list',
'nows'=>1, 'match'=>'PGE::Exp::Concat')
- optable.'newtok'('infix:&', 'looser'=>'infix:', 'nows'=>1,
'match'=>'PGE::Exp::Conj')
- optable.'newtok'('infix:|', 'looser'=>'infix:&', 'nows'=>1,
'match'=>'PGE::Exp::Alt')
- optable.'newtok'('prefix:|', 'equiv'=>'infix:|', 'nows'=>1,
'match'=>'PGE::Exp::Alt')
+ optable.newtok('term:*', 'equiv'=>'term:', 'parsed'=>$P0)
+ optable.newtok('term:+', 'equiv'=>'term:', 'parsed'=>$P0)
+ optable.newtok('term:?', 'equiv'=>'term:', 'parsed'=>$P0)
+
+ optable.newtok('infix:', 'looser'=>'postfix:*', 'assoc'=>'list',
'nows'=>1, 'match'=>'PGE::Exp::Concat')
+ optable.newtok('infix:&', 'looser'=>'infix:', 'nows'=>1,
'match'=>'PGE::Exp::Conj')
+ optable.newtok('infix:|', 'looser'=>'infix:&', 'nows'=>1,
'match'=>'PGE::Exp::Alt')
+ optable.newtok('prefix:|', 'equiv'=>'infix:|', 'nows'=>1,
'match'=>'PGE::Exp::Alt')
- optable.'newtok'('infix::=', 'tighter'=>'infix:', 'assoc'=>'right',
'match'=>'PGE::Exp::Alias')
+ optable.newtok('infix::=', 'tighter'=>'infix:', 'assoc'=>'right',
'match'=>'PGE::Exp::Alias')
$P0 = get_global 'parse_modifier'
- optable.'newtok'('prefix::', 'looser'=>'infix:|', 'nows'=>1, 'parsed'=>$P0)
+ optable.newtok('prefix::', 'looser'=>'infix:|', 'nows'=>1, 'parsed'=>$P0)
- optable.'newtok'('close:}', 'precedence'=>'<', 'nows'=>1)
+ optable.newtok('close:}', 'precedence'=>'<', 'nows'=>1)
.local pmc esclist
esclist = new 'Hash'
@@ -263,13 +265,13 @@
# Create and store closure preprocessors in %closure_pp
$P0 = new 'Hash'
- set_global '%closure_pp', $P0
- $P1 = get_global 'PIR_closure'
- $P0['PIR'] = $P1
+ set_hll_global ['PGE::Perl6Regex'], '%closure_pp', $P0
+ $P1 = get_hll_global ['PGE::Perl6Regex'], 'PIR_closure'
+ $P0["PIR"] = $P1
# Create an array for holding stop tokens
$P0 = new 'ResizablePMCArray'
- set_global '@!stopstack', $P0
+ set_hll_global ['PGE::Perl6Regex'], '@!stopstack', $P0
$P0 = get_global 'compile_perl6regex'
compreg 'PGE::Perl6Regex', $P0
@@ -297,7 +299,7 @@
lastpos = length target
.local string stop
- $P0 = get_global '@!stopstack'
+ $P0 = get_hll_global ['PGE::Perl6Regex'], '@!stopstack'
stop = $P0[-1]
$I0 = is_cclass .CCLASS_WHITESPACE, target, pos
@@ -331,7 +333,7 @@
.return 'parse_term_ws'(mob)
end_noterm:
- mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
+ (mob) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
.return (mob)
.end
@@ -492,7 +494,6 @@
(mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
lastpos = length target
-
.local int min, max, suffixpos
.local string suffix
min = 1
@@ -614,12 +615,12 @@
if $I0 > pos goto scalar
eos_anchor:
- mob = mob.'new'(mob, 'grammar' => 'PGE::Exp::Anchor')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Anchor')
mob.'to'(pos)
.return (mob)
scalar:
- mob = mob.'new'(mob, 'grammar' => 'PGE::Exp::Scalar')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
dec pos
$I1 = $I0 - pos
cname = substr target, pos, $I1
@@ -630,7 +631,7 @@
.return (mob)
numeric:
- mob = mob.'new'(mob, 'grammar' => 'PGE::Exp::Scalar')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
$I1 = $I0 - pos
cname = substr target, pos, $I1
mob["cname"] = cname
@@ -639,7 +640,7 @@
name:
inc pos
- mob = mob.'new'(mob, 'grammar' => 'PGE::Exp::Scalar')
+ mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Scalar')
$I0 = index target, ">", pos
if $I0 < pos goto err_close
name_1:
@@ -1099,7 +1100,7 @@
-.namespace ['PGE';'Exp']
+.namespace [ 'PGE::Exp' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1107,7 +1108,7 @@
.end
-.namespace ['PGE';'Exp';'Literal']
+.namespace [ 'PGE::Exp::Literal' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1117,7 +1118,7 @@
.end
-.namespace ['PGE';'Exp';'Concat']
+.namespace [ 'PGE::Exp::Concat' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1147,7 +1148,7 @@
.end
-.namespace ['PGE';'Exp';'Quant']
+.namespace [ 'PGE::Exp::Quant' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1173,7 +1174,7 @@
.end
-.namespace ['PGE';'Exp';'Group']
+.namespace [ 'PGE::Exp::Group' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1195,7 +1196,7 @@
.end
-.namespace ['PGE';'Exp';'CGroup']
+.namespace [ 'PGE::Exp::CGroup' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1274,7 +1275,7 @@
.end
-.namespace ['PGE';'Exp';'Subrule']
+.namespace [ 'PGE::Exp::Subrule' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1315,7 +1316,7 @@
.end
-.namespace ['PGE';'Exp';'WS']
+.namespace [ 'PGE::Exp::WS' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1331,7 +1332,7 @@
.end
-.namespace ['PGE';'Exp';'Alt']
+.namespace [ 'PGE::Exp::Alt' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1349,7 +1350,7 @@
## if lhs is whitespace, then this is a prefix-alt and
## we ignore it (by simply returning its rhs)
- $I0 = isa exp0, ['PGE';'Exp';'WS']
+ $I0 = isa exp0, 'PGE::Exp::WS'
if $I0 == 0 goto with_lhs
.return exp1.'perl6exp'(pad)
with_lhs:
@@ -1382,7 +1383,7 @@
.end
-.namespace ['PGE';'Exp';'Alias']
+.namespace [ 'PGE::Exp::Alias' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1398,14 +1399,14 @@
## Otherwise, we need to create a capture group for this
## alias and return that.
- $I0 = isa exp1, ['PGE';'Exp';'CGroup']
+ $I0 = isa exp1, 'PGE::Exp::CGroup'
if $I0 == 1 goto make_alias
- $I0 = isa exp1, ['PGE';'Exp';'Subrule']
+ $I0 = isa exp1, 'PGE::Exp::Subrule'
if $I0 == 1 goto make_alias
- $I0 = isa exp1, ['PGE';'Exp';'Quant']
+ $I0 = isa exp1, 'PGE::Exp::Quant'
if $I0 == 0 goto add_cgroup
$P0 = exp1[0]
- $I0 = isa $P0, ['PGE';'Exp';'CGroup']
+ $I0 = isa $P0, 'PGE::Exp::CGroup'
if $I0 == 0 goto add_cgroup
$P0['cname'] = cname
goto end
@@ -1433,7 +1434,7 @@
.end
-.namespace ['PGE';'Exp';'Modifier']
+.namespace [ 'PGE::Exp::Modifier' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1462,7 +1463,7 @@
.return (exp)
.end
-.namespace ['PGE';'Exp';'Conj']
+.namespace [ 'PGE::Exp::Conj' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1476,7 +1477,7 @@
.end
-.namespace ['PGE';'Exp';'Closure']
+.namespace [ 'PGE::Exp::Closure' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1486,7 +1487,7 @@
lang = pad['lang']
self['lang'] = lang
# see if we need to do any pre-processing of the closure
- closure_pp = get_hll_global ['PGE';'Perl6Regex'], '%closure_pp'
+ closure_pp = get_hll_global ['PGE::Perl6Regex'], '%closure_pp'
$I0 = defined closure_pp[lang]
if $I0 == 0 goto end
closure_fn = closure_pp[lang]
@@ -1512,7 +1513,7 @@
=back
=cut
-.namespace ['PGE';'Perl6Regex']
+.namespace [ 'PGE::Perl6Regex' ]
.sub 'PIR_closure'
.param string code
@@ -1525,7 +1526,7 @@
.end
-.namespace ['PGE';'Exp';'Action']
+.namespace [ 'PGE::Exp::Action' ]
.sub 'perl6exp' :method
.param pmc pad
@@ -1535,7 +1536,7 @@
.end
-.namespace ['PGE';'Exp';'Cut']
+.namespace [ 'PGE::Exp::Cut' ]
.sub 'perl6exp' :method
.param pmc pad
Modified: branches/pdd15oo/compilers/pge/PGE/Regex.pir
==============================================================================
--- branches/pdd15oo/compilers/pge/PGE/Regex.pir (original)
+++ branches/pdd15oo/compilers/pge/PGE/Regex.pir Fri Oct 5 00:07:27 2007
@@ -9,14 +9,14 @@
=cut
-.namespace ['PGE';'Match']
+.namespace [ 'PGE::Match' ]
.include 'cclass.pasm'
.include 'interpinfo.pasm'
.sub '__onload' :load
.local pmc base
- $P0 = subclass ['PGE';'Match'] , ['PGE';'Grammar']
+ $P0 = subclass 'PGE::Match', 'PGE::Grammar'
$P0 = new 'Hash'
set_global '%!cache', $P0
.return ()
@@ -37,6 +37,7 @@
.param pmc mob
.param pmc adverbs :slurpy :named
.local string target
+ .local pmc mfrom, mpos
.local int pos, lastpos
$P0 = get_hll_global ['PGE'], 'Match'
Modified: branches/pdd15oo/config/gen/makefiles/pge.in
==============================================================================
--- branches/pdd15oo/config/gen/makefiles/pge.in (original)
+++ branches/pdd15oo/config/gen/makefiles/pge.in Fri Oct 5 00:07:27 2007
@@ -12,7 +12,7 @@
PARROT_LIBRARY = ../../runtime/parrot/library
# the default target
-all: $(PARROT_LIBRARY)/PGE.pbc
+all: $(PARROT_LIBRARY)/PGE.pbc
SOURCES = PGE.pir \
PGE/Exp.pir \
@@ -22,7 +22,8 @@
PGE/Perl6Regex.pir \
PGE/OPTable.pir \
PGE/P5Regex.pir \
- $(PARROT_LIBRARY)/PGE/Perl6Grammar.pir \
+ PGE/builtins.pg \
+ pgc.pir \
$(PARROT_LIBRARY)/PGE.pbc: PGE.pbc
$(CP) PGE.pbc $(PARROT_LIBRARY)
@@ -31,6 +32,8 @@
$(RM_RF) PGE.pbc $(PARROT_LIBRARY)/PGE.pbc
$(PERL) -e "" >PGE/builtins_gen.pir
$(PARROT) -o PGE.pbc --output-pbc PGE.pir
+ $(PARROT) $(PARROT_LIBRARY)/PGE/Perl6Grammar.pir
--output=PGE/builtins_gen.pir PGE/builtins.pg
+ $(PARROT) -o PGE.pbc --output-pbc PGE.pir
# This is a listing of all targets, that are meant to be called by users
help:
@@ -67,7 +70,7 @@
$(RM_RF) \
PGE.pbc \
$(PARROT_LIBRARY)/PGE.pbc \
- PGE/builtins_gen.pir \
+ PGE/builtins_gen.pir
realclean: clean
$(RM_RF) Makefile
Modified: branches/pdd15oo/runtime/parrot/library/PGE/Text.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/PGE/Text.pir (original)
+++ branches/pdd15oo/runtime/parrot/library/PGE/Text.pir Fri Oct 5
00:07:27 2007
@@ -16,7 +16,7 @@
.sub "__onload" :load
.local pmc base
- $P0 = subclass ['PGE';'Grammar'], 'PGE::Text'
+ $P0 = subclass 'PGE::Grammar', 'PGE::Text'
.end
=head2 Available rules
Modified: branches/pdd15oo/runtime/parrot/library/PGE/Util.pir
==============================================================================
--- branches/pdd15oo/runtime/parrot/library/PGE/Util.pir (original)
+++ branches/pdd15oo/runtime/parrot/library/PGE/Util.pir Fri Oct 5
00:07:27 2007
@@ -17,7 +17,7 @@
.sub "__onload" :load
.local pmc base
- $P0 = subclass ['PGE';'Grammar'], 'PGE::Util'
+ $P0 = subclass 'PGE::Grammar', 'PGE::Util'
.return ()
.end
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 Fri Oct 5 00:07:27 2007
@@ -27,7 +27,7 @@
.sub main :main
load_bytecode 'PGE.pbc'
- $P0 = compreg 'PGE::Perl6Regex'
+ $P0 = compreg 'PGE::P6Regex'
$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 Fri Oct 5 00:07:27 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 = get_global ['PGE';'Match'], 'ident'
+ ident = find_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 Fri Oct 5 00:07:27 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