public final class ParserUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BRACKET_OP
A bracket operator.
|
static java.lang.String |
DECREMENT_OP
A decrement operator (--);
|
static java.lang.String |
DEPRECATED_ANNOTATION
Annotation
@Deprecated . |
static java.lang.String |
DEREFERENCE_OP
A dereference operator.
|
static java.lang.String |
DISABLED_ANNOTATION
Annotation
@Disabled . |
static java.lang.String |
DIVIDE
Division operator (/).
|
static java.lang.String |
ELLIPSIS
Ellipsis used to declare variadic parameters.
|
static java.lang.String |
EXTENSION_METHOD_ANNOTATION
Annotation
@ExtensionMethod . |
static java.lang.String |
INCREMENT_OP
An increment operator (++).
|
static java.lang.String |
META_ANNOTATION
Annotation
@Meta . |
static java.lang.String |
MINUS
A minus operator (-);
|
static java.lang.String |
MODULO
Remainder operator (%).
|
static java.lang.String |
MULTIPLY
A multiplication operator (*).
|
static java.lang.String |
PLUS
A plus operator (+).
|
static java.lang.String |
POWER
Power operator (**).
|
static java.lang.String |
REFERENCE_OP
A reference operator.
|
static java.lang.String |
SIDE_EFFECT_ANNOTATION
Annotation
@SideEffect . |
static java.lang.String |
STATUS_ANNOTATION
Annotation
@Status . |
static java.lang.String |
SUPER
"super" keyword
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
createLocalDateLiteral(java.time.LocalDate localDate)
Creates a local date literal.
|
static java.lang.String |
createLocalDateTimeLiteral(java.time.LocalDateTime localDateTime)
Creates a local date time literal.
|
static java.lang.String |
createStringLiteral(java.lang.String string)
Creates a string literal which has the value as a given string.
|
static java.lang.String |
createSymbolLiteral(java.lang.String string)
Creates a symbol literal which has the value as a given string.
|
static java.lang.String |
encodeIdentifier(java.lang.String id)
Encodes the given string as an identifier.
|
static Type |
findCommonExpressionSupertype(java.util.Collection<? extends Expression> expressions)
Returns the most specific common supertype of given expressions.
|
static java.util.Set<java.lang.String> |
getAllKeywords()
Returns a set of all keywords (both language and reserved).
|
static java.util.Set<java.lang.String> |
getAnnotationKeywords()
Returns a set of annotation keywords.
|
static ASTRange |
getASTRange(org.antlr.runtime.tree.Tree tree)
Returns the AST range of the given tree.
|
static int |
getBeginIndex(org.antlr.runtime.CommonToken token)
Returns start index of the token in the underlying source.
|
static int |
getBeginIndex(org.antlr.runtime.tree.Tree tree)
Returns start index of the tree in the underlying source.
|
static int |
getEndIndex(org.antlr.runtime.CommonToken token)
Returns end index (exclusive) of the token in the underlying source.
|
static int |
getEndIndex(org.antlr.runtime.tree.Tree tree)
Returns end index (exclusive) of the tree in the underlying source.
|
static java.util.Set<java.lang.String> |
getLanguageKeywords()
Returns a set of language keywords.
|
static int |
getLine(org.antlr.runtime.CommonToken token)
Returns the line number.
|
static int |
getLine(org.antlr.runtime.tree.Tree tree)
Returns the line number.
|
static LocalVarRange |
getLocalVarRange(org.antlr.runtime.tree.Tree tree) |
static ClassType |
getMethodDeclarationType(FunctionSignature method,
ClassType classType)
Returns the type where the method is declared.
|
static ClassType |
getReferencedClassType(Type type)
If the given type is a class type or a reference to a class type,
that class type is returned.
|
static java.util.Set<java.lang.String> |
getReservedKeywords()
Returns a set of reserved language keywords.
|
static boolean |
isEmptyExpression(java.lang.String source)
Returns
true if the given expression is null ,
or an empty string, or a string containing only whitespaces or comments. |
static boolean |
isLanguageIdentifier(java.lang.String id)
Returns true if the given string is a language identifier and does not have to be quoted in
expressions.
|
static java.lang.String |
parseIdentifier(java.lang.String text)
Parses the given text, assuming it is an identifier.
|
static java.lang.String |
parseIdentifier(org.antlr.runtime.tree.Tree tree)
Parses identifier.
|
static java.util.List<java.lang.String> |
parseIdentifierList(java.lang.String string)
Parses an identifier list from a string.
|
static java.util.List<IdentifierAst> |
parseIdentifierListAst(java.lang.String string)
Parses an identifier list from a string.
|
static java.util.List<java.lang.String> |
parseIdentifierPath(java.lang.String string)
Parses an identifier path from a given string.
|
static java.util.List<java.lang.String> |
parseIdentifierPath(org.antlr.runtime.tree.Tree tree)
Parses an identifier path from the given ANTLR tree.
|
static Decimal |
parseIntegerLiteral(java.lang.String str)
Parser a given string assuming it is an integer literal.
|
static java.time.LocalDate |
parseLocalDateLiteral(java.lang.String text)
Parses a given local date literal.
|
static java.time.LocalDateTime |
parseLocalDateTimeLiteral(java.lang.String text)
Parses a given local date time literal.
|
static java.util.Map<java.lang.String,java.lang.String> |
parseMetadata(org.antlr.runtime.tree.Tree tree,
Errors errors)
Parses the metadata annotation.
|
static java.util.List<QID> |
parseQualifiedIdentifierList(java.lang.String string)
Parses a qualified identifier list from a string.
|
static java.util.List<QIDAst> |
parseQualifiedIdentifierListAst(java.lang.String string)
Parses a qualified identifier list from a string.
|
static java.lang.String |
parseStringLiteral(java.lang.String text)
Parses a string literal.
|
static void |
transform(org.antlr.runtime.tree.CommonTree tree)
Prepares an expression tree to be parsed.
|
static void |
updateTokenRanges(org.antlr.runtime.tree.CommonTree tree)
Updates the token ranges (start, stop, line) recursively.
|
public static final java.lang.String DEPRECATED_ANNOTATION
@Deprecated
.public static final java.lang.String DISABLED_ANNOTATION
@Disabled
.public static final java.lang.String EXTENSION_METHOD_ANNOTATION
@ExtensionMethod
.public static final java.lang.String STATUS_ANNOTATION
@Status
.public static final java.lang.String SIDE_EFFECT_ANNOTATION
@SideEffect
.public static final java.lang.String META_ANNOTATION
@Meta
.public static final java.lang.String ELLIPSIS
public static final java.lang.String BRACKET_OP
public static final java.lang.String REFERENCE_OP
public static final java.lang.String DEREFERENCE_OP
public static final java.lang.String PLUS
public static final java.lang.String MINUS
public static final java.lang.String MULTIPLY
public static final java.lang.String DIVIDE
public static final java.lang.String MODULO
public static final java.lang.String POWER
public static final java.lang.String INCREMENT_OP
public static final java.lang.String DECREMENT_OP
public static final java.lang.String SUPER
public static java.util.Set<java.lang.String> getLanguageKeywords()
public static java.util.Set<java.lang.String> getReservedKeywords()
public static java.util.Set<java.lang.String> getAllKeywords()
public static java.util.Set<java.lang.String> getAnnotationKeywords()
public static java.lang.String createStringLiteral(java.lang.String string)
string
- public static java.lang.String createSymbolLiteral(java.lang.String string)
string
- public static java.lang.String parseStringLiteral(java.lang.String text) throws ValidationException
text
- ValidationException
public static Decimal parseIntegerLiteral(java.lang.String str)
str
- public static java.lang.String createLocalDateLiteral(java.time.LocalDate localDate)
localDate
- public static java.time.LocalDate parseLocalDateLiteral(java.lang.String text) throws ValidationException
text
- ValidationException
public static java.lang.String createLocalDateTimeLiteral(java.time.LocalDateTime localDateTime)
localDateTime
- public static java.time.LocalDateTime parseLocalDateTimeLiteral(java.lang.String text) throws ValidationException
text
- ValidationException
public static java.lang.String encodeIdentifier(java.lang.String id)
id
- java.lang.NullPointerException
- if the id
is nullpublic static boolean isLanguageIdentifier(java.lang.String id)
id
- public static java.lang.String parseIdentifier(java.lang.String text)
text
- public static java.lang.String parseIdentifier(org.antlr.runtime.tree.Tree tree)
tree
- public static boolean isEmptyExpression(java.lang.String source)
true
if the given expression is null
,
or an empty string, or a string containing only whitespaces or comments.source
- true
if the given expression is emptypublic static java.util.List<java.lang.String> parseIdentifierPath(java.lang.String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifiersjava.lang.NullPointerException
- if the string
is nullpublic static java.util.List<java.lang.String> parseIdentifierPath(org.antlr.runtime.tree.Tree tree)
tree
- public static java.util.List<java.lang.String> parseIdentifierList(java.lang.String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static java.util.List<IdentifierAst> parseIdentifierListAst(java.lang.String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static java.util.List<QID> parseQualifiedIdentifierList(java.lang.String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static java.util.List<QIDAst> parseQualifiedIdentifierListAst(java.lang.String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static ClassType getReferencedClassType(Type type)
null
.type
- public static Type findCommonExpressionSupertype(java.util.Collection<? extends Expression> expressions)
expressions
- public static void transform(org.antlr.runtime.tree.CommonTree tree)
tree
- public static void updateTokenRanges(org.antlr.runtime.tree.CommonTree tree)
tree
- public static int getBeginIndex(org.antlr.runtime.tree.Tree tree)
tree
- public static int getBeginIndex(org.antlr.runtime.CommonToken token)
token
- public static int getEndIndex(org.antlr.runtime.tree.Tree tree)
tree
- public static int getEndIndex(org.antlr.runtime.CommonToken token)
token
- public static int getLine(org.antlr.runtime.tree.Tree tree)
tree
- public static int getLine(org.antlr.runtime.CommonToken token)
token
- public static ASTRange getASTRange(org.antlr.runtime.tree.Tree tree)
tree
- public static LocalVarRange getLocalVarRange(org.antlr.runtime.tree.Tree tree)
tree
- public static ClassType getMethodDeclarationType(FunctionSignature method, ClassType classType)
method
- classType
- public static java.util.Map<java.lang.String,java.lang.String> parseMetadata(org.antlr.runtime.tree.Tree tree, Errors errors)
tree
- errors
- Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.