Changeset 750


Ignore:
Timestamp:
May 22, 2003, 1:41:13 PM (18 years ago)
Author:
orlov
Message:
  • Work towards clashes compilation.
Location:
to-imperative/trunk/compiler
Files:
2 edited

Legend:

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

    r712 r750  
    8282      } :: e.label,
    8383      ('for ( ; ' <Cond-To-CPP e.cond> '; ' <Step-To-CPP e.step> ')')
    84       ('{' (<ASAIL-To-CPP e.body>) e.label '}');
     84      ('{' ('{' (<ASAIL-To-CPP e.body>) '}') e.label '}');
    8585    (LABEL (e.label) e.body) =
    8686      {
  • to-imperative/trunk/compiler/rfp_compile.rf

    r749 r750  
    12561256$func CC (e.clashes) s.tail? (v.fails) e.Snt = e.asail-Snt;
    12571257
    1258 $const New-Clash-Tags = Unknown-length Ties Check-symbols Dereference Compare;
     1258$const New-Clash-Tags = Unknown-length Ties Check-symbols Deref Compare;
    12591259
    12601260Comp-Clashes (e.clashes) s.tail? (v.fails) e.Sentence =
     
    12771277$func Cyclic-Restr (e.fail) (e.watched-clashes) e.clashes = e.cond (e.clashes);
    12781278
    1279 $func Compare-Subexprs (e.fail) e.clashes = e.cond;
     1279$func Deref-Exprs
     1280    (e.fail) (e.conds) (e.assigns) e.clashes = e.clashes (e.conds) (e.assigns);
     1281
     1282$func Compare-Subexprs (e.fail) (e.conds) e.clashes = e.clashes (e.conds);
    12801283
    12811284$func? Comp-Cycle e.clashes = t t t e.clashes;
     
    13541357  <Cyclic-Restr (e.fail) (/*e.watched*/) e.clashes> :: e.cond (e.clashes),
    13551358
    1356     /*
    1357      * If previous doesn't work then compare recursively all known
    1358      * subexpressions and all unknown repeated subexpressions with
    1359      * corresponding parts of source.
    1360      */
    1361     e.cond <Compare-Subexprs (e.fail) e.clashes> :: e.cond,
    1362     e.clashes (/*e.assigns*/) $iter {
    1363       e.tmp-clashes : (e (e.Re) (s.dir e.Pe)) e.rest =
    1364         e.rest (e.assigns <Map &Assign-Value (<Vars e.Pe>)>);
    1365     } :: e.tmp-clashes (e.assigns),
    1366     e.tmp-clashes : /*empty*/ =
    1367     {
    1368       <Comp-Cycle e.clashes> :: t.var t.l-var t.r-var e.clashes =
    1369         <Gener-Label L "For" "Cont"> :: t.cont-label,
    1370         <Gener-Label L "For" "Break"> :: t.break-label,
    1371         e.cond e.assigns
    1372         (LSPLIT t.var (<Get-Var Min t.l-var>) t.l-var t.r-var)
    1373 //        (LABEL (t.break-label)
    1374           (FOR (t.cont-label) () ((INC-ITER t.var))
    1375             <CC (e.clashes) s.tail?
    1376               (e.prev-fails (e.fail) /*((BREAK t.break-label))*/)
    1377               (Comp Fail ((CONTINUE t.cont-label))) e.Snt>
    1378 //          )
    1379         );
    1380       e.cond e.assigns <Comp-Sentence s.tail? (e.prev-fails (e.fail)) () e.Snt>;
     1359    <Deref-Exprs (e.fail) (/*e.conds*/) (/*e.assigns*/) e.clashes> : {
     1360      e.new-clashes (v.conds) (v.assigns) =
     1361        e.cond v.conds v.assigns
     1362        <CC (e.new-clashes) s.tail? (e.prev-fails (e.fail)) e.Snt>;
     1363
     1364      /*
     1365       * If previous doesn't work then compare recursively all known
     1366       * subexpressions and all unknown repeated subexpressions with
     1367       * corresponding parts of source.
     1368       */
     1369      e.new-clashes () () =
     1370        <Compare-Subexprs (e.fail) () e.new-clashes> :: e.clashes (e.cond2),
     1371        e.new-clashes (/*e.assigns*/) $iter {
     1372          e.new-clashes : (e (e.Re) (s.dir e.Pe)) e.rest =
     1373            e.rest (e.assigns <Map &Assign-Value (<Vars e.Pe>)>);
     1374        } :: e.new-clashes (e.assigns),
     1375        e.new-clashes : /*empty*/ =
     1376        {
     1377          <Comp-Cycle e.clashes> :: t.var t.l-var t.r-var e.clashes =
     1378            <Gener-Label L "For" "Cont"> :: t.cont-label,
     1379            <Gener-Label L "For" "Break"> :: t.break-label,
     1380            e.cond e.cond2 e.assigns
     1381            (LSPLIT t.var (<Get-Var Min t.l-var>) t.l-var t.r-var)
     1382            (LABEL (t.break-label)
     1383              (FOR (t.cont-label) () ((INC-ITER t.var))
     1384                <CC (e.clashes) s.tail?
     1385                  (e.prev-fails (e.fail))
     1386                  (Comp Fail ((CONTINUE t.cont-label))) e.Snt>
     1387                (BREAK t.break-label)
     1388              )
     1389            );
     1390          e.cond e.cond2 e.assigns
     1391          <Comp-Sentence s.tail? (e.prev-fails (e.fail)) () e.Snt>;
     1392        };
    13811393    };
    13821394};
     
    19441956
    19451957
     1958$func Deref-Left  (e.fail) (e.conds) (e.assigns) (e.clashes) (e.pos) (e.Re) e.Pe =
     1959  e.Pe (e.conds) (e.assigns) (e.clashes) (e.rest-Pe);
     1960
     1961$func Deref-Right (e.fail) (e.conds) (e.assigns) (e.clashes) (e.pos) (e.Re) e.Pe =
     1962  e.Pe (e.conds) (e.assigns) (e.clashes) (e.rest-Pe);
     1963
     1964Deref-Exprs (e.fail) (e.conds) (e.assigns) e.clashes, {
     1965  e.clashes : e1 (e.t1 Deref e.t2 (e.Re) (s.dir e.Pe)) e2 =
     1966    <Deref-Left  (e.fail) () () () (0) (e.Re) e.Pe>
     1967      :: e.l-Pe (e.l-conds) (e.l-assigns) (e.l-clashes) (e.rest-Pe),
     1968    <Deref-Right (e.fail) () () () (0) (e.Re) e.rest-Pe>
     1969      :: e.r-Pe (e.r-conds) (e.r-assigns) (e.r-clashes) (e.Pe),
     1970    e1 e.l-clashes (e.t1 e.t2 (e.Re) (s.dir e.l-Pe e.Pe e.r-Pe)) e.r-clashes
     1971    <Deref-Exprs (e.fail)
     1972            (e.conds e.l-conds e.r-conds)
     1973            (e.assigns e.l-assigns e.r-assigns) e2>;
     1974  e.clashes (e.conds) (e.assigns);
     1975};
     1976
     1977Deref-Left (e.fail) (e.conds) (e.assigns) (e.clashes) (e.pos) (e.Re) e.Pe, {
     1978  e.Pe : t.Pt e.rest, {
     1979    <Get-Known-Length t.Pt> : e.len (), {
     1980      t.Pt : (PAREN expr) =
     1981        <Gener-Vars ((VAR)) "deref" e.Re> : t.var,
     1982        <Set-Var (Instantiated? True) t.var>,
     1983        (PAREN t.var)
     1984        ((IF ((SYMBOL? e.Re (e.pos))) e.fail))
     1985        ((DEREF t.var e.Re (e.pos)))
     1986        ((<Gener-Label "clash"> &New-Clash-Tags (t.var) (LEFT expr)));
     1987      t.Pt () () ();
     1988    } :: t.Pt (e.cond) (e.assign) (e.clash) =
     1989      t.Pt
     1990      <Deref-Left (e.fail)
     1991            (e.conds e.cond) (e.assigns e.assign) (e.clashes e.clash)
     1992            (e.pos e.len) (e.Re) e.rest>;
     1993    (e.conds) (e.assigns) (e.clashes) (e.Pe);
     1994  };
     1995  (e.conds) (e.assigns) (e.clashes) ();
     1996};
     1997
     1998Deref-Right (e.fail) (e.conds) (e.assigns) (e.clashes) (e.pos) (e.Re) e.Pe =
     1999  () () () (e.Pe);
     2000
     2001
     2002
    19462003$func Compare-Terms-Left  (e.fail) (e.pos) (e.Re) e.Pe = e.cond (e.rest-Pe);
    19472004$func Compare-Terms-Right (e.fail) (e.pos) (e.Re) e.Pe = e.cond (e.rest-Pe);
    19482005
    1949 Compare-Subexprs (e.fail) e.clashes, {
     2006Compare-Subexprs (e.fail) (e.conds) e.clashes, {
    19502007  e.clashes : (e.t (e.Re) (s.dir e.Pe)) e.rest =
    1951     <Compare-Terms-Left (e.fail) (0) (e.Re) e.Pe> :: e.left-cond (e.rest-Pe),
    1952     <Compare-Terms-Right (e.fail) (0) (e.Re) e.rest-Pe> :: e.right-cond t,
    1953     e.left-cond e.right-cond <Compare-Subexprs (e.fail) e.rest>;
    1954   /*empty*/;
     2008    <Compare-Terms-Left (e.fail) (0) (e.Re) e.Pe> :: e.l-cond (e.rest-Pe),
     2009    <Compare-Terms-Right (e.fail) (0) (e.Re) e.rest-Pe> :: e.r-cond (e.Pe),
     2010    {
     2011      e.Pe : /*empty*/ = /*empty*/;
     2012      (e.t (e.Re) (s.dir e.Pe));
     2013    } :: e.clash,
     2014    e.clash <Compare-Subexprs (e.fail) (e.conds e.l-cond e.r-cond) e.rest>;
     2015  (e.conds);
    19552016};
    19562017
     
    19852046};
    19862047
    1987 Compare-Terms-Right (e.fail) (e.pos) (e.Re) e.Pe = ();
     2048Compare-Terms-Right (e.fail) (e.pos) (e.Re) e.Pe = (e.Pe);
    19882049
    19892050
Note: See TracChangeset for help on using the changeset viewer.