Table of Contents

About

Semantic Predicate are boolean expressions that enable or disable the rule that follows.

They are written in the target language making the grammar language dependent

Example

RegularExpressionLiteral : {isRegexPossible()}? '/' RegularExpressionBody '/' RegularExpressionFlags ;

Python

TEXT : {self._input.LA(-1) == ord('[')}? ~[\])]+ ;

where:

  • self._input.LA(-1) get the character before the current one

Usage

  • support different versions of the same language

Documentation / Reference