Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

a couple of smallish fixes

- the 'tighter' option only holds at circumnest level 0
- the backtrack should default to GREEDY in getargs
  • Loading branch information...
commit b47a964826eb7360bc6c336d529e41ed2617aa7e 1 parent dd87949
Carl Mäsak authored January 28, 2010
15  lib/GGE/Exp.pm
@@ -38,6 +38,12 @@ enum CUT (
38 38
     CUT_MATCH => -3,
39 39
 );
40 40
 
  41
+enum GGE_BACKTRACK <
  42
+    GREEDY
  43
+    EAGER
  44
+    NONE
  45
+>;
  46
+
41 47
 class GGE::Exp is GGE::Match {
42 48
     my $group;
43 49
 
@@ -142,6 +148,7 @@ class GGE::Exp is GGE::Match {
142 148
         }
143 149
     }
144 150
 } ]]);
  151
+        ~$code;
145 152
     }
146 153
 
147 154
     method getargs($label, $next, %hash?) {
@@ -152,7 +159,7 @@ class GGE::Exp is GGE::Match {
152 159
             %hash<M> = %hash<m> == 0   ?? '### ' !! '';
153 160
             %hash<n> = $quant.hash-access('max');
154 161
             %hash<N> = %hash<n> == Inf ?? '### ' !! '';
155  
-            my $bt = $quant.hash-access('backtrack').name.lc;
  162
+            my $bt = ($quant.hash-access('backtrack') // GREEDY).name.lc;
156 163
             %hash<Q> = sprintf '%s..%s (%s)', %hash<m>, %hash<n>, $bt;
157 164
         }
158 165
         return %hash;
@@ -222,12 +229,6 @@ class GGE::Exp::Literal is GGE::Exp does GGE::ShowContents {
222 229
     }
223 230
 }
224 231
 
225  
-enum GGE_BACKTRACK <
226  
-    GREEDY
227  
-    EAGER
228  
-    NONE
229  
->;
230  
-
231 232
 class GGE::Exp::Quant is GGE::Exp {
232 233
     method contents() {
233 234
         my ($min, $max, $bt) = map { self.hash-access($_) },
2  lib/GGE/OPTable.pm
@@ -184,7 +184,7 @@ class GGE::OPTable {
184 184
                 for (%!keys{$key} // []).list -> $token {
185 185
                     next unless $expect +& $token<expect>;
186 186
                     next if $token<nows> && $nows;
187  
-                    if $tighter
  187
+                    if $circumnest == 0 && $tighter
188 188
                        && $token<precedence> ~ '=' x 100
189 189
                           le $tighter ~ '=' x 100 {
190 190
                         $key = '';

0 notes on commit b47a964

Please sign in to comment.
Something went wrong with that request. Please try again.