All files / src/abap/2_statements/expressions compare.ts

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

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 391x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x
import {seq, ver, tok, plus, optPrio, star, altPrio, Expression, AlsoIn} from "../combi";
import {FieldSub, ClassName, Constant, Source, MethodCallChain, CompareOperator, SourceFieldSymbolChain} from ".";
import {WParenLeft, ParenRightW} from "../../1_lexer/tokens";
import {Release} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
 
export class Compare extends Expression {
  public getRunnable(): IStatementRunnable {
    const val = altPrio(FieldSub, Constant);
 
    const list = seq(tok(WParenLeft),
                     val,
                     plus(seq(",", val)),
                     tok(ParenRightW));
 
    const inn = seq(optPrio("NOT"), "IN", altPrio(Source, list));
 
    const sopt = seq("IS",
                     optPrio("NOT"),
                     altPrio("SUPPLIED",
                             "BOUND",
                             ver(Release.v750, seq("INSTANCE OF", ClassName), {also: AlsoIn.OpenABAP}),
                             "REQUESTED",
                             "INITIAL"));
 
    const between = seq(optPrio("NOT"), "BETWEEN", Source, "AND", Source);
 
// a predicative method call, or a predicate function like contains( ), the release is checked in syntax
    const predicate = MethodCallChain;
 
    const rett = seq(Source, altPrio(seq(CompareOperator, Source), inn, between, sopt));
 
    const fsassign = seq(SourceFieldSymbolChain, "IS", optPrio("NOT"), "ASSIGNED");
 
    const ret = seq(star("NOT"), altPrio(rett, predicate, fsassign));
 
    return ret;
  }
}