Commits

Anonymous committed 2c73989

succesfully generate unless

Comments (0)

Files changed (6)

src/gen_actions.pir

 
 .namespace ["z2";"Grammar";"Actions"]
 .sub "_block13" :init :load :subid("32")
-    .const 'Sub' $P273 = "30" 
-    capture_lex $P273
-    .const 'Sub' $P256 = "29" 
-    capture_lex $P256
-    .const 'Sub' $P244 = "28" 
-    capture_lex $P244
+    .const 'Sub' $P280 = "30" 
+    capture_lex $P280
+    .const 'Sub' $P263 = "29" 
+    capture_lex $P263
+    .const 'Sub' $P251 = "28" 
+    capture_lex $P251
     .const 'Sub' $P232 = "27" 
     capture_lex $P232
     .const 'Sub' $P207 = "25" 
         $P2 = $P0.'new_class'($P1)
       subclass_done:
         pop_eh
-    .const 'Sub' $P273 = "30" 
-    capture_lex $P273
-    .return ($P273)
+    .const 'Sub' $P280 = "30" 
+    capture_lex $P280
+    .return ($P280)
 .end
 
 
     push_eh $P234
     .lex "$/", param_235
     .lex "$k", param_236
-    find_lex $P237, "$/"
-    get_hll_global $P238, ["PAST"], "Val"
-    find_lex $P239, "$k"
-    unless_null $P239, vivify_83
-    new $P239, "Undef"
+    get_hll_global $P237, ["PAST"], "Op"
+    find_lex $P238, "$/"
+    unless_null $P238, vivify_83
+    new $P238, "Undef"
   vivify_83:
+    $P239 = $P237."new"("test" :named("name"), "call" :named("pasttype"), $P238 :named("node"))
+    .lex "$test", $P239
     find_lex $P240, "$/"
-    unless_null $P240, vivify_84
-    new $P240, "Undef"
+    get_hll_global $P241, ["PAST"], "Op"
+    find_lex $P242, "$test"
+    unless_null $P242, vivify_84
+    new $P242, "Undef"
   vivify_84:
-    $P241 = $P238."new"($P239 :named("value"), "String" :named("returns"), $P240 :named("node"))
-    $P242 = $P237."result_object"($P241)
-    .return ($P242)
+    find_lex $P243, "$/"
+    set $P244, $P243["branch"]
+    unless_null $P244, vivify_85
+    new $P244, "Undef"
+  vivify_85:
+    $P245 = $P244."item"()
+    find_lex $P246, "$k"
+    unless_null $P246, vivify_86
+    new $P246, "Undef"
+  vivify_86:
+    find_lex $P247, "$/"
+    unless_null $P247, vivify_87
+    new $P247, "Undef"
+  vivify_87:
+    $P248 = $P241."new"($P242, $P245, $P246 :named("pasttype"), $P247 :named("node"))
+    $P249 = $P240."result_object"($P248)
+    .return ($P249)
   control_233:
     .local pmc exception 
     .get_results (exception) 
-    getattribute $P243, exception, "payload"
-    .return ($P243)
+    getattribute $P250, exception, "payload"
+    .return ($P250)
     rethrow exception
 .end
 
 
 .namespace ["z2";"Grammar";"Actions"]
 .sub "computation"  :subid("28") :method :outer("32")
-    .param pmc param_247
-    .param pmc param_248
-    new $P246, 'ExceptionHandler'
-    set_addr $P246, control_245
-    $P246."handle_types"(58)
-    push_eh $P246
-    .lex "$/", param_247
-    .lex "$key", param_248
-    find_lex $P249, "$/"
-    find_lex $P250, "$key"
-    unless_null $P250, vivify_85
-    new $P250, "Undef"
-  vivify_85:
-    find_lex $P251, "$/"
-    unless_null $P251, vivify_86
-    new $P251, "Hash"
-  vivify_86:
-    set $P252, $P251[$P250]
-    unless_null $P252, vivify_87
-    new $P252, "Undef"
-  vivify_87:
-    $P253 = $P252."item"()
-    $P254 = $P249."result_object"($P253)
-    .return ($P254)
-  control_245:
+    .param pmc param_254
+    .param pmc param_255
+    new $P253, 'ExceptionHandler'
+    set_addr $P253, control_252
+    $P253."handle_types"(58)
+    push_eh $P253
+    .lex "$/", param_254
+    .lex "$key", param_255
+    find_lex $P256, "$/"
+    find_lex $P257, "$key"
+    unless_null $P257, vivify_88
+    new $P257, "Undef"
+  vivify_88:
+    find_lex $P258, "$/"
+    unless_null $P258, vivify_89
+    new $P258, "Hash"
+  vivify_89:
+    set $P259, $P258[$P257]
+    unless_null $P259, vivify_90
+    new $P259, "Undef"
+  vivify_90:
+    $P260 = $P259."item"()
+    $P261 = $P256."result_object"($P260)
+    .return ($P261)
+  control_252:
     .local pmc exception 
     .get_results (exception) 
