source: to-imperative/trunk/samples/select1.rf @ 2470

Last change on this file since 2470 was 760, checked in by orlov, 18 years ago
  • Code formatting.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 838 bytes
Line 
1//$use Dos StdIO; //"timer";
2$use StdIO;
3
4$func  MkArg  eString = ePrefixes;
5$func  Select (eXs) eSets = eXs-or-sFail; * (eXs) or '*'
6$func? OneOf  (eXs) sX = ;
7
8Main =
9  /*<PrintLN <Time>>,*/
10  <MkArg '1234567890ab'> :: e.Arg,
11  <PrintLN e.Arg>,
12  <Select () e.Arg> :: e.Res,
13  <PrintLN e.Res>,
14  //<Timer-BegProc " End ">::t,
15  /*<PrintLN <Time>>*/;
16
17MkArg e.String = * e.Prefixes
18  ( ) (e.String) $iter {
19    e.Prefix : e.Prefix-- s =
20      (e.Prefixes (e.Prefix)) (e.Prefix--) ;
21  } :: (e.Prefixes) (e.Prefix),
22  e.Prefix : /*empty*/
23  = e.Prefixes;
24
25Select (e.Xs) e.Sets = * e.Xs-or-sFail -- (eXs) or '*'
26  e.Sets : {
27    /*empty*/ = (e.Xs);
28
29    (e.Set) e.Sets--,
30      e.Set : e sX e,
31      #<OneOf (e.Xs) sX>,
32      <Select (e.Xs sX) e.Sets--> : (e.Xs-) = (e.Xs-);
33
34    e = '*';
35   };
36
37OneOf (e.Xs) s.X = */
38   e.Xs : e s.X e;
39
Note: See TracBrowser for help on using the repository browser.