Class TagChunk
java.lang.Object
org.antlr.v4.runtime.tree.pattern.Chunk
org.antlr.v4.runtime.tree.pattern.TagChunk
Represents a placeholder tag in a tree pattern. A tag can have any of the
following forms.
expr
: An unlabeled placeholder for a parser ruleexpr
.ID
: An unlabeled placeholder for a token of typeID
.e:expr
: A labeled placeholder for a parser ruleexpr
.id:ID
: A labeled placeholder for a token of typeID
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
tag
This is the backing field forgetTag()
. -
label
This is the backing field forgetLabel()
.
-
-
Constructor Details
-
TagChunk
Construct a new instance ofTagChunk
using the specified tag and no label.- Parameters:
tag
- The tag, which should be the name of a parser rule or token type.- Throws:
IllegalArgumentException
- iftag
isnull
or empty.
-
TagChunk
Construct a new instance ofTagChunk
using the specified label and tag.- Parameters:
label
- The label for the tag. If this isnull
, theTagChunk
represents an unlabeled tag.tag
- The tag, which should be the name of a parser rule or token type.- Throws:
IllegalArgumentException
- iftag
isnull
or empty.
-
-
Method Details
-
getTag
Get the tag for this chunk.- Returns:
- The tag for the chunk.
-
getLabel
Get the label, if any, assigned to this chunk.- Returns:
- The label assigned to this chunk, or
null
if no label is assigned to the chunk.
-
toString
This method returns a text representation of the tag chunk. Labeled tags are returned in the formlabel:tag
, and unlabeled tags are returned as just the tag name.
-