Class SyntaxParser
java.lang.Object
io.github.syst3ms.skriptparser.parsing.SyntaxParser
Contains the logic for parsing and interpreting single statements, sections and expressions inside of a script.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternType<Boolean> The pattern type representingBooleanstatic final intTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to only return conditional expressionsstatic final PatternElementstatic final ExpressionInfo<ExprBooleanOperators, Boolean> static final Patternstatic final intTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to return any expressions, conditional or notstatic final intTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to only return expressions that are not conditionalstatic final PatternType<Object> The pattern type representingObjectstatic final PatternType<Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<? extends Expression<Boolean>> parseBooleanExpression(String s, int conditional, ParserState parserState, SkriptLogger logger) Parses aboolean expressionfrom the given Stringstatic <T> Optional<? extends ContextExpression<?, ? extends T>> parseContextValue(String toParse, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) parseEffect(String s, ParserState parserState, SkriptLogger logger) Parses a line of code as anEffectstatic <T> Optional<? extends Expression<? extends T>> parseExpression(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) static <T> Optional<? extends Expression<? extends T>> parseListLiteral(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) Parses a list literal expression (of the form..., ... and ...) from the given String andexpected return typestatic <T> Optional<? extends Expression<? extends T>> parseLiteral(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) static Optional<? extends CodeSection> parseSection(FileSection section, ParserState parserState, SkriptLogger logger) Parses a section of a file as aCodeSectionstatic Optional<? extends UnloadedTrigger> parseTrigger(FileSection section, SkriptLogger logger) Parses a section of a file as aTrigger
-
Field Details
-
NOT_CONDITIONAL
public static final int NOT_CONDITIONALTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to only return expressions that are not conditional- See Also:
-
MAYBE_CONDITIONAL
public static final int MAYBE_CONDITIONALTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to return any expressions, conditional or not- See Also:
-
CONDITIONAL
public static final int CONDITIONALTellsparseBooleanExpression(String, int, ParserState, SkriptLogger)to only return conditional expressions- See Also:
-
LIST_SPLIT_PATTERN
-
BOOLEAN_PATTERN_TYPE
The pattern type representingBoolean -
OBJECT_PATTERN_TYPE
The pattern type representingObject -
OBJECTS_PATTERN_TYPE
-
CONTEXT_VALUE_PATTERN
-
EXPRESSION_BOOLEAN_OPERATORS
-
-
Constructor Details
-
SyntaxParser
public SyntaxParser()
-
-
Method Details
-
parseExpression
public static <T> Optional<? extends Expression<? extends T>> parseExpression(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) - Type Parameters:
T- the type of the expression- Parameters:
s- the string to be parsed as an expressionexpectedType- the expected return typeparserState- the current parser statelogger- the logger- Returns:
- an expression that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message.
-
parseBooleanExpression
public static Optional<? extends Expression<Boolean>> parseBooleanExpression(String s, int conditional, ParserState parserState, SkriptLogger logger) Parses aboolean expressionfrom the given String- Parameters:
s- the string to be parsed as an expressionconditional- a constant describing whether the result can be aconditionparserState- the current parser statelogger- the logger- Returns:
- a boolean expression that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message.
- See Also:
-
parseContextValue
public static <T> Optional<? extends ContextExpression<?, ? extends T>> parseContextValue(String toParse, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) - Type Parameters:
T- the type of the context value- Parameters:
toParse- the string to be parsed as a context valueexpectedType- the expected return typeparserState- the current parser statelogger- the logger- Returns:
- an expression that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message.
-
parseListLiteral
public static <T> Optional<? extends Expression<? extends T>> parseListLiteral(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) Parses a list literal expression (of the form..., ... and ...) from the given String andexpected return type- Type Parameters:
T- the type of the list literal- Parameters:
s- the string to be parsed as a list literalexpectedType- the expected return type (must be plural)parserState- the current parser statelogger- the logger- Returns:
- a list literal that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message.
-
parseLiteral
public static <T> Optional<? extends Expression<? extends T>> parseLiteral(String s, PatternType<T> expectedType, ParserState parserState, SkriptLogger logger) - Type Parameters:
T- the type of the literal- Parameters:
s- the string to be parsed as a literalexpectedType- the expected return typeparserState- the current parser statelogger- the logger- Returns:
- a literal that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message.
-
parseEffect
public static Optional<? extends Effect> parseEffect(String s, ParserState parserState, SkriptLogger logger) Parses a line of code as anEffect- Parameters:
s- the line to be parsedparserState- the current parser statelogger- the logger- Returns:
- an effect that was successfully parsed, or null if the string is empty, no match was found or for another reason detailed in an error message
-
parseSection
public static Optional<? extends CodeSection> parseSection(FileSection section, ParserState parserState, SkriptLogger logger) Parses a section of a file as aCodeSection- Parameters:
section- the section to be parsedparserState- the current parser statelogger- the logger- Returns:
- a section that was successfully parsed, or null if the section is empty, no match was found or for another reason detailed in an error message
-
parseTrigger
public static Optional<? extends UnloadedTrigger> parseTrigger(FileSection section, SkriptLogger logger) Parses a section of a file as aTrigger- Parameters:
section- the section to be parsedlogger- the logger- Returns:
- a trigger that was successfully parsed, or null if the section is empty, no match was found or for another reason detailed in an error message
-