# All files / src/parser keyword.js

95.83% Statements 23/24
91.67% Branches 11/12
100% Functions 1/1
95.83% Lines 23/24

    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
    43
    28x
    28x
    28x
    28x
    28x
    28x
    28x
    28x
    28x
    28x
    28x

    28x
    535x

    114x

    26x

    129x

    13x

    37x

    47x

    4x

    2x

    161x

    2x

     // @flow
    import declaration from "./declaration";
    import maybeFunctionDeclaration from "./maybe-function-declaration";
    import _export from "./export";
    import _import from "./import";
    import _break from "./break";
    import type from "./type";
    import forLoop from "./for-loop";
    import whileLoop from "./while-loop";
    import returnStatement from "./return-statement";
    import ifThenElse from "./if-then-else";
    import Context from "./context";

    const keyword = (ctx: Context) => {
      switch (ctx.token.value) {
        case "let":
        case "const":
          return declaration(ctx);
        case "function":
          return maybeFunctionDeclaration(ctx);
        case "export":
          return _export(ctx);
        case "import":
          return _import(ctx);
        case "type":
          return type(ctx);
        case "if":
          return ifThenElse(ctx);
        case "for":
          return forLoop(ctx);
        case "while":
          return whileLoop(ctx);
        case "return":
          return returnStatement(ctx);
        case "break":
          return _break(ctx);
        default:
          throw ctx.unsupported();
      }
    };

    export default keyword;