Wed, 19 Feb 2020 08:25:00 +0100
I’ve been considering an issue for over a year now: specialized syntax.
Of course, uniformity is very valuable, but there are situations in which
even the flexible xparse may result in an unfriendly interface. At those
times, it can be tempting to use significantly different syntax.
As an example: I’ve been toying with typesetting BNF-style grammars.
I prefer to have a lot of control over the typesetting, so I’ll use
more verbose syntax, if it is necessary for that control.
Here are some of my thoughts on the BNF example:
- Using standard xparse-style commands and environments is robust,
but can be verbose and cluttered.
- Defining an environment that sets up active characters to emulate
traditional BNF syntax is very concise, but comes at the cost of
delimited arguments and catcode madness.
- Traditional BNF syntax could be read verbatim, then processed using a
combination of tl and regex manipulations. This makes the syntax concise
and is (perhaps) less dangerous than active characters but risks making
the implementation complicated and slow.
- Another consideration is special TeX’s characters: they could be read
verbatim, but that limits the kind of syntax that can be used, or they
could be escaped, using a regex or even a simple tl replacement.
These considerations apply to any situation where general syntax could be
replaced with something more specialized and concise. I’m very interested
to know what thoughts people have on this matter.