Lets say I want Calc to understand a TeX formula like $\\int\_a\^b f(x) \\mathrm{d} x$. Clearly, there are many ways to write this, I could have just written "d" instead of "\\mathrm", the integral bounds could be just a single lower index indicating a region, "f(x)" could actually consist of derivatives with the same differential notation as "d x", etc. If I could use Backus-Naur form, I would define a non-terminal like
INTEGRAL := "\\\\int" REGION INTEGRAND DIFFERENTIAL DUMMY\_VAR
and then individually handle all of these edge cases in each non-terminal. For instance, I could write REGION to accept empty patterns for indefinite integrals, or to accept just a subscript for regions, similarly for DIFFERENTIAL or INTEGRAND. Instead, in Calc, I have to write a messy rewrite rule to just handle the REGION part, and I am not even sure if the INTEGRAND symbol could be implemented since any integrand having terms that look like $\\frac{d f}{d x}$ would prematurely terminate parsing as the denominator would be interpreted as DIFFERENTIAL. It seems to me that Calc is formally incapable of handling these complications, but I may be wrong. Are there ways within calc to implemen the functinality I want? If not, are there libraries that allow me to augment Calc in this way? Failing that, I would be willing to use the Wisent parser generator, but how do I integrate it into Calc?