Class TagChunk
- java.lang.Object
-
- org.antlr.v4.runtime.tree.pattern.Chunk
-
- org.antlr.v4.runtime.tree.pattern.TagChunk
-
class TagChunk extends Chunk
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 Modifier and Type Field Description private java.lang.String
label
This is the backing field forgetLabel()
.private java.lang.String
tag
This is the backing field forgetTag()
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getLabel()
Get the label, if any, assigned to this chunk.java.lang.String
getTag()
Get the tag for this chunk.java.lang.String
toString()
This method returns a text representation of the tag chunk.
-
-
-
Field Detail
-
tag
private final java.lang.String tag
This is the backing field forgetTag()
.
-
label
private final java.lang.String label
This is the backing field forgetLabel()
.
-
-
Constructor Detail
-
TagChunk
public TagChunk(java.lang.String tag)
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:
java.lang.IllegalArgumentException
- iftag
isnull
or empty.
-
TagChunk
public TagChunk(java.lang.String label, java.lang.String tag)
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:
java.lang.IllegalArgumentException
- iftag
isnull
or empty.
-
-
Method Detail
-
getTag
public final java.lang.String getTag()
Get the tag for this chunk.- Returns:
- The tag for the chunk.
-
getLabel
public final java.lang.String 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
public java.lang.String 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.- Overrides:
toString
in classjava.lang.Object
-
-