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

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

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 311x 1x 1x 1x 1x 1x 1x 1x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 1x  
import {seq, optPrio, star, tok, Expression, altPrio} from "../combi";
import {AttributeName, ClassName, SourceField, SourceFieldSymbol, TableExpression, ComponentName, FieldOffset, FieldLength, TableBody, Dereference} from ".";
import {InstanceArrow, StaticArrow, Dash, DashW} from "../../1_lexer/tokens";
import {IStatementRunnable} from "../statement_runnable";
import {dynAttr, dynComp} from "./_dynamic_access";
 
export class FieldChain extends Expression {
  public getRunnable(): IStatementRunnable {
 
    const attr = seq(tok(InstanceArrow), AttributeName);
    const comp = seq(tok(Dash), optPrio(ComponentName));
 
    const chain = star(altPrio(
      Dereference,
      dynAttr(),
      attr,
      dynComp(optPrio(FieldOffset), optPrio(FieldLength)),
      comp,
      TableExpression));
 
    const clas = seq(ClassName, tok(StaticArrow), AttributeName);
    const start = altPrio(clas, SourceField, SourceFieldSymbol);
 
    const after = altPrio(tok(DashW), seq(optPrio(TableBody), optPrio(FieldOffset), optPrio(FieldLength)));
 
    const ret = seq(start, chain, after);
 
    return ret;
  }
}