javascript - Ambiguous grammar when parsing boolean expressions with Peg.js -
    i'm writing parser generates abstract syntax tree boolean expressions.   i have following peg.js grammar supports ^  , ∨ , &  , |  respectively:   start   = operation  // optional whitespace _  = [ \t\r\n]*  operation "operation"   = "("? _ left:(operand / operation) _ operator:operator _ right:(operand / operation) _  ")"?   {     return {       operation: operator,       between: [ left, right ]     };   }  operator "operator"   = operator:["&"|"|"]     {     return operator;   }  operand "operand"   = operand:[a-z]   {      return { operand: operand };   }   it parses expressions a & b  , a & (b | c) , fails if expression starts operation:   (a | b) & c line 1, column 8: expected end of input " " found.   the expression gets parsed correctly if surround parenthesis:   ((a | b) & c)   my guess peg.js taking (a | b)  operation, instead of operand of parent operation, failing...