# All files / src/parser builtin-type.js

100% Statements 11/11
100% Branches 2/2
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
    30

    28x
    28x

    162x
    3x
    3x
    3x
    3x
    3x

    3x
    3x

    159x

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

    export default function builtInType(ctx: Context): NodeType {
      if (ctx.stream.peek().value === "<") {
        const valueType = ctx.token.value;
        ctx.eat(["Memory", "Table"]);
        ctx.eat(["<"]);
        ctx.eat(["{"]);
        const node = ctx.makeNode(
          {
            value: valueType,
            type: valueType,
            params: [expression(ctx)],
          },
          Syntax.Type
        );
        ctx.eat(["}"]);
        return node;
      }

      return ctx.makeNode(
        { value: ctx.token.value, type: ctx.token.value },
        Syntax.Type
      );
    }