Ignore:
Timestamp:
Oct 2, 2008, 6:13:11 PM (12 years ago)
Author:
yura
Message:
  • Expr.concat(Comparable, Expr) checks if term in array of expr and before it.
  • XML parsing.
File:
1 edited

Legend:

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

    r3952 r3953  
    22
    33$use Convert Stream  StdIO;
     4
     5$func? GetComment s.stream = e.comment;
     6
     7GetComment s.stream,
     8  <Scans s.stream '<!--'> : '<!--' =
     9  <Get_Delims s.stream '-->'> : e.comment '-->',
     10  '<!--' e.comment '-->';
     11
     12
     13$func? GetCDATA s.stream = e.cdata;
     14
     15GetCDATA s.stream,
     16  <Scans s.stream '<![CDATA['> : '<![CDATA[' =
     17  <Get_Delims s.stream ']]>'> : e.cdata ']]>',
     18  '<![CDATA[' e.cdata ']]>';
     19
    420
    521$func? GetTag s.stream = e.text (e.tag);
     
    723GetTag s.stream =
    824  <Get_Delim s.stream '<'> : e.text '<',
    9   <Get_Delim s.stream '>'> : e.tag '>',
    10   e.text ('<' e.tag '>');
     25  <Ungets s.stream '<'>, {
     26    e.text ((COMMENT) <GetComment s.stream>) <GetTag s.stream>;
     27    e.text ((CDATA) <GetCDATA s.stream>) <GetTag s.stream>;
     28    e.text (<Get_Delim s.stream '>'>);
     29  };
    1130
    12 $func ReadTag s.stream e.tag = t;
     31$func SplitName e = (e) e;
     32
     33SplitName {
     34  e.name ' ' e.attrs = (e.name) e.attrs;
     35  e.name = (e.name);
     36};
     37
     38$func? ReadTag s.stream e.tag = t;
    1339
    1440ReadTag s.stream e.tag, e.tag : {
    1541  '<' e.name '/>' =
    16     (<ToWord e.name>);
     42    <SplitName e.name> :: (e.name) e.attrs,
     43    (<ToWord e.name> <ToWord e.attrs>);
    1744  '<' e.name '>' =
     45    <SplitName e.name> :: (e.name) e.attrs,
    1846    <GetTag s.stream> $iter e.text <ReadTag s.stream e.tag> <GetTag s.stream> :: e.text (e.tag),
    1947    e.tag : '</' e.name '>',
    20     (<ToWord e.name> e.text);
     48    (<ToWord e.name> <ToWord e.attrs> e.text);
    2149};
    2250
    23 $public $func Read s = t;
     51$public $func? Read s = e;
    2452
    25 Read s.stream = <GetTag s.stream> : (e.tag), <ReadTag s.stream e.tag>;
     53Read s.stream = <GetTag s.stream> : e.text (e.tag), e.text <ReadTag s.stream e.tag>;
    2654
    2755$func Main = e;
    2856
    2957Main =
    30   <WriteLn <Read <Expr_Open '<Z>as<C/><B>b<Z></Z></B><C>c</C></Z>'>>>;
     58  <WriteLn <Read <Expr_Open '<Z>as<C/><B>b<!--<Z></Z>--></B><C>c</C></Z>'>>>;
Note: See TracChangeset for help on using the changeset viewer.