# All files / src/parser precedence.js

100% Statements 21/21
100% Branches 0/0
100% Functions 0/0
100% Lines 21/21

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61

    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x
    27x

    27x
    27x

    27x

    27x

     // @flow
    // More or less JavaScript precedence
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

    export const PRECEDENCE_MEMBER_ACCESS = 19;
    export const PRECEDENCE_FUNCTION_CALL = 19;
    export const PRECEDENCE_NOT = 18;
    export const PRECEDENCE_ASSIGNMENT = 3;
    export const PRECEDENCE_INCREMENT = 2;
    export const PRECEDENCE_DECREMENT = 2;
    export const PRECEDENCE_DIVIDE = 1;
    export const PRECEDENCE_MULTIPLY = 1;
    export const PRECEDENCE_ADDITION = 0;
    export const PRECEDENCE_SUBTRACTION = 0;
    export const PRECEDENCE_SHIFT = -1;
    export const PRECEDENCE_COMMA = -2;
    export const PRECEDENCE_BITWISE_XOR = -2;
    export const PRECEDENCE_SPREAD = -1;
    export const PRECEDENCE_BITWISE_AND = -1;
    export const PRECEDENCE_BITWISE_OR = -3;
    export const PRECEDENCE_LOGICAL_AND = -4;

    export const PRECEDENCE_LOGICAL_OR = -5;
    export const PRECEDENCE_KEY_VALUE_PAIR = -1;

    export const PRECEDENCE_PARAMS = -99;

    const precedence = {
      '=>': PRECEDENCE_PARAMS,
      '(': PRECEDENCE_PARAMS,
      ',': PRECEDENCE_COMMA,
      as: PRECEDENCE_COMMA + 1,
      '>>': PRECEDENCE_SHIFT,
      '>>>': PRECEDENCE_SHIFT,
      '<<': PRECEDENCE_SHIFT,
      '+': PRECEDENCE_ADDITION,
      '-': PRECEDENCE_SUBTRACTION,
      '*': PRECEDENCE_MULTIPLY,
      '/': PRECEDENCE_DIVIDE,
      '==': 2,
      '!=': 2,
      '.': PRECEDENCE_MEMBER_ACCESS,
      '=': -1,
      '-=': PRECEDENCE_ASSIGNMENT,
      '+=': PRECEDENCE_ASSIGNMENT,
      '?': 4,
      '>': 5,
      '<': 5,
      ':': PRECEDENCE_KEY_VALUE_PAIR,
      '^': PRECEDENCE_BITWISE_XOR,
      '&': PRECEDENCE_BITWISE_AND,
      '|': PRECEDENCE_BITWISE_OR,
      '&&': PRECEDENCE_LOGICAL_AND,
      '||': PRECEDENCE_LOGICAL_OR,
      '...': PRECEDENCE_SPREAD,
      '~': PRECEDENCE_NOT,
      '!': PRECEDENCE_NOT,
    };

    export default precedence;