Skip to content
Browse files

Python backend - fixed .perl()

  • Loading branch information...
1 parent fabc66f commit a044b5cacd2b95beb7a4b97a0e8a518be433b32b @fglock committed Apr 7, 2011
Showing with 28 additions and 10 deletions.
  1. +4 −3 lib/Perlito/Python/Runtime.py
  2. +24 −7 t-backend-specific/15-grammar-quantifier.t
View
7 lib/Perlito/Python/Runtime.py
@@ -527,16 +527,17 @@ def _dump(o, seen):
out = [];
for i in o.__dict__.keys():
out.append(i[2:] + " => " + mp6_perl(o.__dict__[i]))
- name = o.__class__.__name__.replace( "__", "::");
- return name + ".new(" + ", ".join(out) + ")";
+ name = o.__class__.__name__.replace( "__", "::")
+ return name + ".new(" + ", ".join(out) + ")"
def mp6_id(o):
try:
return o.f_id()
except AttributeError:
return id(o)
-def mp6_perl(o, seen={}):
+def mp6_perl(o, last_seen={}):
+ seen = last_seen.copy()
try:
return o.f_perl()
except AttributeError:
View
31 t-backend-specific/15-grammar-quantifier.t
@@ -15,13 +15,30 @@ class Main {
}
say '1..1';
- my $m = Main.digits( '123abc', 0);
- say '# from: ', $m.from;
- say '# to: ', $m.to;
- say '# match: ', $m.perl;
- if $m.to != 3 {
- print "not ";
+
+ {
+ my $m = Main.digits( '123abc', 0);
+ say '# from: ', $m.from;
+ say '# to: ', $m.to;
+ say '# match: ', $m.perl;
+ say '# capture: ', ($$m).perl;
+ if $m.to != 3 {
+ print "not ";
+ }
+ say 'ok 1';
+ }
+
+ {
+ my $m = Main.digits( 'abc', 0);
+ say '# from: ', $m.from;
+ say '# to: ', $m.to;
+ say '# match: ', $m.perl;
+ say '# capture: ', ($$m).perl;
+ if $m.to != 0 {
+ print "not ";
+ }
+ say 'ok 2';
}
- say 'ok 1';
+
}

0 comments on commit a044b5c

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