smie-bnf->prec2
smie-bnf->prec2 is a compiled Lisp function in `smie.el
'.
(smie-bnf->prec2 BNF &rest RESOLVERS)
Convert the BNF grammar into a prec2 table.
BNF is a list of nonterminal definitions of the form:
(NONTERM RHS1 RHS2 ...)
where each RHS is a (non-empty) list of terminals (aka tokens) or non-terminals.
Not all grammars are accepted:
- an RHS cannot be an empty list (this is not needed, since SMIE allows all
non-terminals to match the empty string anyway).
- an RHS cannot have 2 consecutive non-terminals: between each non-terminal
needs to be a terminal (aka token). This is a fundamental limitation of
the parsing technology used (operator precedence grammar).
Additionally, conflicts can occur:
- The returned prec2 table holds constraints between pairs of
token, and for any given pair only one constraint can be
present, either: T1 < T2, T1 = T2, or T1 > T2.
- A token can either be an `opener' (something similar to an open-paren),
a `closer' (like a close-paren), or `neither' of the two (e.g. an infix
operator, or an inner token like "else").
Conflicts can be resolved via RESOLVERS, which is a list of elements that can
be either:
- a precs table (see `smie-precs->prec2') to resolve conflicting constraints,
- a constraint (T1 REL T2) where REL is one of = < or >.