All files / src/ddl ddl_lexer.ts

100% Statements 33/33
100% Branches 10/10
100% Functions 1/1
100% Lines 33/33

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 331x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 26x 9x 9x 17x 17x 5x 5x 5x 91x 43x 91x 7x 7x 48x 41x 41x 91x 5x 5x 5x 1x
import {Identifier} from "../abap/1_lexer/tokens";
import {Token} from "../abap/1_lexer/tokens/_token";
import {IFile} from "../files/_ifile";
import {Position} from "../position";
 
export class DDLLexer {
  public static run(file: IFile): Token[] {
    const step1: string[] = [];
 
    const lines = file.getRaw().replace(/\c/g, "").split("\n");
 
    for (const l of lines) {
      if (l.startsWith("@")) {
        continue; // skip annotations for now
      }
      step1.push(...l.split(" "));
    }
 
    const step2: string[] = [];
    for (const t of step1) {
      if (t === "") {
        continue;
      } else if (t.endsWith(";")) {
        step2.push(t.substr(0, t.length - 1));
        step2.push(";");
      } else {
        step2.push(t);
      }
    }
 
    return step2.map(t => new Identifier(new Position(1, 1), t));
  }
}