# All files / src/parser block.js

100% Statements 11/11
83.33% Branches 5/6
100% Functions 1/1
100% Lines 11/11

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

    62x
    62x
    62x

    62x
    138x
    138x
    69x

    62x

    62x

     // @flow
    import Syntax from "../Syntax";
    import statement from "./statement";
    import type Context from "./context";
    import type { NodeType } from "../flow/types";

    export default function blockParser(ctx: Context): NodeType {
      const node = ctx.startNode();
      const params = [];
      Eif (ctx.eat(["{"])) {
        let stmt;
        while (ctx.token && ctx.token.value !== "}") {
          stmt = statement(ctx);
          if (stmt) {
            params.push(stmt);
          }
        }
        ctx.expect(["}"]);
      }

      return ctx.endNode(
        {
          ...node,
          params,
        },
        Syntax.Block
      );
    }