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

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

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 421x 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 2x 2x 2x 1x
import {seq, starPrio, optPrio, tok, Expression, altPrio} from "../combi";
import {WParenLeftW, WParenRightW} from "../../1_lexer/tokens";
import {SQLJoin, SQLFromSource} from ".";
import {IStatementRunnable} from "../statement_runnable";
 
export class SQLFrom extends Expression {
  // todo: rewrite/refactor this method
  public getRunnable(): IStatementRunnable {
    const joins = starPrio(seq(optPrio(tok(WParenRightW)), SQLJoin));
 
    // No opening parens
    const from0 = seq("FROM", SQLFromSource, joins);
 
    // 1 to 6 opening parens, with up to that many closing parens at the end
    const from1 = seq("FROM", tok(WParenLeftW), SQLFromSource, joins, optPrio(tok(WParenRightW)));
 
    const from2 = seq("FROM", tok(WParenLeftW), tok(WParenLeftW), SQLFromSource, joins,
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)));
 
    const from3 = seq("FROM", tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW), SQLFromSource, joins,
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)));
 
    const from4 = seq("FROM", tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW),
                      SQLFromSource, joins,
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)),
                      optPrio(tok(WParenRightW)));
 
    const from5 = seq("FROM", tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW),
                      tok(WParenLeftW), SQLFromSource, joins,
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)),
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)));
 
    const from6 = seq("FROM", tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW), tok(WParenLeftW),
                      tok(WParenLeftW), tok(WParenLeftW), SQLFromSource, joins,
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)),
                      optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)), optPrio(tok(WParenRightW)));
 
    const source = altPrio(from6, from5, from4, from3, from2, from1, from0);
 
    return source;
  }
}