Author: pmichaud
Date: Tue May  3 15:26:44 2005
New Revision: 7966

Modified:
   trunk/compilers/pge/PGE.pir
   trunk/compilers/pge/PGE/Exp.pir
   trunk/compilers/pge/PGE/Match.pir
   trunk/compilers/pge/PGE/P6Rule.pir
   trunk/compilers/pge/PGE/TokenHash.pir
   trunk/lib/Parrot/Test/PGE.pm
Log:
Fixed test harness a bit, revised pir code to only have one @LOAD
subroutine in the .pbc/.pir files.


Modified: trunk/compilers/pge/PGE.pir
==============================================================================
--- trunk/compilers/pge/PGE.pir (original)
+++ trunk/compilers/pge/PGE.pir Tue May  3 15:26:44 2005
@@ -2,12 +2,32 @@
 
 PGE - the Parrot/Perl Grammar Engine
 
+=head2 Description
+
+This is the base file for the grammar engine.  It basically combines
+(via .include) each of the separate PGE modules into a single compilation
+unit, and then calls the "__onload" subroutines for each.  We do
+this because as of this writing (2005-May-03) the semantics of
+multiple @LOAD pragmas in a single compilation unit aren't well
+defined.
+
 =cut
 
 .namespace [ "PGE" ]
 
+.sub "__onload" @LOAD
+    .local pmc load
+    load = find_global "PGE::TokenHash", "__onload"
+    load()
+    load = find_global "PGE::Exp", "__onload"
+    load()
+    load = find_global "PGE::Match", "__onload"
+    load()
+    load = find_global "PGE::P6Rule", "__onload"
+    load()
+.end
+
 .include "PGE/TokenHash.pir"
 .include "PGE/Exp.pir"
 .include "PGE/Match.pir"
 .include "PGE/P6Rule.pir"
-

Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir     (original)
+++ trunk/compilers/pge/PGE/Exp.pir     Tue May  3 15:26:44 2005
@@ -28,7 +28,7 @@
 
 .const int PGE_INF = 2147483647                    # XXX: arbitrary limit
 
-.sub __onload @LOAD
+.sub __onload 
     .local pmc hashclass
     .local pmc expclass
     .local pmc hash
@@ -498,14 +498,13 @@
     if token == '$' goto eos
     emit(code, "if pos == 0 goto %s", next)
     unless token == '^^' goto end
-    emit(code, "$I0 = is_newline target, pos")
+    emit(code, "$I0 = pos - 1")
+    emit(code, "$I0 = is_newline target, $I0")
     emit(code, "if $I0 goto %s", next)
     goto end
   eos:
     emit(code, "if pos == lastpos goto %s", next)
     unless token == '$$' goto end
-    emit(code, "if pos == 0 goto fail")
-    emit(code, "$I0 = pos - 1")
     emit(code, "$I0 = is_newline target, $I0")
     emit(code, "if $I0 goto %s", next)
   end:

Modified: trunk/compilers/pge/PGE/Match.pir
==============================================================================
--- trunk/compilers/pge/PGE/Match.pir   (original)
+++ trunk/compilers/pge/PGE/Match.pir   Tue May  3 15:26:44 2005
@@ -10,7 +10,7 @@
 
 .namespace [ "PGE::Match" ]
 
-.sub "__onload" @LOAD
+.sub "__onload" 
     .local pmc base
     newclass base, "PGE::Match"
     addattribute base, "$:target"                  # target

Modified: trunk/compilers/pge/PGE/P6Rule.pir
==============================================================================
--- trunk/compilers/pge/PGE/P6Rule.pir  (original)
+++ trunk/compilers/pge/PGE/P6Rule.pir  Tue May  3 15:26:44 2005
@@ -18,41 +18,41 @@
 
 =cut
 
-.namespace [ "PGE" ]
+.namespace [ "PGE::P6Rule" ]
 
 .const int PGE_INF    = 2147483647                # XXX: arbitrary limit
 
