Changeset 924
- Timestamp:
- Jul 1, 2003, 6:38:19 AM (18 years ago)
- Location:
- to-imperative/trunk/compiler
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/compiler/rfp_asail.rf
r881 r924 98 98 }; 99 99 (TRY e.body) = 100 ('trap 100 ('trap') ('{' (<ASAIL-To-CPP e.body>) '}'); 101 101 (CATCH-ERROR e.body) = 102 ('with {' (<ASAIL-To-CPP e.body>) '}');102 ('with') <ASAIL-To-CPP e.body>; 103 103 RETURN = ('return true;'); 104 104 RETFAIL = ('retfail;'); … … 205 205 <Expr-Int-To-CPP e.pos> ', ' <Expr-Int-To-CPP e.len> ')'; 206 206 (REF t.name) = <Name-To-CPP t.name>; 207 ERROR-EXPR = 'err'; 207 208 (s.var-tag t.name) = <Rfp2Cpp (s.var-tag t.name)>; 208 209 }; -
to-imperative/trunk/compiler/rfp_clashes.rf
r881 r924 152 152 <Classify-Lengths (s.idx (e.Re) (s.dir e.Pe))> :: e.boxes1, 153 153 /* 154 * Если e.R1 -- переменная или константа, кладём е гов ящик154 * Если e.R1 -- переменная или константа, кладём её в ящик 155 155 * &Ready-Source. 156 156 */ -
to-imperative/trunk/compiler/rfp_compile.rf
r881 r924 243 243 <Gener-Vars (e.in) "arg"> :: e.in, 244 244 <Vars e.in> :: e.arg-vars, 245 <Vars-Decl e.arg-vars> : e, 245 <Vars-Decl e.arg-vars> : e, // ??? 246 246 <Map &Set-Var- (Instantiated? True) (e.arg-vars)> : e, 247 247 <Store &Arg-Vars e.arg-vars>, … … 394 394 (s.dir e.Pattern) e.Snt, s.dir : \{ LEFT; RIGHT; } = 395 395 <Get-Clash-Sequence (e.last-Re) e.Sentence> :: (e.clashes) e.Sentence, 396 // <WriteLN XXX e.clashes>,397 396 <Comp-Clashes (e.clashes) s.tail? (v.fails) e.Sentence>; 398 397 … … 415 414 * If so, we should declare variables from that expression before 416 415 * entering any branch -- those should be visible after the block. 416 * Pattern or format expression is placed in the end of each branch. 417 * But if a branch computes to $error, the expression shouldn't be 418 * used, so protect it with (Comp If-not-error). 417 419 * If next after the block is (Comp Error) then block results should be 418 420 * used as values for $error, so place (Comp Error) in the end of each 419 421 * branch. 422 * If next after the block is (Comp If-not-error) then our block is in 423 * the end of a branch of an outer block and has next pattern or format 424 * inherited from there. In that case we should place all the sentence 425 * rest in the end of each branch because the block can be inside the 426 * $error already. 420 427 */ 421 428 { … … 432 439 <Vars e.expr> :: e.vars, 433 440 * <New-Vars e.vars>, 434 (<Vars-Decl e.vars>) (t.first) ((Comp Source)) e.rest; 441 (<Vars-Decl e.vars>) ((Comp If-not-error) t.first) 442 ((Comp Source)) e.rest; 435 443 (Comp Error) e.rest = 436 444 () ((Comp Error)) () /*empty*/; 445 (Comp If-not-error) e.rest = 446 () (e.Snt) () /*empty*/; 437 447 e = () () () e.Snt; 438 } :: (e.decls) (e.next-term ) (e.source?) e.Snt,448 } :: (e.decls) (e.next-terms) (e.source?) e.Snt, 439 449 /* 440 450 * The block is a source if after it goes pattern or format expression … … 480 490 (v.branch-fails ((BREAK t.br-label))) 481 491 (e.last-Re) 482 e.branch e.next-term 492 e.branch e.next-terms 483 493 > :: e.comp-br, 484 494 <Recall-Snt-State>, … … 487 497 e.branches : (BRANCH e.branch) = 488 498 <Comp-Sentence 489 s.tail-branch? (v.branch-fails) (e.last-Re) e.branch e.next-term 499 s.tail-branch? (v.branch-fails) (e.last-Re) e.branch e.next-terms 490 500 > :: e.last-branch, 491 501 <Pop-Snt-State>, … … 505 515 * Then compile $iter condition and body both with the current state of the 506 516 * sentence. 507 * e.Snt can contain only (Comp Error), so compile it together with the 517 * e.Snt can contain (Comp Error) and (protected from errors) pattern or 518 * format which comes from an outer block, so compile it together with the 508 519 * condition. 509 520 * If condition fails we should compute the body, so put the compiled … … 527 538 * Then recall the state of the sentence and compile catching of an error 528 539 * with a variable err. 529 * e.Snt can be only (Comp Error), so compile it together with both530 * sentences -- when either of it comuptes to an object expression it531 * becomes a value of the $error.540 * e.Snt can contain (Comp Error) and (protected from errors) pattern or 541 * format which comes from an outer block, so compile it together with both 542 * sentences. 532 543 */ 533 544 (TRY (BRANCH e.try) e.catch) e.Snt = … … 535 546 <Comp-Sentence Notail ((FATAL)) () e.try e.Snt> :: e.comp-try, 536 547 <Pop-Snt-State>, 537 <Comp-Sentence s.tail? (v.fails) () (RESULT (EVAR ("err" 0))) e.catch e.Snt> 538 :: e.comp-catch, 548 <Gener-Err-Var> :: t.var, 549 <Set-Var (Instantiated? True) t.var>, 550 <Comp-Sentence s.tail? (v.fails) (t.var) e.catch e.Snt> :: e.comp-catch, 539 551 (TRY e.comp-try) (CATCH-ERROR e.comp-catch); 540 552 … … 605 617 (LABEL (t.label) e.comp-negation) <Comp-Sentence s.tail? (v.fails) () e.Snt>; 606 618 607 // (Comp Verbatim expr) = expr;608 609 619 /* 610 620 * In case of $error all fails become $error(Fname "Unexpected fail"). So … … 614 624 */ 615 625 (ERROR) e.Snt = 616 <Comp-Sentence Notail ((FATAL)) e.Snt () (Comp Error)>; 617 618 (Comp Error) e.Snt = (ERROR e.last-Re); 626 <Comp-Sentence Notail ((FATAL)) () e.Snt (Comp Error)>; 627 628 (Comp Error) e.Snt = 629 <Comp-Static-Exprs (e.last-Re)> : (e.Re), 630 (ERROR e.Re); 631 632 /* 633 * Protection mark to be used between source and tail. If there is $error 634 * construction somewhere in the source then the tail shouldn't be 635 * computed, but instead the source value should be used for throwing. 636 */ 637 (Comp If-not-error) e.Snt = 638 { 639 e.Snt : e (Comp Error) = 640 <Comp-Sentence s.tail? (v.fails) (e.last-Re) (Comp Error)>; 641 <Comp-Sentence s.tail? (v.fails) (e.last-Re) e.Snt>; 642 }; 619 643 620 644 // (Comp Fatal) = FATAL; 621 645 622 646 // (Comp Retfail) = RETFAIL; 623 624 (Comp Fail t.fail) e.Snt = <Comp-Sentence s.tail? (v.fails t.fail) () e.Snt>;625 647 626 648 }; -
to-imperative/trunk/compiler/rfp_vars.rf
r881 r924 232 232 (s.tag <Box 1 e.prefix>) <Gener-Vars (e.Fe) e.prefix>; 233 233 }; 234 e.format : (PAREN e1) e2 =235 (PAREN <Gener-Vars ( e1) e.prefix>) <Gener-Vars (e2) e.prefix>;234 e.format : (PAREN v1) e2 = 235 (PAREN <Gener-Vars (v1) e.prefix>) <Gener-Vars (e2) e.prefix>; 236 236 e.format : t.Ft e.Fe = 237 237 t.Ft <Gener-Vars (e.Fe) e.prefix>; … … 241 241 * <New-Vars e.vars>, 242 242 * (e.vars) e.Re; 243 244 Gener-Err-Var = (EVAR <Box 2>); 243 245 244 246 … … 282 284 <Store s.box t.var>, 283 285 t.var <Boxes-To-Vars expr>; 286 2 = 287 ERROR-EXPR <Boxes-To-Vars expr>; 284 288 t.var = <Boxes-To-Vars t.var expr>; 285 289 }; -
to-imperative/trunk/compiler/rfp_vars.rfi
r759 r924 22 22 23 23 $func Gener-Vars (e.format) e.prefix = /*(e.vars)*/ e.Re; 24 25 $func Gener-Err-Var = t.var; 24 26 25 27 $func? Generated-Var? e.Re = ;
Note: See TracChangeset
for help on using the changeset viewer.