doc/faq/actions-preds.md
raw| 1 | # Actions and semantic predicates |
| 2 | |
| 3 | ## How do I test if an optional rule was matched? |
| 4 | |
| 5 | For optional rule references such as the initialization clause in the following |
| 6 | |
| 7 | ``` |
| 8 | decl : 'var' ID (EQUALS expr)? ; |
| 9 | ``` |
| 10 | |
| 11 | testing to see if that clause was matched can be done using `$EQUALS!=null` or `$expr.ctx!=null` where `$expr.ctx` points to the context or parse tree created for that reference to rule expr. |