# All files / src/parser introspection.js

100% Statements 7/7
100% Branches 12/12
100% Functions 2/2
100% Lines 7/7

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

    28x
    863x

    28x
    135x

    10x

    125x

     // @flow
    import precedence from "./precedence";
    import type { TokenType } from "../flow/types";

    export const getPrecedence = (token: TokenType): number =>
      precedence[token.value];

    export const getAssociativty = (token: TokenType): "left" | "right" => {
      switch (token.value) {
        case "=":
        case "-=":
        case "+=":
        case "--":
        case "++":
        case "?":
          return "right";
        case "+":
        case "-":
        case "/":
        case "*":
        case ":":
        default:
          return "left";
      }
    };