Class JavaccTokenDocument.TokenDocumentBehavior
java.lang.Object
net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument.TokenDocumentBehavior
- Enclosing class:
JavaccTokenDocument
Overridable configuration of a token document.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateToken
(JavaccTokenDocument self, int kind, CharStream cs, @Nullable String image) Creates a new token with the given kind.final @NonNull String
describeKind
(int kind) Returns a string that describes the token kind.protected @Nullable String
describeKindImpl
(int kind) Describe the given kind.translate
(TextDocument text) Translate the escapes of the source document.boolean
Returns true if the lexer should accumulate the image of MORE tokens into the StringBuilder jjimage.
-
Field Details
-
DEFAULT
-
-
Constructor Details
-
TokenDocumentBehavior
-
-
Method Details
-
useMarkSuffix
public boolean useMarkSuffix()Returns true if the lexer should accumulate the image of MORE tokens into the StringBuilder jjimage. This is useless in our current implementations, because the image of tokens can be cut out using text coordinates, so doesn't need to be put into a separate string. The default returns false, which makesCharStream.appendSuffix(StringBuilder, int)
a noop. -
translate
Translate the escapes of the source document. The default implementation does not perform any escaping.- Parameters:
text
- Source doc- Throws:
MalformedSourceException
- See Also:
-
describeKind
Returns a string that describes the token kind.- Parameters:
kind
- Kind of token- Returns:
- A descriptive string
-
describeKindImpl
Describe the given kind. If this returns a non-null value, then that's whatdescribeKind(int)
will use. Otherwise a default implementation is used.An implementation typically uses the JavaCC-generated array named
<parser name>Constants.tokenImage
. Remember to check the bounds of the array.- Parameters:
kind
- Kind of token- Returns:
- A descriptive string, or null to use default
-
createToken
public JavaccToken createToken(JavaccTokenDocument self, int kind, CharStream cs, @Nullable String image) Creates a new token with the given kind. This is called back to by JavaCC-generated token managers (jjFillToken). Note that a created token is not guaranteed to end up in the final token chain.- Parameters:
kind
- Kind of the tokencs
- Char stream of the file. This can be used to get text coordinates and the imageimage
- Shared instance of the image token. If this is non-null, then no call toCharStream.getTokenImage()
should be issued.- Returns:
- A new token
-