# New Ticket Created by  Klaas-Jan Stol 
# Please include the string:  [perl #41665]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41665 >


hi,

attached a patch fixing the "not" operator and "and". for pynie.

regards.
kjs
Index: languages/pynie/src/PAST/Grammar.tg
===================================================================
--- languages/pynie/src/PAST/Grammar.tg	(revision 17281)
+++ languages/pynie/src/PAST/Grammar.tg	(working copy)
@@ -203,6 +203,7 @@
 
 
 transform past (Pynie::Grammar::expression) :language('PIR') {
+    $S0 = node.'find_key'()
     $P0 = node['or_test']
     $P0 = $P0[0] # this is a hack, 'rule expression' has 1 or more <or_test>s, so it stores them in an array. Handle $P0[1] later.
     #printerr "pynie::grammar::expression\n"
@@ -226,16 +227,39 @@
 }
 
 transform past (Pynie::Grammar::and_test) :language('PIR') {
-    $P0 = node['not_test']
-    $P0 = $P0[0] # this is a hack, 'rule expression' has 1 or more <or_test>s, so it stores them in an array. Handle $P0[1] later.
-    #printerr "pynie::grammar::and_test\n"
-    .return tree.'get'('past', $P0, 'Pynie::Grammar::not_test')
+  .local pmc past, iter, clist, cnode
+    clist = node['not_test']
+    clist = clone clist
+    cnode = pop clist
+    past = tree.'get'('past', cnode, 'Pynie::Grammar::not_test')
+    unless clist goto end
+  clist_loop:
+    cnode = pop clist
+    $P0 = tree.'get'('past', cnode, 'Pynie::Grammar::not_test')
+    past = past.'new'('PAST::Op', $P0, past, 'node'=>node, 'pasttype'=>'if')
+    if clist goto clist_loop
+  end:
+    .return (past)
 }
 
 transform past (Pynie::Grammar::not_test) :language('PIR') {
-    $P0 = node['not_in_test']
-    #printerr "pynie::grammar::not_test\n"
-    .return tree.'get'('past', $P0, 'Pynie::Grammar::not_in_test')
+    .local string key, fullkey
+    .local pmc cnode, past, notpast
+
+    cnode = node['not_test']
+    if null cnode goto do_in_test
+    notpast = tree.'get'('past', cnode, 'Pynie::Grammar::not_test')
+
+    past = new 'PAST::Op'
+    past.'init'('node'=>cnode, 'pasttype'=>'pirop', 'pirop'=>'not')
+    past.'push'(notpast)
+
+    .return (past)
+
+  do_in_test:
+    cnode = node['not_in_test']
+    past = tree.'get'('past', cnode, 'Pynie::Grammar::not_in_test')
+    .return (past)
 }
 
 transform past (Pynie::Grammar::not_in_test) :language('PIR') {

Reply via email to