ANTLR Language Rules
Specifies conditions for selecting symbols from ANTLR AST nodes.
Rules apply per language to extract symbol values matching defined criteria.
Options
Specify the options below to configure multiple ANTLR language rules:
| Name | Description | Category |
|---|---|---|
| antlrRuleLang | Lang to apply rule selector to | Rule |
| antlrRuleName | Grammar rule to apply this selector to | Rule |
| antlrRuleContext | Context to assign to symbols collected from this selector | Rule |
| antlrRuleRecursive | Sets whether to collect symbols from sub-nodes | Capture |
| antlrRuleSubRule | Rule name to matched for any direct children of the current AST node for which extend its 'capture' behavior | Capture |
| antlrRuleCapture | Symbols values to capture from the current AST node. Possible: [literalsOnly,allSymbols,allSymbolsIfMatchCond,literalsIfMatchCond] | Capture |
| antlrRuleTag | A pattern to match to apply this rule's tag | Tag |
| antlrRuleCondition | A pattern to match against the current AST node value to set 'antlrRuleTag' | Tag |
| antlrRuleIfTag | Tag value to compare against the 'tag' value that | Tag |
Rule
antlrRuleLang
Lang to apply rule selector to.
| Type | Required | Category |
|---|---|---|
| String | ✔ | Rule |
Specifies the name of the antlrLang this rule selector will apply to (e.g., 'cpp').
antlrRuleName
Grammar rule to apply this selector to.
| Type | Required | Category |
|---|---|---|
| String | ✔ | Rule |
Specifies the rule within the target ANTLR grammar (e.g., 'enumerator') to apply this selector to.
antlrRuleContext
Context to assign to symbols collected from this selector.
| Type | Required | Category |
|---|---|---|
| String | ✔ | Rule |
Sets the source context to assign any symbols collected using this this selector. For possible values, see symbol contexts.
Capture
antlrRuleRecursive
Sets whether to collect symbols from sub-nodes.
| Type | Required | Category |
|---|---|---|
| String | ✔ | Capture |
Sets whether to collect symbol values from child nodes of an ANTLR AST node selected by this rule.
antlrRuleSubRule
Rule name to matched for any direct children of the current AST node for which extend its 'capture' behavior.
| Type | Default | Category |
|---|---|---|
| String | "" | Capture |
Sets an optional rule name that, if matched for any direct children
of the current AST node will extend the antlrRuleCapture behavior
for this node to its child node as well. This option enables
capturing symbol values from a target node based on the name of its direct parent.
antlrRuleCapture
Symbols values to capture from the current AST node. Possible: [literalsOnly,allSymbols,allSymbolsIfMatchCond,literalsIfMatchCond].
| Type | Required | Category |
|---|---|---|
| String | ✔ | Capture |
Controls which values to capture from an AST node matching this rule. Possible values:
- literalsOnly: capture only string literals (e.g., 'ERROR', "hello world")
- allSymbols: capture all symbols, both literal (e.g., "hello") and non-quoted (e.g., 'MyClass', 'foo') values
- allSymbolsIfMatchCond: capture all symbols if this selector's
antlrRuleIfTagequals the current tag. - literalsIfMatchCond: capture only literal symbols if this selector's
antlrRuleIfTagequals the current tag.
Tag
antlrRuleTag
A pattern to match to apply this rule's tag.
| Type | Default | Category |
|---|---|---|
| String | "" | Tag |
Specifies a string value to set as the current ANTLR node tag and its children if the antlrRuleCondition pattern matches the current node.
If 'antlrRuleCondition' is set, this value is required.
antlrRuleCondition
A pattern to match against the current AST node value to set 'antlrRuleTag'.
| Type | Default | Category |
|---|---|---|
| String | "" | Tag |
Sets an optional pattern to match against either the rule name or the text value of the ANTLR AST node.
If the pattern is a match, antlrRuleTag is set as the current tag value for
the current node or its children.
Any children whose ifTag matches the current tag
and antlrRuleCapture will capture their values based on their antlrRuleCapture is
set to 'allSymbolsIfMatchCond' or 'literalsIfMatchCond'.
antlrRuleIfTag
Tag value to compare against the 'tag' value that.
| Type | Default | Category |
|---|---|---|
| String | "" | Tag |
Specifies a string value to compare for the current node against the tag value set by its direct/indirect parent.
If the current tag set by a parent node value is equal to the current node's
antlrRuleIfTag value, the allSymbolsIfMatchCond and literalsIfMatchCond
literal capture values below are triggered based on whether the node's value is literal (i.e., in quotations).
For example, in the Python ANTLR rule-set, tagging enables a class that has
an Enum child to select left-side statement expressions
(i.e., its enum literals), but skip them for any other non-enum class.
This module is defined in rules/module.yaml.