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 TypeMethodDescriptionvoidcheckForParameters(AST parsed) protected Lexer<TokenTypes>Lexes source with theTokenTypes.tokens().Parses the given string in to anExpression.parseAllowParameters(String source) A version ofparse(String)that allows the expression to containParameterTokens.parseExpression(Lexer<TokenTypes> lexer) parseFunctionExpression(Lexer<TokenTypes> lexer) Convenience method to catch any exceptions from parsing the expression and return them as aResultOrProblemstatic ResultOrProblems<PipelineDeclaration>parseParameterizedPipeline(Resource source) Convenience function to parse a parameterized pipeline from the given ResourceparsePipeline(String pipelineSource) Parses a pipeline from the DSLstatic ResultOrProblems<PipelineDeclaration>parsePipeline(Resource source) Convenience function to parse a pipeline (no parameters allowed) from the given ResourceparsePipelineAllowParameters(String pipelineSource) Parses a pipeline from the DSL, allowing $parameters to appear in the sauceparsePropertyExpression(Lexer<TokenTypes> lexer, Optional<Expression> receiver) static ExpressionparseString(String source) Convenience form ofnew ExpressionParser().parse(source)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) -
parseParameterizedPipeline
Convenience function to parse a parameterized pipeline from the given Resource
-
parsePipeline
Convenience function to parse a pipeline (no parameters allowed) from the given Resource
-
parse
Parses the given string in to an
Expression. SeeparseAllowParameters(String)for a version that acceptsParameterTokens- Returns:
- an Expression from the given string
- Throws:
ParseException- if source couldn't be parsed or if the expression containsParameterTokens.LexerException- if source couldn't be lexed in to tokens
-
parseOr
Convenience method to catch any exceptions from parsing the expression and return them as a
ResultOrProblem -
parseAllowParameters
A version of
parse(String)that allows the expression to containParameterTokens.- Parameters:
source-- Returns:
- Expression
-
checkForParameters
- Throws:
ParseException- if the given expression contains $foo style parameters
-
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 pipeline from the DSL
- Parameters:
pipelineSource-- Returns:
- pipeline declaration
-
parsePipelineAllowParameters
Parses a pipeline from the DSL, allowing $parameters to appear in the sauce
- Parameters:
pipelineSource-- Returns:
- pipeline declaration
-