       @string,
       @regex,
       @true,
-      @true,
       @false,
       @null,
       @undefined,

      choice("+=", "-=", "*=", "/="),
      @expression))

    ternary: -> prec(-1, seq(
      @expression, "?", @expression, ":", @expression))

    bool_op: -> choice(
      prec(4, seq("!", @expression)),
      prec(2, seq(@expression, "&&", @expression)),
      prec(1, seq(@expression, "||", @expression)))

    bitwise_op: -> choice(
      prec(13, seq(@expression, ">>", @expression)),
      prec(13, seq(@expression, "<<", @expression)),
      prec(12, seq(@expression, "&", @expression)),
      prec(11, seq(@expression, "|", @expression)))

    comma_op: -> prec(-3, seq(
      @expression, ",", @expression))

    math_op: -> choice(
      prec(14, seq("-", @expression)),
      prec(14, seq("+", @expression)),
      prec(14, seq(@expression, "++")),
      prec(14, seq(@expression, "--")),
      prec(11, seq(@expression, "+", @expression)),
      prec(11, seq(@expression, "-", @expression)),
      prec(12, seq(@expression, "*", @expression)),
      prec(12, seq(@expression, "/", @expression)))

    rel_op: -> choice(
      prec(10, seq(@expression, "<", @expression)),
      prec(10, seq(@expression, "<=", @expression)),
      prec(10, seq(@expression, "==", @expression)),
      prec(10, seq(@expression, "===", @expression)),
      prec(10, seq(@expression, "!=", @expression)),
      prec(10, seq(@expression, "!==", @expression)),
      prec(10, seq(@expression, ">=", @expression)),
      prec(10, seq(@expression, ">", @expression)))

    type_op: -> choice(
      prec(14, seq(keyword("typeof"), @expression)),
      prec(12, seq(@expression, keyword("instanceof"), @expression)),
      prec(12, seq(@expression, keyword("in"), @expression)))

    #
    # Primitives


terminator = ->
  choice(";", sym("_line_break"))

PREC =
  COMMA: -1,
  ASSIGN: 0,
  TERNARY: 1,
  OR: 2,
  AND: 3,
  PLUS: 4,
  REL: 5,
  TIMES: 6,
  TYPEOF: 7,
  NOT: 8,
  NEG: 9,
  INC: 10,
  CALL: 11,
  NEW: 12,
  MEMBER: 13

module.exports = grammar
  name: 'javascript',
