Is the following good grammar for Nearley.js? It describes logical expressions with variables, negation, conjunction and parentheses.
It's a bit convoluted (?), but I didn't know other way how to make precedence work.
expression -> _ conjunction _ {% function(d) { return d[1] } %}
# Parentheses
parens ->
"(" _ conjunction _ ")" {% function(d) { return d[2] } %}
| variable {% id %}
# Negations
negation ->
"~" _ parens {% function(d) { return {negation: [d[2]]} } %}
| parens {% id %}
# Conjunctions
conjunction ->
conjunction _ "/\\" _ negation {% function(d) { return {conjunction: [d[0], d[4]]} } %}
| negation {% id %}
# Variables
variable -> [A-Z] {% function(d) { return {variable: d} } %}
_ -> [\s]:* {% function(d) { return null } %}