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(Source source) Parses aPipelineDeclarationfrom a Source objectparsePipeline(Resource resource) Parses aPipelineDeclarationfrom a Resource object, catching io exceptions and returning them as problems insteadstatic PipelineDeclarationparsePipelineString(String source) Convenience function to parse a pipeline for tests where you aren't expecting errorsparsePropertyExpression(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
-
parsePipelineString
Convenience function to parse a pipeline for tests where you aren't expecting errors
-
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
Parses a
PipelineDeclarationfrom a Resource object, catching io exceptions and returning them as problems instead -
parsePipeline
Parses a
PipelineDeclarationfrom a Source object
-