public final class ParserUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BRACKET_OP
A bracket operator.
|
static String |
DECREMENT_OP
A decrement operator (--);
|
static String |
DEPRECATED_ANNOTATION
Annotation
@Deprecated . |
static String |
DEREFERENCE_OP
A dereference operator.
|
static String |
DISABLED_ANNOTATION
Annotation
@Disabled . |
static String |
DIVIDE
Division operator (/).
|
static String |
ELLIPSIS
Ellipsis used to declare variadic parameters.
|
static String |
EXTENSION_METHOD_ANNOTATION
Annotation
@ExtensionMethod . |
static String |
INCREMENT_OP
An increment operator (++).
|
static String |
META_ANNOTATION
Annotation
@Meta . |
static String |
MINUS
A minus operator (-);
|
static String |
MODULO
Remainder operator (%).
|
static String |
MULTIPLY
A multiplication operator (*).
|
static String |
PLUS
A plus operator (+).
|
static String |
POWER
Power operator (**).
|
static String |
REFERENCE_OP
A reference operator.
|
static String |
SIDE_EFFECT_ANNOTATION
Annotation
@SideEffect . |
static String |
STATUS_ANNOTATION
Annotation
@Status . |
static String |
SUPER
"super" keyword
|
Modifier and Type | Method and Description |
---|---|
static String |
createLocalDateLiteral(java.time.LocalDate localDate)
Creates a local date literal.
|
static String |
createStringLiteral(String string)
Creates a string literal which has the value as a given string.
|
static String |
createSymbolLiteral(String string)
Creates a symbol literal which has the value as a given string.
|
static String |
encodeIdentifier(String id)
Encodes the given string as an identifier.
|
static Type |
findCommonExpressionSupertype(Collection<? extends Expression> expressions)
Returns the most specific common supertype of given expressions.
|
static Set<String> |
getAllKeywords()
Returns a set of all keywords (both language and reserved).
|
static Set<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 Set<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 Set<String> |
getReservedKeywords()
Returns a set of reserved language keywords.
|
static boolean |
isEmptyExpression(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(String id)
Returns true if the given string is a language identifier and does not have to be quoted in
expressions.
|
static String |
parseIdentifier(String text)
Parses the given text, assuming it is an identifier.
|
static String |
parseIdentifier(org.antlr.runtime.tree.Tree tree)
Parses identifier.
|
static List<String> |
parseIdentifierList(String string)
Parses an identifier list from a string.
|
static List<IdentifierAst> |
parseIdentifierListAst(String string)
Parses an identifier list from a string.
|
static List<String> |
parseIdentifierPath(String string)
Parses an identifier path from a given string.
|
static List<String> |
parseIdentifierPath(org.antlr.runtime.tree.Tree tree)
Parses an identifier path from the given ANTLR tree.
|
static Decimal |
parseIntegerLiteral(String str)
Parser a given string assuming it is an integer literal.
|
static java.time.LocalDate |
parseLocalDateLiteral(String text)
Parses a given local date literal.
|
static Map<String,String> |
parseMetadata(org.antlr.runtime.tree.Tree tree,
Errors errors)
Parses the metadata annotation.
|
static List<QID> |
parseQualifiedIdentifierList(String string)
Parses a qualified identifier list from a string.
|
static List<QIDAst> |
parseQualifiedIdentifierListAst(String string)
Parses a qualified identifier list from a string.
|
static String |
parseStringLiteral(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 String DEPRECATED_ANNOTATION
@Deprecated
.public static final String DISABLED_ANNOTATION
@Disabled
.public static final String EXTENSION_METHOD_ANNOTATION
@ExtensionMethod
.public static final String STATUS_ANNOTATION
@Status
.public static final String SIDE_EFFECT_ANNOTATION
@SideEffect
.public static final String META_ANNOTATION
@Meta
.public static final String ELLIPSIS
public static final String BRACKET_OP
public static final String REFERENCE_OP
public static final String DEREFERENCE_OP
public static final String PLUS
public static final String MINUS
public static final String MULTIPLY
public static final String DIVIDE
public static final String MODULO
public static final String POWER
public static final String INCREMENT_OP
public static final String DECREMENT_OP
public static final String SUPER
public static Set<String> getLanguageKeywords()
public static Set<String> getReservedKeywords()
public static Set<String> getAllKeywords()
public static Set<String> getAnnotationKeywords()
public static String createStringLiteral(String string)
string
- public static String createSymbolLiteral(String string)
string
- public static String parseStringLiteral(String text) throws ValidationException
text
- ValidationException
public static Decimal parseIntegerLiteral(String str)
str
- public static String createLocalDateLiteral(java.time.LocalDate localDate)
localDate
- public static java.time.LocalDate parseLocalDateLiteral(String text) throws ValidationException
text
- ValidationException
public static String encodeIdentifier(String id)
id
- NullPointerException
- if the id
is nullpublic static boolean isLanguageIdentifier(String id)
id
- public static String parseIdentifier(String text)
text
- public static String parseIdentifier(org.antlr.runtime.tree.Tree tree)
tree
- public static boolean isEmptyExpression(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 List<String> parseIdentifierPath(String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifiersNullPointerException
- if the string
is nullpublic static List<String> parseIdentifierPath(org.antlr.runtime.tree.Tree tree)
tree
- public static List<String> parseIdentifierList(String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static List<IdentifierAst> parseIdentifierListAst(String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static List<QID> parseQualifiedIdentifierList(String string) throws ValidationException
string
- ValidationException
- if the string
is not a valid list of identifierspublic static List<QIDAst> parseQualifiedIdentifierListAst(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(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
- Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.