# All files / src/parser import.js

90.91% Statements 10/11
50% Branches 1/2
100% Functions 1/1
90.91% Lines 10/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
    26x
    26x

    25x
    25x

    25x

    25x

    25x
    25x

    25x

    25x

     // @flow
    import Syntax from "../Syntax";
    import expression from "./expression";

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

    export default function parseImport(ctx: Context): NodeType {
      const baseNode = ctx.startNode();
      ctx.eat(["import"]);

      Iif (!ctx.eat(["{"])) {
        throw ctx.syntaxError("expected {");
      }

      const fields = expression(ctx);

      ctx.expect(["}"]);
      ctx.expect(["from"]);

      const module = expression(ctx);

      return ctx.endNode({ ...baseNode, params: [fields, module] }, Syntax.Import);
    }