MKS Yacc supports a notation which their web site calls "selection preference syntax". It isn't illustrated, but it consists of a token in square brackets, optionally with a caret, and it indicates that a particular token is required to follow, or is required not to follow, the rest of the rules:
non_terminal: TOKEN1 non_terminal2 TOKEN2 [TOKEN3]
non_terminal: TOKEN1 non_terminal2 TOKEN2 [^TOKEN3]
(I'm not clear whether the bracketed item can be a non-terminal. The code I've seen using the notation always uses a token or a couple of space separated tokens, and never a non-terminal.)
Is anyone aware of an alternative Yacc-compatible system (preferably open source) that provides the same support (notation can differ - functionality can't), running on Unix or Linux machines, preferably available in source format?
(MKS Yacc also provides some flexibility in handling errors and adjusting the error behaviour. One way in which that can be used is to treat keywords as identifiers when they are encountered in a position that makes no sense when they are treated as keywords. I was able to retrofit that into byacc
- Berkeley Yacc - but I haven't spent enough time working out how to handle 'selection preferences'.)
See also: Has anyone used the "selection preference" mechanism provided by MKS Yacc?