- Timestamp:
- 10/13/08 16:31:54 (3 months ago)
- Location:
- misc/elfish/STD_blue
- Files:
-
- 2 modified
-
IRx1_FromAST2_create.pl (modified) (13 diffs)
-
STD_blue_run (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
misc/elfish/STD_blue/IRx1_FromAST2_create.pl
r22593 r22595 13 13 statement 14 14 my $labels = $m<label>; 15 my $result = $m<EXPR> || $m< control>;16 if $o<EXPR> && ($o< mod_loop> || $o<mod_cond>) {15 my $result = $m<EXPR> || $m<statement_control>; 16 if $o<EXPR> && ($o<statement_mod_loop>.elems || $o<statement_mod_cond>.elems) { 17 17 temp $blackboard::statement_expr = $result; 18 $result = $m< mod_loop> || $m<mod_cond>;19 if $o<mod_condloop> { 18 $result = $m<statement_mod_loop>[0] || $m<statement_mod_cond>[0]; 19 if $o<mod_condloop> { #XXX still exists? 20 20 $blackboard::statement_expr = $result; 21 21 $result = $m<mod_condloop>; … … 29 29 30 30 EXPR 31 if $m<infix> { 31 if $o<termish> { 32 $m<termish>[0] 33 } 34 elsif $o<infix> { 32 35 my $op = $m<infix><sym_name>; 33 36 my $args = [$m<left>,$m<right>]; … … 39 42 } 40 43 } 44 elsif $o<chain> { 45 my $op = $o<chain>[1]<sym_name>; 46 my $args = [$m<chain>[0],$m<chain>[2]]; 47 Apply.newp("infix:"~$op,Capture.newp1($args)) 48 } 49 elsif $o<list> { 50 my $op = $o<delims>[0]<sym_name>; 51 my $args = $m<list>; 52 Apply.newp("infix:"~$op,Capture.newp1($args)) 53 } 41 54 else { 42 55 temp $blackboard::expect_term_base = $m<noun>; … … 99 112 $m<fatarrow> || $m<variable> || $m<package_declarator> || $m<scope_declarator> || $m<multi_declarator> || $m<routine_declarator> || $m<regex_declarator> || $m<type_declarator> || $m<circumfix> || $m<dotty> || $m<value> || $m<capterm> || $m<sigterm> || $m<term> || $m<statement_prefi> || $m<colonpair> 100 113 114 115 desigilname 116 $m<longname> 117 118 deflongname 119 $m<name> 120 101 121 longname 102 122 $m<name> … … 130 150 my $args = $m<args><semilist>; 131 151 if not($args) && $o<args><arglist>[0]<EXPR> { 132 $args = [ ir build_ir($o<args><arglist>[0]<EXPR>) ];152 $args = [ ir($o<args><arglist>[0]<EXPR>) ]; 133 153 } 134 154 Apply.newp($m<identifier>,Capture.newp1($args||[])) … … 159 179 my $nibs = $m<nibble><nibbles>; 160 180 my $args = $nibs.map(sub($x){if $x.WHAT eq 'Str' {Buf.newp($x);} else {$x}}); 161 Apply.newp('infix:~',Capture.newp1($args||[])) 181 if $args.elems < 2 { $args.push(Buf.newp("")) } 182 my $tmp = $args.shift; 183 for $args { 184 $tmp = Apply.newp('infix:~',Capture.newp1([$tmp,$_])) 185 } 186 $tmp; 162 187 163 188 nibbles:\ 164 189 my $which = $m<item><sym_name>; 165 190 if $which eq 'n' { "\n" } 166 if $which eq 't' { "\t" }191 elsif $which eq 't' { "\t" } 167 192 else { $which } 193 194 nibbles 195 $m<variable> 168 196 169 197 … … 198 226 199 227 variable 200 my $tw = $m<twigil> ;201 if $o<postcircumfix> {228 my $tw = $m<twigil>[0]; 229 if $o<postcircumfix>.elems { 202 230 if $tw eq "." { 203 231 my $slf = Apply.newp('self',Capture.newp1([])); … … 231 259 232 260 statement_control:for 233 For.newp($m< EXPR>,$m<xblock>)261 For.newp($m<xblock><EXPR>,$m<xblock>) 234 262 235 263 statement_mod_loop:for … … 259 287 260 288 statement_control:if 289 my $if_expr = $m<xblock><EXPR>; 290 my $if_block = $m<xblock><pblock>; 261 291 my $els = $m<else>; 262 292 if $els { $els = $els[0] } 263 Cond.newp([[$ m<if_expr>,$m<if_block>]].push($m<elsif>.flatten),$els,undef)293 Cond.newp([[$if_expr,$if_block]].push($m<elsif>.flatten),$els,undef) 264 294 265 295 elsif … … 315 345 316 346 pblock 317 if $o<signature> {318 SubDecl.newp(undef,undef,undef,undef,$m<signature> ,undef,$m<block>)347 if $o<signature>.elems { 348 SubDecl.newp(undef,undef,undef,undef,$m<signature>[0],undef,$m<block>) 319 349 } else { 320 350 $m<block> … … 327 357 $m<pblock> 328 358 329 plurality_declarator:multi359 multi_declarator:multi 330 360 temp $blackboard::plurality = 'multi'; 331 $m<pluralized> || $m<routine_def> 332 333 routine_declarator:routine_def 334 my $scope = $blackboard::scope; temp $blackboard::scope; 361 $m<declarator> 362 363 routine_declarator:sub 364 $m<routine_def> 365 366 routine_declarator:method 367 $m<method_def> 368 369 method_def 335 370 my $plurality = $blackboard::plurality; temp $blackboard::plurality; 336 my $ident = ""; 337 if $o<ident> { $ident = $m<ident> }; 338 if ($o<ident> && not($scope)) { $scope = "our" }; 339 my $sig = Signature.newp([],undef); 340 if $m<multisig> { $sig = $m<multisig>.[0] }; 341 SubDecl.newp($scope,undef,$plurality,$ident,$sig,$m<trait>,$m<block>) 342 343 # routine_def is the same as routine_declarator:routine_def 344 # This is a workaround for STD.pm not recognizing multi f(){} . 371 my $multisig = $m<multisig>; 372 if not($multisig) { $multisig = [Signature.newp([],undef)]; } 373 MethodDecl.newp(undef,undef,$plurality,$m<longname>,$multisig.[0],maybe($m<trait>),$m<block>,undef,undef) 374 345 375 routine_def 346 376 my $scope = $blackboard::scope; temp $blackboard::scope; 347 377 my $plurality = $blackboard::plurality; temp $blackboard::plurality; 348 378 my $ident = ""; 349 if $o< ident> { $ident = $m<ident>};350 if ($ o<ident>&& not($scope)) { $scope = "our" };379 if $o<deflongname>.elems { $ident = $m<deflongname>[0] }; 380 if ($ident && not($scope)) { $scope = "our" }; 351 381 my $sig = Signature.newp([],undef); 352 if $m<multisig> { $sig = $m<multisig>.[0] }; 353 SubDecl.newp($scope,undef,$plurality,$ident,$sig,$m<trait>,$m<block>) 354 355 routine_declarator:method_def 356 my $plurality = $blackboard::plurality; temp $blackboard::plurality; 357 my $multisig = $m<multisig>; 358 if not($multisig) { $multisig = [Signature.newp([],undef)]; } 359 MethodDecl.newp(undef,undef,$plurality,$m<ident>,$multisig.[0],$m<trait>,$m<block>,undef,undef) 382 if $o<multisig> { $sig = $m<multisig>.[0] }; 383 SubDecl.newp($scope,undef,$plurality,$ident,$sig,maybe($m<trait>),$m<block>) 384 385 multisig 386 $m<signature>[0] 360 387 361 388 signature 362 Signature.newp($m<par sep>,undef)389 Signature.newp($m<parameter>,undef) 363 390 364 391 parameter 365 Parameter.newp($m<type_constraint>,$m<quantchar>,$m<param_var>,undef,undef,undef,undef) 392 my $var = $m<param_var>; 393 my $quantchar; 394 if $o<slurp> { 395 $var = $m<slurp><param_var>; 396 $quantchar = '*'; 397 } 398 my $type_constraint = $m<type_constraint>; 399 #X gimme5 is emitting two copies of the constraint. 400 if $type_constraint && $type_constraint.elems == 2 { $type_constraint.pop } 401 Parameter.newp($type_constraint,$quantchar,$var,undef,undef,undef,undef) 366 402 367 403 param_var 368 ParamVar.newp($m<sigil>,$m<twigil>,$m<ident>) 404 ParamVar.newp($m<sigil>,$m<twigil>[0],$m<identifier>[0]) 405 406 type_constraint 407 $m<fulltypename> 408 409 fulltypename 410 $m<typename>[0] 411 412 typename 413 $m<longname> 414 369 415 370 416 capture … … 450 496 451 497 package_def 452 PackageDecl.newp(undef,undef,$blackboard::package_declarator,$m<module_name>.[0],$m<traits>,$m<block>) 453 454 fulltypename 455 $m<typename>.join("::") 456 457 typename 458 *text* # $m<name> 459 460 trait_verb:is 461 Trait.newp('is',$m<ident>) 462 463 trait_verb:does 464 Trait.newp('does',$m<role_name>) 498 PackageDecl.newp(undef,undef,$blackboard::package_declarator,$m<module_name>.[0],maybe($m<trait>),$m<block>) 499 500 trait 501 $m<trait_auxiliary> 502 503 trait_auxiliary:is 504 Trait.newp('is',$m<longname>) 505 506 trait_auxiliary:does 507 Trait.newp('does',$m<module_name>) 465 508 466 509 … … 632 675 $x.make_ir_from_Match_tree() 633 676 }; 677 sub maybe ($x) { 678 if $x.WHAT eq "Array" && $x.elems == 0 { undef } 679 else { $x } 680 } 634 681 635 682 END -
misc/elfish/STD_blue/STD_blue_run
r22593 r22595 149 149 if($seen{$o}++ > $max_repetition) { return "LOOP:$o"->to_dump0 } 150 150 my $rule = $category; 151 if($rule =~ /\A(chain|list|arg|left|right )\z/) { $rule = 'EXPR' }151 if($rule =~ /\A(chain|list|arg|left|right|termish)\z/) { $rule = 'EXPR' } 152 152 my $sym = $o->{sym}; 153 153 if($sym) { … … 168 168 my $v = $o->{$_}; 169 169 local $category = $_; 170 my $vs = $v->to_dump0;170 my $vs = defined($v) ? $v->to_dump0 : 'undef'; 171 171 "\n $_ => $vs," 172 172 } … … 190 190 sub to_dump0 { 191 191 my($o)=@_; 192 $o =~ s/([\\' \$\@\%])/\\$1/g;192 $o =~ s/([\\'])/\\$1/g; 193 193 "'".$o."'"; 194 194 }
