You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--string-token and --text-token for the Haskell backend
--jlex and --antlr4 for the Java backend
should not be used together. Currently, bnfc always silently takes the first (leftmost) one. Not sure what the best practice is, but this behavior should at least be noticed in docs.
I think taking the last (rightmost) is what most command-line tools do.
Nowadays, when I design a new command-line tool, I add a --dry-run mode that explains what the tool would do. This includes a description of what it understood it should do, in particular, which options it is using. So one can use this mode to check how the tool understands a specific invocation, e.g. one with conflicting options.
Also, I checked some other tools and found it is common to take the last one of exclusive options:
GCC:
For optimization levels, it uses the last one. See Optimize-Options.
If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.
For warning options, it also takes the last one if the options have the same specificity (although things become much more complex with different specificities). See Warning-Options.
The combined effect of positive and negative forms is that more specific options have priority over less specific ones, independently of their position in the command line. For options of the same specificity, the last one takes effect.
Activity
andreasabel commentedon Mar 14, 2026
I think taking the last (rightmost) is what most command-line tools do.
Nowadays, when I design a new command-line tool, I add a
--dry-runmode that explains what the tool would do. This includes a description of what it understood it should do, in particular, which options it is using. So one can use this mode to check how the tool understands a specific invocation, e.g. one with conflicting options.Commelina commentedon Mar 14, 2026
Yes,
--dry-runis very useful.Also, I checked some other tools and found it is common to take the last one of exclusive options:
GCC:
For optimization levels, it uses the last one. See Optimize-Options.
For warning options, it also takes the last one if the options have the same specificity (although things become much more complex with different specificities). See Warning-Options.
GHC: It also takes the last one. See Using GHC.
Agda: There is an issue for it.