Interface AST

All Known Subinterfaces:
Expression, PipelineAST
All Known Implementing Classes:
BinaryOperation, BracketedExpression, Constant, FunctionCall, FunctionCall.Argument, GenericArgument, InputChain, Lambda, ListDeclaration, ParameterToken, PipelineDeclaration, PropertyAccess, SelectAllExpression, StepChain, StepDeclaration, StepDefinition, StepDefinition.Argument, StepLink, StepReference, StructDeclaration

public interface AST

Minimal amount that all bits of an abstract syntax tree must return TODO could consider moving this (or at least parts of this) to the DSL package?

  • Method Details

    • toSource

      String toSource()
      Returns:
      a string that can be reparsed and will equal this ast, although the original source may not be identical
    • isA

      default <T extends AST> Optional<T> isA(Class<T> type)

      Functional style instanceof method

    • getBoundary

      Optional<Pair<Token,Token>> getBoundary()
      Returns:
      a pair of tokens that represent the start and end of this expression, to be used when giving users information about where errors have occurred. If the expression has been rebuilt then the boundary may be empty or it may be from the original AST. Intended for use in problems to trace errors back to their source.
    • switchType

      default void switchType(Consumer<Expression> ifExpression, Consumer<PipelineAST> ifPipeline)

      Functional if/else helper that emulates case-classes to run different handlers depending on whether this part of the AST belongs to a pipeline (PipelineAST) or an expression (Expression).