Author: pmichaud
Date: Thu Oct  4 23:13:53 2007
New Revision: 21870

Modified:
   trunk/compilers/pge/PGE/P5Regex.pir
   trunk/compilers/pge/PGE/P6Regex.pir

Log:
[pge]:
* Convert 'newfrom' to 'new' in P5Regex and P6Regex.


Modified: trunk/compilers/pge/PGE/P5Regex.pir
==============================================================================
--- trunk/compilers/pge/PGE/P5Regex.pir (original)
+++ trunk/compilers/pge/PGE/P5Regex.pir Thu Oct  4 23:13:53 2007
@@ -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\x0$.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: trunk/compilers/pge/PGE/P6Regex.pir
==============================================================================
--- trunk/compilers/pge/PGE/P6Regex.pir (original)
+++ trunk/compilers/pge/PGE/P6Regex.pir Thu Oct  4 23:13:53 2007
@@ -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,7 +709,7 @@
     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'
     $P1 = regex(mob, 'stop'=>'>')
@@ -725,7 +717,7 @@
     $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

Reply via email to