# All files / src/parser keyword.js

100% Statements 24/24
100% Branches 12/12
100% Functions 1/1
100% Lines 24/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
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x

    27x
    1538x

    174x

    47x

    138x

    113x

    816x

    61x

    3x

    5x

    178x

    2x

    1x

     // @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;