# All files / src/parser statement.js

100% Statements 14/14
100% Branches 8/8
100% Functions 1/1
100% Lines 14/14

    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
    27x
    27x
    27x
    27x
    27x

    27x
    3139x

    1538x

    178x

    1423x
    1357x

    66x
    58x

    8x

     // @flow
    import Syntax from '../Syntax';
    import block from './block';
    import keyword from './keyword';
    import expression from './expression';
    import maybeAssignment from './maybe-assignment';
    import type Context from './context';
    import type { NodeType } from '../flow/types';

    const statement = (ctx: Context): NodeType | null => {
      switch (ctx.token.type) {
        case Syntax.Keyword:
          return keyword(ctx);
        case Syntax.Identifier:
          return maybeAssignment(ctx);
        case Syntax.Punctuator:
        default:
          if (ctx.eat([';'])) {
            return null;
          }
          if (ctx.token.value === '{') {
            return block(ctx);
          }
          return expression(ctx);
      }
    };

    export default statement;