Changeset 3953


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.
Location:
to-imperative/trunk/java
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/java/org/refal/plus/Expr.java

    r3842 r3953  
    271271            return create(obj);
    272272        int k = (expr.start + expr.length) % expr.terms.length;
     273        if (expr.terms[k] == obj) {
     274            no_copy++;
     275            return new Expr(expr.terms, expr.start, expr.length + 1);
     276        }
    273277        if (expr.terms[k] == null) {
    274278            right_copy++;
     
    288292            return create(obj);
    289293        int k = (expr.start - 1 + expr.terms.length) % expr.terms.length;
     294        if (expr.terms[k] == obj) {
     295            no_copy++;
     296            return new Expr(expr.terms, k, expr.length + 1);
     297        }
    290298        if (expr.terms[k] == null) {
    291299            left_copy++;
  • to-imperative/trunk/java/refal/refal/plus/Stream.rf

    r3614 r3953  
    9797};
    9898
     99Scans stream e1, {
     100  <Gets stream <Length e1>> : {
     101    e1 = e1;
     102    e2 = <Ungets stream e2>;
     103  };
     104  /*empty*/;
     105};
     106
     107//** $func Get-Delim stream t.delim = expr;
     108
     109Get_Delims stream e.delim, {
     110  <Scans stream e.delim> : e.delim = e.delim;
     111  <Getc stream> :: t1 = t1 <Get_Delims stream e.delim>;
     112  /*empty*/;
     113};
    99114
    100115//** $func Get-Delim stream t.delim = expr;
  • to-imperative/trunk/java/refal/refal/plus/Stream.rfi

    r3752 r3953  
    1212$func  Ungets         s.stream e.expr   = ;
    1313$func  Scanc          s.stream t.1      = e.empty_or_t1;
     14$func  Scans          s.stream e.1      = e.empty_or_e1;
    1415$func  Get_Delim      s.stream t.delim  = e.expr;
     16$func  Get_Delims     s.stream e.delim  = e.expr;
    1517$func  Get_Line       s.stream          = e.expr;
    1618$func  Get_While      s.stream s.pred   = e.expr;
  • 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.