Author: pmichaud
Date: Thu Oct 27 14:09:36 2005
New Revision: 9601

Modified:
   trunk/compilers/pge/PGE/Exp.pir
Log:
Fixed bug with ^^ and $$ at end of string.
Thanks to particle for tests that exposed the bug.


Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir     (original)
+++ trunk/compilers/pge/PGE/Exp.pir     Thu Oct 27 14:09:36 2005
@@ -834,19 +834,28 @@ register.
     token = self["token"]
     if token == "\\b" goto word
     if token == "\\B" goto word
-    if token == '$$' goto eos
+    if token == '$$' goto eol
     if token == '$' goto eos
+  bos:
     emit(code, "    if pos == 0 goto %s", next)
     unless token == '^^' goto end
+  bol:
+    emit(code, "    if pos == lastpos goto fail")
     emit(code, "    $I0 = pos - 1")
     emit(code, "    $I1 = is_cclass .CCLASS_NEWLINE, target, $I0")
     emit(code, "    if $I1 goto %s", next)
     goto end
+  eol:
+    emit(code, "    $I1 = is_cclass .CCLASS_NEWLINE, target, pos")
+    emit(code, "    if $I1 goto %s", next)
+    emit(code, "    if pos != lastpos goto fail")
+    emit(code, "    if pos < 1 goto %s", next)
+    emit(code, "    $I0 = pos - 1")
+    emit(code, "    $I1 = is_cclass .CCLASS_NEWLINE, target, $I0")
+    emit(code, "    if $I1 == 0 goto %s", next)
+    goto end
   eos:
     emit(code, "    if pos == lastpos goto %s", next)
-    unless token == '$$' goto end
-    emit(code, "    $I0 = is_cclass .CCLASS_NEWLINE, target, pos")
-    emit(code, "    if $I0 goto %s", next)
     goto end
   word:
     emit(code, "    $I0 = 0")

Reply via email to