-    getattribute $P255, exception, "payload"
-    .return ($P255)
+    getattribute $P262, exception, "payload"
+    .return ($P262)
     rethrow exception
 .end
 
 
 .namespace ["z2";"Grammar";"Actions"]
 .sub "unary"  :subid("29") :method :outer("32")
-    .param pmc param_259
-    .param pmc param_260
-    new $P258, 'ExceptionHandler'
-    set_addr $P258, control_257
-    $P258."handle_types"(58)
-    push_eh $P258
-    .lex "$/", param_259
-    .lex "$key", param_260
-    get_hll_global $P261, ["PAST"], "Op"
-    find_lex $P262, "$key"
-    unless_null $P262, vivify_88
-    new $P262, "Undef"
-  vivify_88:
-    find_lex $P263, "$/"
-    unless_null $P263, vivify_89
-    new $P263, "Undef"
-  vivify_89:
-    $P264 = $P261."new"($P262 :named("name"), "call" :named("pasttype"), $P263 :named("node"))
-    .lex "$res", $P264
-    find_lex $P265, "$res"
-    unless_null $P265, vivify_90
-    new $P265, "Undef"
-  vivify_90:
-    find_lex $P266, "$/"
-    set $P267, $P266["value"]
-    unless_null $P267, vivify_91
-    new $P267, "Undef"
+    .param pmc param_266
+    .param pmc param_267
+    new $P265, 'ExceptionHandler'
+    set_addr $P265, control_264
+    $P265."handle_types"(58)
+    push_eh $P265
+    .lex "$/", param_266
+    .lex "$key", param_267
+    get_hll_global $P268, ["PAST"], "Op"
+    find_lex $P269, "$key"
+    unless_null $P269, vivify_91
+    new $P269, "Undef"
   vivify_91:
-    $P268 = $P267."item"()
-    $P265."push"($P268)
-    find_lex $P269, "$/"
-    find_lex $P270, "$res"
+    find_lex $P270, "$/"
     unless_null $P270, vivify_92
     new $P270, "Undef"
   vivify_92:
-    $P271 = $P269."result_object"($P270)
-    .return ($P271)
-  control_257:
+    $P271 = $P268."new"($P269 :named("name"), "call" :named("pasttype"), $P270 :named("node"))
+    .lex "$res", $P271
+    find_lex $P272, "$res"
+    unless_null $P272, vivify_93
+    new $P272, "Undef"
+  vivify_93:
+    find_lex $P273, "$/"
+    set $P274, $P273["value"]
+    unless_null $P274, vivify_94
+    new $P274, "Undef"
+  vivify_94:
+    $P275 = $P274."item"()
+    $P272."push"($P275)
+    find_lex $P276, "$/"
+    find_lex $P277, "$res"
+    unless_null $P277, vivify_95
+    new $P277, "Undef"
+  vivify_95:
+    $P278 = $P276."result_object"($P277)
+    .return ($P278)
+  control_264:
     .local pmc exception 
     .get_results (exception) 
-    getattribute $P272, exception, "payload"
-    .return ($P272)
+    getattribute $P279, exception, "payload"
+    .return ($P279)
     rethrow exception
 .end
 
 
 .namespace ["z2";"Grammar";"Actions"]
 .sub "binary"  :subid("30") :method :outer("32")
-    .param pmc param_276
-    .param pmc param_277
-    new $P275, 'ExceptionHandler'
-    set_addr $P275, control_274
-    $P275."handle_types"(58)
-    push_eh $P275
-    .lex "$/", param_276
-    .lex "$key", param_277
-    get_hll_global $P278, ["PAST"], "Op"
-    find_lex $P279, "$key"
-    unless_null $P279, vivify_93
-    new $P279, "Undef"
-  vivify_93:
-    find_lex $P280, "$/"
-    unless_null $P280, vivify_94
-    new $P280, "Undef"
-  vivify_94:
-    $P281 = $P278."new"($P279 :named("name"), "call" :named("pasttype"), $P280 :named("node"))
-    .lex "$res", $P281
-    find_lex $P283, "$/"
-    set $P284, $P283["value"]
-    unless_null $P284, vivify_95
-    new $P284, "Undef"
-  vivify_95:
-    defined $I285, $P284
-    unless $I285, for_undef_96
-    iter $P282, $P284
-    new $P295, 'ExceptionHandler'
-    set_addr $P295, loop294_handler
-    $P295."handle_types"(64, 66, 65)
-    push_eh $P295
-  loop294_test:
-    unless $P282, loop294_done
-    shift $P286, $P282
-  loop294_redo:
-    .const 'Sub' $P288 = "31" 
-    capture_lex $P288
-    $P288($P286)
-  loop294_next:
-    goto loop294_test
-  loop294_handler:
+    .param pmc param_283
+    .param pmc param_284
+    new $P282, 'ExceptionHandler'
+    set_addr $P282, control_281
+    $P282."handle_types"(58)
+    push_eh $P282
+    .lex "$/", param_283
+    .lex "$key", param_284
+    get_hll_global $P285, ["PAST"], "Op"
+    find_lex $P286, "$key"
+    unless_null $P286, vivify_96
+    new $P286, "Undef"
+  vivify_96:
+    find_lex $P287, "$/"
+    unless_null $P287, vivify_97
+    new $P287, "Undef"
+  vivify_97:
+    $P288 = $P285."new"($P286 :named("name"), "call" :named("pasttype"), $P287 :named("node"))
+    .lex "$res", $P288
+    find_lex $P290, "$/"
+    set $P291, $P290["value"]
+    unless_null $P291, vivify_98
+    new $P291, "Undef"
+  vivify_98:
+    defined $I292, $P291
+    unless $I292, for_undef_99
+    iter $P289, $P291
+    new $P302, 'ExceptionHandler'
+    set_addr $P302, loop301_handler
+    $P302."handle_types"(64, 66, 65)
+    push_eh $P302
+  loop301_test:
+    unless $P289, loop301_done
+    shift $P293, $P289
+  loop301_redo:
+    .const 'Sub' $P295 = "31" 
+    capture_lex $P295
+    $P295($P293)
+  loop301_next:
+    goto loop301_test
+  loop301_handler:
     .local pmc exception 
     .get_results (exception) 
