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

Last change on this file since 1233 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: 1.2 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 =
12  /*<PrintLN <Time>>,*/
13  <MkArg '1234567890ab'> :: e.Arg,
14  <PrintLN e.Arg>,
15  <Select e.Arg> :: e.Res,
16  <PrintLN e.Res>,
17  /*<PrintLN <Time>>*/;
18
19MkArg e.String = * e.Prefixes
20  ( ) (e.String) $iter {
21    e.Prefix : e.Prefix-- s =
22      (e.Prefixes (e.Prefix)) (e.Prefix--) ;
23  } :: (e.Prefixes) (e.Prefix),
24  e.Prefix : /*empty*/
25   = e.Prefixes;
26
27Select e.Sets = * e.Xs-or-sFail -- (eXs') or '*'
28  {
29    <Sel () e.Sets> :: (e.Xs) = (<Stack2Exp e.Xs>);
30    '*';
31  };
32
33Sel (e.Xs) e.Sets = * (eXs) | $fail;
34  e.Sets : \{
35    /*empty*/ = (e.Xs);
36
37    (e.Set) e.Sets--,
38      e.Set : e sX e,
39      #<InStack e.Xs s.X>,
40      <Sel (s.X (e.Xs)) e.Sets-->;
41  };
42
43InStack e.Xs s.X =               * /*empty*/ | $false;
44  e.Xs : s.Y (e.Xs--),
45  \{
46    s.Y : s.X;
47    <InStack e.Xs-- s.X>;
48  };
49 
50Stack2Exp e.Xs =                 * e.ExpXs
51  e.Xs : {
52    /* empty */ = /* empty */;
53    s.Y (e.Xs--) = <Stack2Exp e.Xs--> s.Y;
54  };
Note: See TracBrowser for help on using the repository browser.