Since bison-3.0 caret errors are activated by default. Caret output
is a useful feature in many cases, but sometimes it's not helpful.
E.g. when your editor parses the line/column numbers from the output
and automatically jumps to this position, additional caret output is
not needed, and indeed rather wastes space in the list of output
messages.

Of course, you can turn off carets with the option "-fno-caret". But
before you do that, you need a Bison version check, since older
versions don't understand this option and would fail with it. GCC
now also has carets, and to turn them off, you need a different
option ("-fno-diagnostics-show-caret"), and of course a different
version check. Then maybe next year flex will get carets and you
need yet another option and version check, etc. ...

Now, suppose your build runs from a Makefile (which contains various
Bison, gcc, etc. invocations), and you want to use the Makefile from
an arbitrary context (e.g. plain command line where you want carets,
and from the editor where you don't). Now, you have to pass some
variable to the Makefile to tell it whether to do those version
checks and pass the respective options to Bison, GCC, etc. And you
need to do this in every relevant Makefile. This all gets a bit
cumbersome ...

So let me suggest an alternative:

If all programs that support caret output would recognize a common
environment variable (say "NO_CARET_OUTPUT"), all of the above
complications would disappear:

- No version checks are required, since older versions simple ignore
  the variable.

- One doesn't even have to know which programs (Bison, GCC, maybe
  flex etc.) support carets if they use a common variable.

- The Makefiles don't have do to anything since environment
  variables are automatically propagated. Only the editor, i.e. the
  instance that actually knows that carets are not useful there,
  needs to set the variable once. (So not only DRY, but also SOC, to
  drop some TLAs. ;)

Does this seem reasonable? The implementation of such a variable
shouldn't be so difficult (if you like, I can probably make a
patch). Of course, it then would need to be done in GCC (etc.) too,
but since Bison supported carets first AFAIK, I'm starting here ...

Regards,
Frank

Reply via email to