-    getattribute $P296, exception, 'type'
-    eq $P296, 64, loop294_next
-    eq $P296, 66, loop294_redo
-  loop294_done:
+    getattribute $P303, exception, 'type'
+    eq $P303, 64, loop301_next
+    eq $P303, 66, loop301_redo
+  loop301_done:
     pop_eh 
-  for_undef_96:
-    find_lex $P297, "$/"
-    find_lex $P298, "$res"
-    unless_null $P298, vivify_99
-    new $P298, "Undef"
-  vivify_99:
-    $P299 = $P297."result_object"($P298)
-    .return ($P299)
-  control_274:
+  for_undef_99:
+    find_lex $P304, "$/"
+    find_lex $P305, "$res"
+    unless_null $P305, vivify_102
+    new $P305, "Undef"
+  vivify_102:
+    $P306 = $P304."result_object"($P305)
+    .return ($P306)
+  control_281:
     .local pmc exception 
     .get_results (exception) 
-    getattribute $P300, exception, "payload"
-    .return ($P300)
+    getattribute $P307, exception, "payload"
+    .return ($P307)
     rethrow exception
 .end
 
 
 .namespace ["z2";"Grammar";"Actions"]
-.sub "_block287"  :anon :subid("31") :outer("30")
-    .param pmc param_289
-    .lex "$_", param_289
-    find_lex $P290, "$res"
-    unless_null $P290, vivify_97
-    new $P290, "Undef"
-  vivify_97:
-    find_lex $P291, "$_"
-    unless_null $P291, vivify_98
-    new $P291, "Undef"
-  vivify_98:
-    $P292 = $P291."item"()
-    $P293 = $P290."push"($P292)
-    .return ($P293)
+.sub "_block294"  :anon :subid("31") :outer("30")
+    .param pmc param_296
+    .lex "$_", param_296
+    find_lex $P297, "$res"
+    unless_null $P297, vivify_100
+    new $P297, "Undef"
+  vivify_100:
+    find_lex $P298, "$_"
+    unless_null $P298, vivify_101
+    new $P298, "Undef"
+  vivify_101:
+    $P299 = $P298."item"()
+    $P300 = $P297."push"($P299)
+    .return ($P300)
 .end
 

src/gen_grammar.pir

           $I1 = can $P1, "test"
           if $I1 == 0 goto R446
           mpos = pos
-          $P1."test"(mob, "so")
+          $P1."test"(mob, "if")
           goto R446
         R446: # subrule ws
           captob = captscope
           $I1 = can $P1, "test"
           if $I1 == 0 goto R453
           mpos = pos
-          $P1."test"(mob, "not")
+          $P1."test"(mob, "unless")
           goto R453
         R453: # subrule ws
           captob = captscope

src/parser/actions.pm

 
 
 method test($/, $k) {
-    make PAST::Val.new( :value( $k ), :returns('String'), :node($/) );
+  my $test := PAST::Op.new( 
+    :name( 'test' ), 
+    :pasttype('call'), 
+    :node( $/ ) );
+
+  make PAST::Op.new( 
+    $test,
+    $( $<branch> ),
+    :pasttype($k), 
+    :node($/) );
 }
 method computation($/, $key) {
   make $( $/{$key} );

src/parser/grammar.pg

   | 'is' <value> 'as' <adjective> 'as' <value>{*} #= equal
 }
 rule test {
-  | 'if so,' <branch>  {*} #= so
-  | 'if not,' <branch> {*} #= not
+  | 'if so,' <branch>  {*} #= if
+  | 'if not,' <branch> {*} #= unless
 }
 rule computation {
   |<binary> {*} #= binary
+Scene III : no special characters. 
+[ENTER romeo and juliet]
+Juliet:  Are you better than nothing?
+
+Romeo: If not, we shall proceed to scene IV.
+
+Juliet: Open your heart! 
+ 
+[Exit Romeo]
+
Binary file modified.