Changeset 2715


Ignore:
Timestamp:
Apr 19, 2007, 2:09:07 AM (14 years ago)
Author:
orlov
Message:
  • Changes in Refal Abstract Syntax: BLOCK -> ALT and BLOCK? -> ALT?.
  • Fixed searching for rfi-files from C++ compiler version.
Location:
to-imperative/trunk/compiler
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/rfp_as2as.rf

    r2638 r2715  
    8686 */
    8787Unstick_Blocks e.Sentence, e.Sentence : eL e.Snt, e.Snt : \{
    88   (s.block t.Pragma e.branches) eR, s.block : \{ BLOCK; "BLOCK?"; } =
     88  (s.block t.Pragma e.branches) eR, s.block : \{ ALT; "ALT?"; } =
    8989    e.branches () () $iter {
    9090      e.branches : (BRANCH t.p e.branch) e.rest,
     
    9595    {
    9696      eR : \{
    97         (BLOCK  t (BRANCH t (LEFT e) e) e) e;
    98         (BLOCK  t (BRANCH t (RIGHT e) e) e) e;
    99         ("BLOCK?" t (BRANCH t (LEFT e) e) e) e;
    100         ("BLOCK?" t (BRANCH t (RIGHT e) e) e) e;
    101         (LEFT e) e;
     97        (ALT    t (BRANCH t (LEFT e) e) e) e;
     98        (ALT    t (BRANCH t (RIGHT e) e) e) e;
     99        ("ALT?" t (BRANCH t (LEFT e) e) e) e;
     100        ("ALT?" t (BRANCH t (RIGHT e) e) e) e;
     101        (LEFT  e) e;
    102102        (RIGHT e) e;
    103103      } =
     
    111111      eL (s.block t.Pragma e.br) <Unstick_Blocks eR>;
    112112    };
    113   (RESULT t.Pragma (s.block e.branches)) eR, s.block : \{ BLOCK; "BLOCK?"; } =     // FIXME: Comment this and search for BUGs!
     113  (RESULT t.Pragma (s.block e.branches)) eR, s.block : \{ ALT; "ALT?"; } =     // FIXME: Comment this and search for BUGs!
    114114    eL <Unstick_Blocks (s.block e.branches) eR>;
    115115  (RESULT t.Pragma e.Re) eR =
     
    145145
    146146Flatten_Result s.Istail (e.Re) e.items, e.items : {
    147   t1 e.rest, t1 : \{ (BLOCK e); ("BLOCK?" e); } =
     147  t1 e.rest, t1 : \{ (ALT e); ("ALT?" e); } =
    148148    <Unstick_Blocks t1> :: e1 (e.Format),
    149149    {
     
    208208   * variables.
    209209   */
    210   e.Sentence : (s.block t.Pragma e.branches) e.Snt, s.block : \{ BLOCK; "BLOCK?"; } =
     210  e.Sentence : (s.block t.Pragma e.branches) e.Snt, s.block : \{ ALT; "ALT?"; } =
    211211    <Gener_Var_Indices 1 (e.in) "arg"> :: e.in_expr s,
    212212    <Vars e.in_expr> :: e.in_vars,
     
    273273       * block).
    274274       */
    275       t.Statement : (s.block t.Pragma e.branches), s.block : \{ BLOCK; "BLOCK?"; } =
     275      t.Statement : (s.block t.Pragma e.branches), s.block : \{ ALT; "ALT?"; } =
    276276        /*
    277277         * As well as after-block patterns, formats should be scaned
     
    457457//
    458458//Comp-Pattern (s.dir e.PatternExp) e.Sentence =
    459 //      <Norm-Vars (<Vars e.PatternExp>) (s.dir e.PatternExp) e.Sentence>
    460 //              : t t.Pattern e.Snt,
     459//  <Norm-Vars (<Vars e.PatternExp>) (s.dir e.PatternExp) e.Sentence>
     460//    : t t.Pattern e.Snt,
    461461////    (Unwatched (<? &Last-Re>) t.Pattern) e.Snt $iter {
    462 //      /*
    463 //      * Uncomment previous line and delete next one to activate Split-Clashes
    464 //      * function
    465 //      */
    466 //      ((<? &Last-Re>) t.Pattern) e.Snt $iter {
    467 //              e.Snt : (RESULT e.Re) (s.d e.Pe) e =
     462//  /*
     463//  * Uncomment previous line and delete next one to activate Split-Clashes
     464//  * function
     465//  */
     466//  ((<? &Last-Re>) t.Pattern) e.Snt $iter {
     467//    e.Snt : (RESULT e.Re) (s.d e.Pe) e =
    468468////                    <WriteLN Matching (RESULT e.Re) (s.d e.Pe)>,
    469 //                      <Norm-Vars (<Vars e.Pe>) e.Snt> : t t.R t.P e.rest,
     469//      <Norm-Vars (<Vars e.Pe>) e.Snt> : t t.R t.P e.rest,
    470470////                    (e.clashes Unwatched (e.Re) t.P) e.rest;
    471 //                      /*
    472 //                      * Uncomment previous line and delete next one to activate
    473 //                      * Split-Clashes function
    474 //                      */
    475 //                      (e.clashes (e.Re) t.P) e.rest;
    476 //      } :: (e.clashes) e.Snt,
    477 //      # \{
    478 //              e.Snt : \{
    479 //                      (RESULT e.Re) (LEFT e) e = e.Re;
    480 //                      (RESULT e.Re) (RIGHT e) e = e.Re;
    481 //              } :: e.Re,
    482 //                      <Without-Calls? e.Re>;
    483 //      } =
    484 //      e.Snt : e.Current-Snt (Comp Sentence) e.Other-Snts =
    485 //      <Comp-Sentence () e.Other-Snts> :: e.asail-Others,
    486 //      {
     471//      /*
     472//      * Uncomment previous line and delete next one to activate
     473//      * Split-Clashes function
     474//      */
     475//      (e.clashes (e.Re) t.P) e.rest;
     476//  } :: (e.clashes) e.Snt,
     477//  # \{
     478//    e.Snt : \{
     479//      (RESULT e.Re) (LEFT e) e = e.Re;
     480//      (RESULT e.Re) (RIGHT e) e = e.Re;
     481//    } :: e.Re,
     482//      <Without-Calls? e.Re>;
     483//  } =
     484//  e.Snt : e.Current-Snt (Comp Sentence) e.Other-Snts =
     485//  <Comp-Sentence () e.Other-Snts> :: e.asail-Others,
     486//  {
    487487////            <Split-Clashes (e.clashes) e.Current-Snt>
    488488////            :: (e.greater) (e.less) (e.hards) (e.clashes) e.Current-Snt =
     
    517517////                    e.hards : /*empty*/ =
    518518////!                   e.asail-Clashes e.asail-Others;
    519 //              e.asail-Others;
     519//    e.asail-Others;
    520520////            <Comp-Sentence () e.Other-Snts>;
    521 //      };
     521//  };
    522522//
    523523//Split-Clashes (e.clashes) e.Snt =
  • to-imperative/trunk/compiler/rfp_check.rf

    r2638 r2715  
    1313
    1414// verifies that all constructions in e.Sentence have right formats
    15 $func? IsSatisfies_Format (e.InFormat) (e.OutFormat) e.Sentence = ;
     15$func? Satisfies_Format (e.InFormat) (e.OutFormat) e.Sentence = ;
    1616
    1717// verifies that all function calls found in e.expr have appropriate input
     
    4747    t.item : (s.linkage s.tag t.pragma t.name (e.in) (e.out) t.branch),
    4848    s.tag : \{ FUNC; "FUNC?"; TFUNC; },
    49     { <IsSatisfies_Format (<Format_Exp e.in>) (<Format_Exp e.out>) t.branch>;; },
     49    { <Satisfies_Format (<Format_Exp e.in>) (<Format_Exp e.out>) t.branch>;; },
    5050    <Check_Vars (<Vars e.in>) t.branch>,
    5151    { <Print_Error "Error!" Cut <R 0 <Get_Cuts t.branch>>>;; },
     
    6060 * 4) All function calls are performed with expressions of right formats.
    6161 */
    62 IsSatisfies_Format (e.InFormat) (e.OutFormat) e.Sentence, \{
     62Satisfies_Format (e.InFormat) (e.OutFormat) e.Sentence, \{
    6363  e.Sentence : $r e.Snt (ERROR t) e.queue =
    64     <IsSatisfies_Format () ((EVAR)) e.queue>,
    65     <IsSatisfies_Format (e.InFormat) () e.Snt>;
     64    <Satisfies_Format () ((EVAR)) e.queue>,
     65    <Satisfies_Format (e.InFormat) () e.Snt>;
    6666  e.Sentence (e.OutFormat) $iter {
    6767    e.Sentence : e.Snt t.Statement,
     
    6969        (RESULT t.Pragma e.ResultExpression) =
    7070          {
    71             e.ResultExpression : (s.block e), s.block : \{ BLOCK; "BLOCK?"; } =
    72               <IsSatisfies_Format () (e.OutFormat) e.ResultExpression>,
     71            e.ResultExpression : (s.block e), s.block : \{ ALT; "ALT?"; } =
     72              <Satisfies_Format () (e.OutFormat) e.ResultExpression>,
    7373              e.Snt ();
    7474            <IsSubformat (e.OutFormat) (<Format_Exp e.ResultExpression>)> =
     
    8989//            <Print-Error Error! Re t.Statement>, $fail;
    9090//          };
    91         (s.block t e.Branches), s.block : \{ BLOCK; "BLOCK?"; } =
     91        (s.block t e.Branches), s.block : \{ ALT; "ALT?"; } =
    9292          {
    9393            e.Snt : /*empty*/ = /*empty*/;
     
    9696          {
    9797            e.Branches : e (BRANCH t e.Snt1) e,
    98               <IsSatisfies_Format (e.InFormat) (e.OutFormat) e.pref e.Snt1>,
     98              <Satisfies_Format (e.InFormat) (e.OutFormat) e.pref e.Snt1>,
    9999              $fail;
    100100            e.Snt ((EVAR));
     
    108108        (ITER (BRANCH t e.Snt1) (FORMAT t.Pragma e.HardExp) (BRANCH t e.Snt2)) =
    109109          <Format_Exp e.HardExp> :: e.HardFormat,
    110           <IsSatisfies_Format () (e.HardFormat) e.Snt1>,
     110          <Satisfies_Format () (e.HardFormat) e.Snt1>,
    111111          e.Snt (FORMAT t.Pragma e.HardExp) e.Snt2 (e.OutFormat);
    112112        (TRY (BRANCH t e.Snt1) e.NOFAIL t.CatchBlock) =
    113           <IsSatisfies_Format () (e.OutFormat) e.Snt1>,
    114           <IsSatisfies_Format ((EVAR)) (e.OutFormat) t.CatchBlock>,
     113          <Satisfies_Format () (e.OutFormat) e.Snt1>,
     114          <Satisfies_Format ((EVAR)) (e.OutFormat) t.CatchBlock>,
    115115          e.Snt ();
    116116        (s.tag t.Pragma e.PatternExpression), s.tag : \{ LEFT; RIGHT; } =
     
    135135        (STAKE t) = e.Snt ();
    136136        (BRANCH t e.Snt1) =
    137           <IsSatisfies_Format (e.InFormat) (e.OutFormat) e.Snt1> ();
     137          <Satisfies_Format (e.InFormat) (e.OutFormat) e.Snt1> ();
    138138        (Comp Branch) = /*empty*/ ();
    139139      };
     
    197197        (LEFT  t e.Pe) = <Update_Vars Pattern (e.vars) <Vars e.Pe>>;
    198198        (RIGHT t e.Pe) = <Update_Vars Pattern (e.vars) <Vars e.Pe>>;
    199         (s.block t e.Branches), s.block : \{ BLOCK; "BLOCK?"; } =
     199        (s.block t e.Branches), s.block : \{ ALT; "ALT?"; } =
    200200          {
    201201            e.Branches : e t.branch e,
     
    267267        { <Print_Error "Error!" Cut <R 0 <Get_Cuts t.Branch>>>;; },
    268268        e.cuts;
    269       (s.block t e.Branches), s.block : \{ BLOCK; "BLOCK?"; } =
     269      (s.block t e.Branches), s.block : \{ ALT; "ALT?"; } =
    270270        () e.Branches $iter {
    271271          e.Branches : t.Branch e.rest =
  • to-imperative/trunk/compiler/rfp_compile.rf

    r2638 r2715  
    279279    <Comp_Clashes (e.clashes) s.Istail (v.fails) e.Sentence>;
    280280
    281   ("BLOCK?") e =
     281  ("ALT?") e =
    282282    v.fails : e (e.last_fail),
    283283    e.last_fail;
    284284
    285   (BLOCK) e =
     285  (ALT) e =
    286286    FATAL;
    287287
     
    293293  (s.block e.branches) e.Snt,
    294294    s.block : \{
    295       BLOCK = (FATAL);
    296       "BLOCK?";
     295      ALT = (FATAL);
     296      "ALT?";
    297297    } :: e.Isfatal =
    298298    /*
     
    10361036    e.Re : t.Rt e.rest =
    10371037      t.Rt : {
    1038         (CALL e) = $fail;
    1039         (BLOCK e) = $fail;
     1038        (CALL   e) = $fail;
     1039        (ALT    e) = $fail;
     1040        ("ALT?" e) = $fail;
    10401041        (PAREN e.Re1) = <IsWithout_Calls e.Re1>;
    10411042        t.symbol_or_var = /*empty*/;
  • to-imperative/trunk/compiler/rfp_debug.rf

    r2638 r2715  
    8585    <Map &Conv_Pragma (<Nub v.debugs>)> : {
    8686      v.stop_cals =
    87         (BLOCK (PRAGMA) (BRANCH (PRAGMA)
    88             ("BLOCK?" (PRAGMA) v.stop_cals)
     87        (ALT (PRAGMA) (BRANCH (PRAGMA)
     88            ("ALT?" (PRAGMA) v.stop_cals)
    8989            (RESULT (PRAGMA) (CALL (PRAGMA) (Debug Debug) <Map &Conv_Var (env)>)))
    9090          (BRANCH (PRAGMA) (RESULT (PRAGMA))));
  • to-imperative/trunk/compiler/rfp_parse.rf

    r2668 r2715  
    562562      <Get_Expected_Token RBRACE> : e,
    563563      {
    564         s.type : LBRACE = (BLOCK <Pragma e.pos> e.items);
    565         ("BLOCK?" <Pragma e.pos> e.items);
     564        s.type : LBRACE = (ALT <Pragma e.pos> e.items);
     565        ("ALT?" <Pragma e.pos> e.items);
    566566      };
    567567  };
     
    677677        <Get_Expected_Token RBRACE> : e, // TODO: is it good for error correction?
    678678        {
    679           s.type : LBRACE = (BLOCK <Pragma e.pos> e.items);
    680           ("BLOCK?" <Pragma e.pos> e.items);
     679          s.type : LBRACE = (ALT <Pragma e.pos> e.items);
     680          ("ALT?" <Pragma e.pos> e.items);
    681681        };
    682682    };
  • to-imperative/trunk/compiler/rfp_src.rf

    r2710 r2715  
    8585      <Get &RFP_Include_Path> : e (e.dirname) e,
    8686      <Try_Open e.dirname e.fname '.rfi'>;
    87     $trap
    88       <Intersperse ('/') e.qname> '.rfi' :: e.fname, \?
    89       <GetSystemResourceAsStream <ToWord e.fname>> <Null> : {
    90         s.null s.null, \! $fail;
    91         s.is   s.null = FILE &Get_Line_From_Reader (e.fname) (<BufferedReader <InputStreamReader s.is>>);
    92       }
     87    $trap \{
     88      <Intersperse ('/') e.qname> '.rfi' :: e.fname \?
     89        <GetSystemResourceAsStream <ToWord e.fname>> <Null> : {
     90          s.null s.null \! $fail;
     91          s.is   s.null = FILE &Get_Line_From_Reader (e.fname) (<BufferedReader <InputStreamReader s.is>>);
     92        };
     93      <Intersperse (s.dir_separator) e.qname> :: e.fname,
     94        <Get &RFP_Include_Path> : e (e.dirname) e \?
     95        <ReadFormatsFromFile <ToWord e.dirname e.fname '.class'>> <Null> : {
     96          s.null s.null \! $fail;
     97          s.str  s.null = <Store &FormatsFromClass <ToChars s.str>>,
     98            FILE &ReadFormatsFromBox (e.dirname e.fname '.class') ();
     99        };
     100      <Intersperse ('/') e.qname> :: e.fname \?
     101        <ReadFormatsFromClass <ToWord e.fname>> <Null> : {
     102          s.null s.null \! $fail;
     103          s.str  s.null = <Store &FormatsFromClass <ToChars s.str>>,
     104            FILE &ReadFormatsFromBox (e.fname '.class') ();
     105        };
     106    }
    93107    $with \{
    94108      e "Not available",
     
    98112        <Try_Open e.dirname e.lib '.rfi'>;
    99113    };
    100     <Intersperse (s.dir_separator) e.qname> :: e.fname,
    101       <Get &RFP_Include_Path> : e (e.dirname) e, \?
    102       <ReadFormatsFromFile <ToWord e.dirname e.fname '.class'>> <Null> : {
    103         s.null s.null, \! $fail;
    104         s.str  s.null = <Store &FormatsFromClass <ToChars s.str>>,
    105           FILE &ReadFormatsFromBox (e.dirname e.fname '.class') ();
    106       };
    107     <Intersperse ('/') e.qname> :: e.fname, \?
    108       <ReadFormatsFromClass <ToWord e.fname>> <Null> : {
    109         s.null s.null, \! $fail;
    110         s.str  s.null = <Store &FormatsFromClass <ToChars s.str>>,
    111           FILE &ReadFormatsFromBox (e.fname '.class') ();
    112       };
    113114  };
    114115
Note: See TracChangeset for help on using the changeset viewer.