source: to-imperative/trunk/java/refal/refal/plus/XML.rf @ 3952

Last change on this file since 3952 was 3952, checked in by yura, 12 years ago
  • XML library
File size: 709 bytes
Line 
1$module "refal.plus.XML";
2
3$use Convert Stream  StdIO;
4
5$func? GetTag s.stream = e.text (e.tag);
6
7GetTag s.stream =
8  <Get_Delim s.stream '<'> : e.text '<',
9  <Get_Delim s.stream '>'> : e.tag '>',
10  e.text ('<' e.tag '>');
11
12$func ReadTag s.stream e.tag = t;
13
14ReadTag s.stream e.tag, e.tag : {
15  '<' e.name '/>' =
16    (<ToWord e.name>);
17  '<' e.name '>' =
18    <GetTag s.stream> $iter e.text <ReadTag s.stream e.tag> <GetTag s.stream> :: e.text (e.tag),
19    e.tag : '</' e.name '>',
20    (<ToWord e.name> e.text);
21};
22
23$public $func Read s = t;
24
25Read s.stream = <GetTag s.stream> : (e.tag), <ReadTag s.stream e.tag>;
26
27$func Main = e;
28
29Main =
30  <WriteLn <Read <Expr_Open '<Z>as<C/><B>b<Z></Z></B><C>c</C></Z>'>>>;
Note: See TracBrowser for help on using the repository browser.