-.sub __onload @LOAD
+.sub "__onload"
     .local pmc p6meta
     .local pmc u
 
     u = new Undef
     $I0 = find_type "PGE::TokenHash"
     p6meta = new $I0
-    store_global "PGE", "%_p6meta", p6meta
+    store_global "PGE::P6Rule", "%_p6meta", p6meta
     p6meta['*'] = u
     p6meta['+'] = u
     p6meta['?'] = u
     p6meta[':'] = u
     p6meta['|'] = u
-    $P0 = find_global "PGE", "p6rule_parse_literal"
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_literal"
     p6meta['']  = $P0
-    $P0 = find_global "PGE", "p6rule_parse_dot"
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_dot"
     p6meta['.'] = $P0
-    $P0 = find_global "PGE", "p6rule_parse_anchor"
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_anchor"
     p6meta['^'] = $P0
     p6meta['^^'] = $P0
     p6meta['$'] = $P0
     p6meta['$$'] = $P0
-    $P0 = find_global "PGE", "p6rule_parse_group"
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_group"
     p6meta['['] = $P0
     p6meta[']'] = u
     p6meta['('] = $P0
     p6meta[')'] = u
-    # $P0 = find_global "PGE", "p6rule_parse_assert"      # XXX: TODO
+    # $P0 = find_global "PGE::P6Rule", "p6rule_parse_assert"      # XXX: TODO
     # p6meta['<'] = $P0
     # p6meta['>'] = u
-    $P0 = find_global "PGE", "p6rule_parse_charclass"
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_charclass"
     p6meta['\d'] = $P0
     p6meta['\D'] = $P0
     p6meta['\w'] = $P0
@@ -140,7 +140,7 @@
     .local int pos                         # current position
     .local pmc exp
 
-    p6meta = find_global "PGE", "%_p6meta"
+    p6meta = find_global "PGE::P6Rule", "%_p6meta"
     lit = ''
 
   literal:
@@ -340,7 +340,7 @@
     p6rule_parse_skip(pattern, lex, 0)             # skip to next token
     pos = lex["pos"]
 
-    p6meta = find_global "PGE", "%_p6meta"
+    p6meta = find_global "PGE::P6Rule", "%_p6meta"
     c = p6meta."lkey"(pattern, pos)
     $P0 = p6meta[c]
     (exp) = $P0(pattern, lex, c)
@@ -559,6 +559,8 @@
 
 =cut
 
+.namespace [ "PGE" ]
+
 .sub "p6rule"
     .param string pattern
     .local pmc lex
@@ -571,7 +573,8 @@
     lex["subp"] = 0
     $I0 = length pattern
     lex["plen"] = $I0
-    (exp) = "p6rule_parse_exp"(pattern, lex)
+    $P0 = find_global "PGE::P6Rule", "p6rule_parse_exp"
+    (exp) = $P0(pattern, lex)
 
     $P1 = find_global "PGE::Exp", "new"
     $P2 = $P1("PGE::Exp::End")

Modified: trunk/compilers/pge/PGE/TokenHash.pir
==============================================================================
--- trunk/compilers/pge/PGE/TokenHash.pir       (original)
+++ trunk/compilers/pge/PGE/TokenHash.pir       Tue May  3 15:26:44 2005
@@ -6,7 +6,7 @@
 
 .namespace [ "PGE::TokenHash" ]
 
-.sub "__onload" @LOAD
+.sub "__onload" 
     .local pmc class
     class = newclass "PGE::TokenHash"
     addattribute class, ".ihash"

Modified: trunk/lib/Parrot/Test/PGE.pm
==============================================================================
--- trunk/lib/Parrot/Test/PGE.pm        (original)
+++ trunk/lib/Parrot/Test/PGE.pm        Tue May  3 15:26:44 2005
@@ -102,7 +102,7 @@
     return qq(
         .sub _PGE_Test
             .local pmc p6rule_compile
-            load_bytecode "runtime/parrot/library/PGE.pir"
+            load_bytecode "runtime/parrot/library/PGE.pbc"
             find_global p6rule_compile, "PGE", "p6rule"
 
             .local string target

Reply via email to