All files / src/abap/2_statements/statements loop.ts

100% Statements 19/19
100% Branches 0/0
100% Functions 1/1
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  1x 1x 1x 1x   1x   1x     89x   89x   89x   89x   89x   89x             89x       89x   89x   89x   89x   89x         89x      
import {IStatement} from "./_statement";
import {seq, alt, opt, ver, altPrio, optPrio, tok, per, plus} from "../combi";
import {FSTarget, Target, ComponentCond, Dynamic, Source, ComponentCompare, SimpleName, ComponentName} from "../expressions";
import {Version} from "../../../version";
import {WParenLeftW, WParenRightW} from "../../1_lexer/tokens";
import {IStatementRunnable} from "../statement_runnable";
import {SimpleSource2} from "../expressions/simple_source2";
 
export class Loop implements IStatement {
 
  public getMatcher(): IStatementRunnable {
    const where = seq("WHERE", alt(ComponentCond, Dynamic));
 
    const groupSize = seq(ComponentName, "=", "GROUP SIZE");
 
    const components = seq(tok(WParenLeftW), plus(alt(ComponentCompare, groupSize)), tok(WParenRightW));
 
    const into = seq(opt("REFERENCE"), "INTO", Target);
 
    const assigning = seq("ASSIGNING", FSTarget);
 
    const group = ver(Version.v740sp08,
                      seq("GROUP BY",
                          alt(Source, components),
                          optPrio("ASCENDING"),
                          optPrio("WITHOUT MEMBERS"),
                          optPrio(alt(into, assigning))));
 
    const target = alt(seq(alt(into, assigning),
                           optPrio("CASTING")),
                       "TRANSPORTING NO FIELDS");
 
    const from = seq("FROM", Source);
 
    const to = seq("TO", Source);
 
    const usingKey = seq("USING KEY", altPrio(SimpleName, Dynamic));
 
    const options = per(target, from, to, where, usingKey, group);
 
    const at = seq("AT",
                   opt(ver(Version.v740sp08, "GROUP")),
                   alt(SimpleSource2, ver(Version.v740sp02, Source)),
                   opt(options));
 
    return seq("LOOP", opt(at));
  }
 
}