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

100% Statements 43/43
100% Branches 1/1
100% Functions 1/1
100% Lines 43/43

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 431x 1x 1x 1x 1x 1x 1x 1x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 1x 1x
import {IStatement} from "./_statement";
import {seq, opt, alt, per, plus, optPrio} from "../combi";
import {Target, Source, FindType} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
 
export class Find implements IStatement {
 
  public getMatcher(): IStatementRunnable {
// SUBMATCHES handling is a workaround
    const options = per("IGNORING CASE",
                        "RESPECTING CASE",
                        "IN BYTE MODE",
                        "IN CHARACTER MODE",
                        seq("OF", Source),
                        seq("FROM", Source),
                        seq("TO", Source),
                        seq("MATCH OFFSET", Target),
                        seq("MATCH LINE", Target),
                        seq("MATCH COUNT", Target),
                        seq("MATCH LENGTH", Target),
                        seq("LENGTH", Source),
                        seq("RESULTS", Target),
                        seq("SUBMATCHES", Target),
                        seq("SUBMATCHES", Target, Target),
                        seq("SUBMATCHES", plus(Target)));
 
    const sectionLength = seq("SECTION LENGTH", Source, "OF");
 
    const before = seq(optPrio(alt("TABLE", "SECTION OFFSET", sectionLength)),
                       Source);
 
    const ret = seq("FIND",
                    opt(alt("FIRST OCCURRENCE OF", "ALL OCCURRENCES OF")),
                    FindType,
                    Source,
                    "IN",
                    before,
                    opt(options));
 
    return ret;
  }
 
}