# All files / src/parser constant.js

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    28x

    400x
    400x
    400x
    400x

     // @flow
    import type Context from "./context";
    import Syntax from "../Syntax";

    export default function parseConstant(ctx: Context) {
      const node = ctx.startNode();
      const value = ctx.token.value;
      const type = value.toString().indexOf(".") !== -1 ? "f32" : "i32";
      return ctx.endNode({ ...node, type, value }, Syntax.Constant);
    }