Class ExpressionParser
Methods for parsing PipelineDeclarations and Expressions from a source string.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EnumSet<TokenTypes>Used withConditionalParsestatic final ExpressionParserstatic final EnumSet<TokenTypes>Used withConditionalParsestatic final EnumSet<TokenTypes>The list of tokens that typically start any expressionstatic final EnumSet<TokenTypes>All of the things that can be inside aConstant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Lexer<TokenTypes>Lexes source with theTokenTypes.tokens().Parses the given string in to anExpression.parseExpression(Lexer<TokenTypes> lexer) parseFunctionExpression(Lexer<TokenTypes> lexer) static Map<String,Expression> Parameter-map friendly of parseString.parsePipeline(String pipelineSource) Deprecated.parsePipeline(Source pipelineSource) Parses a pipeline from the DSLstatic ResultOrProblems<PipelineDeclaration>parsePipeline(Resource source) Convenience function to parse a pipeline (no parameters allowed) from the given ResourceparsePropertyExpression(Lexer<TokenTypes> lexer, Optional<Expression> receiver) static ExpressionparseString(String source) Convenience form ofnew ExpressionParser().parse(source).get()used for tests and cases where you don't expect parsing to throw errors (e.g.toList(Expression expr) Return a version of the given expression as aListDeclaration.toStruct(Expression expr) Return a version of the given expression as a struct.
-
Field Details
-
INSTANCE
-
IDENTIFIERS
Used with
ConditionalParse -
KEY_IDENTIFIERS
Used with
ConditionalParse -
LITERALS
All of the things that can be inside a
Constant -
LEADING_TOKENS
The list of tokens that typically start any expression
NB this is 'derived', which kind of sucks, but it's just for debugging/error messages
-
-
Constructor Details
-
ExpressionParser
public ExpressionParser()
-
-
Method Details
-
parseString
Convenience form of
new ExpressionParser().parse(source).get()used for tests and cases where you don't expect parsing to throw errors (e.g. source isn't from the user) -
parseMap
Parameter-map friendly of parseString.
- Returns:
- a map of parsed expressions
-
parsePipeline
Convenience function to parse a pipeline (no parameters allowed) from the given Resource
-
parse
Parses the given string in to an
Expression.- Returns:
- an Expression from the given string, or a problem if it failed
-
toStruct
Return a version of the given expression as a struct. If it's already a struct declaration it is returned as is, otherwise a simple anonymous struct declaration is put around it.
-
toList
Return a version of the given expression as a
ListDeclaration. If expression is a ListDeclaration it is returned as is, otherwise a ListDeclaration is returned containing expression as the single item. -
lex
Lexes source with the
TokenTypes.tokens().- Parameters:
source- to lex
-
parseExpression
-
parseFunctionExpression
-
parsePropertyExpression
public PropertyAccess parsePropertyExpression(Lexer<TokenTypes> lexer, Optional<Expression> receiver) -
parsePipeline
Deprecated.useparsePipeline(Source)instead. -
parsePipeline
Parses a pipeline from the DSL
- Parameters:
pipelineSource-- Returns:
- pipeline declaration
-
parsePipeline(Source)instead.