source: to-imperative/trunk/samples/select3.rf @ 432

Last change on this file since 432 was 432, checked in by pooh, 18 years ago
  • Workaround to allow program compilation.
  • Makefile rules changed to allow correct dependency checking.
  • Removed C++ versions of samples from CVS.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1//$use Dos StdIO;// TIMER;
2$use StdIO;
3
4$func  MkArg  eString     = ePrefixes;
5$func  Select eSets       = eXs-or-sFail;   * (eXs) or '*'
6$func? Sel    (eXs) eSets = (eXs);
7$func? InStack e.Xs s.X   = ;               * /*empty*/ | $false;
8$func  Stack2Exp e.Xs     = e.ExpXs;
9
10
11Main =   /*<PrintLN <Time>>,*/
12         <MkArg "1234567890ab"> :: e.Arg,
13         <PrintLN e.Arg>,
14         <Select e.Arg> :: e.Res,
15         <PrintLN e.Res>,
16         /*<PrintLN <Time>>*/;
17
18MkArg e.String = * e.Prefixes
19   ( ) (e.String) $iter{
20      e.Prefix : e.Prefix-- s =
21        (e.Prefixes (e.Prefix)) (e.Prefix--) ;
22   } :: (e.Prefixes)            (e.Prefix),
23   e.Prefix : /*empty*/
24   = e.Prefixes;
25
26Select e.Sets = * e.Xs-or-sFail -- (eXs') or '*'
27   {  <Sel () e.Sets>::(e.Xs)
28         = (<Stack2Exp e.Xs>);
29      '*';
30   };
31
32Sel (e.Xs) e.Sets = * (eXs) | $fail;
33   e.Sets : \{
34           /*empty*/ = (e.Xs);
35
36      (e.Set) e.Sets--,
37              e.Set : e sX e,
38         #<InStack e.Xs s.X>,
39         <Sel (s.X (e.Xs)) e.Sets-->;
40   };
41
42InStack e.Xs s.X =               * /*empty*/ | $false;
43  e.Xs: s.Y (e.Xs--),
44  \{  s.Y : s.X;
45      <InStack e.Xs-- s.X>;
46  };
47 
48Stack2Exp e.Xs =                 * e.ExpXs
49   e.Xs : {
50      /* empty */
51         = /* empty */;
52      s.Y (e.Xs--)
53         = <Stack2Exp e.Xs--> s.Y;
54   };
Note: See TracBrowser for help on using the repository browser.