Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-22157

Allow a DATASET definition to be assigned a row

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.4.40
    • Fix Version/s: 7.4.0
    • Component/s: Code Generator
    • Labels:
      None
    • Environment:
      N/A

      Description

      Hi,

      I've been demoing the Tomita variant of PARSE to my colleagues, using the calculator example in the ECL ref manual. I notice that you can assign the result from MATCHROW to DATASET(<record structure>) if said item is in the result rec, but not if the left-hand side of the expression is a standalone local DATASET.

      PATTERN ws := [' ','\t'];
      TOKEN number := PATTERN('[0-9]+');
      TOKEN plus := '+';
      TOKEN minus := '-';attrRec := RECORD
       REAL val;
      END;RULE(attrRec) e0 :=   '(' USE(attrRec,expr)? ')'
                          | number TRANSFORM(attrRec, SELF.val := (INTEGER)$1;)
                          | '-' SELF TRANSFORM(attrRec, SELF.val := -$2.val;);
      RULE(attrRec) e1 :=   e0
                          | SELF '*' e0 TRANSFORM(attrRec, SELF.val := $1.val * $3.val;)
                          | USE(attrRec, e1) '/' e0 TRANSFORM(attrRec, SELF.val := $1.val / $3.val;);
      RULE(attrRec) e2 :=   e1
                          | SELF plus e1 TRANSFORM(attrRec, SELF.val := $1.val + $3.val;)
                          | SELF minus e1 TRANSFORM(attrRec, SELF.val := $1.val - $3.val;);
      RULE(attrRec) expr := e2;infile := DATASET([{'1+2*3'},{'1+2*z'},{'1+2+(3+4)*4/2'},{'2+1/2+1/6+1/24+1/120+1/720+1/5040'}],{ STRING line });resultsRec := RECORD
       DATASET(attrRec) ds;
      END;resultsRec extractResults(infile l, attrRec attr) := TRANSFORM
       // DATASET(attrRec) xxx := MATCHROW(e0);  // Syntax failure if included
       SELF.ds  := MATCHROW(e0);
      END;OUTPUT(PARSE(infile,line,expr,extractResults(LEFT, $1), FIRST,WHOLE,PARSE,SKIP(ws)));
      

      So what's the difference between

       DATASET(attrRec) xxx := MATCHROW(e0); 
      

      and

      SELF.ds := MATCHROW(e0);
      

      Yours

      Allan

        Attachments

          Activity

            People

            • Assignee:
              ghalliday Gavin Halliday
              Reporter:
              allan Allan Francis Wrobel
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: