I am maintaining a mode for a programming language with... let's say "annoying" syntax constructs.
For example, the angle brackets (no idea if it is the correct word)
<
and >
are parentheses. However, the word ->
is also a valid
token, does not count as a closing parenthesis, and to top it all,
should only occur inside a pair of <
and >
.
If I understand correctly, there is no way to get emacs to recognise this using only syntax tables, is that correct?
Hence the question: the mode is using smie
for what cannot be done
with syntax tables, and smie is also the
canonical answer to define multi-character parens. So I guess that I will have to get smie to replace the syntax table for this pair of parentheses.
The question is: what does need to be set up in smie, in order to replace syntax table features for a particular paren pair?
The question is motivated by the manual: it is advised to let syntax tables do their job whenever possible. Hence, I'm afraid that with a naive set-up, I will run into problems later, or worse, that it will cause problems behind the scenes.
What I can think of (aka the "naive set-up" mentioned above):
- removing the paren category for characters
<
and>
in the syntax table; - adding
("<" whatever ">")
in the BNF grammar; - making the lexer recognize the token
<
(resp>
) as"<"
(resp.">"
) instead of""
.
Is it enough?
And, in case it would actually be, bonus question: is there any good reason to leave the handling of sexps to the syntax table instead of smie?