# All files / src/parser statement.js

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

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

    28x
    1052x

    535x

    78x

    439x
    393x

    46x
    45x

    1x

     // @flow
    import Syntax from "../Syntax";
    import block from "./block";
    import keyword from "./keyword";
    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);
          }
          throw ctx.syntaxError("Unexpected expression");
      }
    };

    export default statement;