Changeset 3964 for to-imperative


Ignore:
Timestamp:
Oct 9, 2008, 9:57:49 PM (12 years ago)
Author:
yura
Message:
  • Library extentions (after hdd errors).
Location:
to-imperative/trunk/java/refal/refal/plus
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/refal/refal/plus/List.rf

    r3752 r3964  
    143143  e.list;
    144144
     145
     146
     147$func QSort_Split t.num e.list = (e.list) (e.list);
     148
     149QSort_Split t.num e.list,
     150  () () (e.list) $iter {
     151    e.list : t.head e.tail, {
     152      <Le (t.head) (t.num)>,
     153        (e.smaller t.head) (e.greater) (e.tail);
     154      (e.smaller) (e.greater t.head) (e.tail);
     155    };
     156  } :: (e.smaller) (e.greater) (e.list),
     157  e.list : /*empty*/,
     158  (e.smaller) (e.greater);
     159
     160QSort {
     161  /* empty */   = /* empty */;
     162  t.head e.tail = <QSort_Split t.head e.tail> :: (e.smaller) (e.greater),
     163    <QSort e.smaller> t.head <QSort e.greater>;
     164};
     165
    145166/*
    146167 * Returns number of e.expr entries in e.source and e.source without all e.expr's.
  • to-imperative/trunk/java/refal/refal/plus/List.rfi

    r3752 r3964  
    4141$func Replicate s.n e.expr = e.list;
    4242
     43$func QSort e.list = e.list;
     44
    4345// Returns number of e.expr entries in e.source and e.source without all e.expr's.
    4446// FIXME: Strange function!
  • to-imperative/trunk/java/refal/refal/plus/Stream.rf

    r3953 r3964  
    143143//** $func Get-While stream s.pred = expr;
    144144
    145 Get_While stream s.pred, {
     145Get_While stream s.pred e.predArgs, {
    146146  <Get stream> : (e.buf) (s.func e.args) =
    147147    (/*e.str*/) (e.buf) $iter {
    148       e.buf : t1 e2, {
    149         <Apply s.pred t1> : e = (e.str t1) (e2);
    150         (e.str) (e.buf) Stop;
    151       };
    152       (e.str) (<Apply s.func e.args>);
    153       (e.str) (e.buf) Stop;
     148      e.buf : e.head t1 e.tail, # \{ <Apply s.pred e.predArgs t1> : e; } = (e.str e.head) (t1 e.tail) Stop;
     149      (e.str e.buf) (<Apply s.func e.args>);
     150      (e.str e.buf) () Stop;
    154151    } :: (e.str) (e.buf) e.Isstop,
    155152    e.Isstop : Stop =
     
    159156};
    160157
     158Get_Until stream s.pred e.predArgs, {
     159  <Get stream> : (e.buf) (s.func e.args) =
     160    (/*e.str*/) (e.buf) $iter {
     161      e.buf : e.head t1 e.tail, <Apply s.pred e.predArgs t1> : e = (e.str e.head) (t1 e.tail) Stop;
     162      (e.str e.buf) (<Apply s.func e.args>);
     163      (e.str e.buf) () Stop;
     164    } :: (e.str) (e.buf) e.Isstop,
     165    e.Isstop : Stop =
     166    <Store stream (e.buf) (s.func e.args)>,
     167    e.str;
     168  <Lib_Error (Stream "Get_Until") "Arg 1 is not a Stream"> = $fail;
     169};
    161170
    162171//** $func? End-of-Stream? stream = ;
  • to-imperative/trunk/java/refal/refal/plus/Stream.rfi

    r3953 r3964  
    1616$func  Get_Delims     s.stream e.delim  = e.expr;
    1717$func  Get_Line       s.stream          = e.expr;
    18 $func  Get_While      s.stream s.pred   = e.expr;
     18$func  Get_While      s.stream s.pred e.predArgs = e.expr;
     19$func  Get_Until      s.stream s.pred e.predArgs = e.expr;
    1920$func? IsEnd_of_Stream s.stream         = ;
    2021//X*/
  • to-imperative/trunk/java/refal/refal/plus/XML.rf

    r3960 r3964  
    11$module "refal.plus.XML";
    22
    3 $use Convert Stream  StdIO;
     3$use Convert Stream StdIO;
     4
     5$func? IsBlank t.term = ;
     6IsBlank \{ ' '; '\n'; '\r'; '\t'; };
     7
     8$func? IsBlankOrDelim t.delim t.term = ;
     9IsBlankOrDelim t.delim t.term, t.term : \{ ' '; '\n'; '\r'; '\t'; t.delim; };
     10
     11$func GetDelims s.stream t.delim = e.expr; // no e.delim at the end
     12GetDelims s.stream t.delim =
     13  GO $iter {
     14    <Get_While s.stream &IsBlank> :: e, {
     15      <Scanc s.stream t.delim> : v = e.expr STOP;
     16      <Get_Until s.stream &IsBlankOrDelim t.delim> : v.head = e.expr ' ' v.head GO;
     17      e.expr STOP;
     18    };
     19  } :: e.expr s.flag, s.flag : STOP =
     20  { e.expr : ' ' e.head = e.head; e.expr; };
     21
     22$func? GetXMLFormat s.stream = e.comment;
     23
     24GetXMLFormat s.stream,
     25  <Scans s.stream '<?'> : '<?' =
     26  <Get_Delims s.stream '?>'> : e.format '?>',
     27  '<?' e.format '?>';
     28
    429
    530$func? GetComment s.stream = e.comment;
     
    1035  '<!--' e.comment '-->';
    1136
    12 
    1337$func? GetCDATA s.stream = e.cdata;
    1438
     
    1842  '<![CDATA[' e.cdata ']]>';
    1943
    20 
    2144$func? GetTag s.stream = e.text (e.tag);
    2245
    2346GetTag s.stream =
    24   <Get_Delim s.stream '<'> : e.text '<',
     47  <GetDelims s.stream '<'> :: e.text,
     48  //<Get_Delim s.stream '<'> : e.text '<',
    2549  <Ungets s.stream '<'>, {
     50    <GetXMLFormat s.stream> : '<?' e.format '?>',
     51      e.text ((XML_FORMAT) e.format) <GetTag s.stream>;
    2652    <GetComment s.stream> : '<!--' e.comment '-->',
    2753      e.text ((COMMENT) e.comment) <GetTag s.stream>;
    2854    <GetCDATA s.stream> : '<![CDATA[' e.cdata ']]>',
    29     e.text ((CDATA) e.cdata) <GetTag s.stream>;
    30     e.text (<Get_Delim s.stream '>'>);
     55      e.text ((CDATA) e.cdata) <GetTag s.stream>;
     56    e.text (<GetDelims s.stream '>'> '>');
     57    //e.text (<Get_Delim s.stream '>'>);
    3158  };
    3259
Note: See TracChangeset for help on using the changeset viewer.