# All files / src/tokenizer/constant index.js

100% Statements 21/21
100% Branches 10/10
100% Functions 5/5
100% Lines 18/18

    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
    31
    32
    33
    34
    35
    28x
    28x

    28x
    18442x
    18428x
    54x
    28x
    490x
    26x

    464x
    68x

    396x

    28x
    17938x
    14x

    17924x
    818x

    17106x

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

    const { isNaN, parseInt } = Number;
    export const isNumber = (char: string) => !isNaN(parseInt(char));
    const isDot = char => char === ".";
    const number = char => (isNumber(char) ? number : null);
    const numberOrDot = char => {
      if (isDot(char)) {
        return number;
      }

      if (isNumber(char)) {
        return numberOrDot;
      }
      return null;
    };

    const root = char => {
      if (isDot(char)) {
        return number;
      }

      if (isNumber(char)) {
        return numberOrDot;
      }

      return null;
    };

    // TODO: split constants into literals String vs Numbers with Types
    // TODO: figure out what above means??
    export default token(root, Syntax.Constant);