Class CSTTransformer<T extends JobParameters>

java.lang.Object
io.github.douira.glsl_transformer.cst.transform.ExecutionPlanner<T>
io.github.douira.glsl_transformer.cst.transform.CSTTransformer<T>
Type Parameters:
T - The job parameters type
All Implemented Interfaces:
ParserInterface, Transformer, ParameterHolder<T>, ParameterizedTransformer<T>

public class CSTTransformer<T extends JobParameters> extends ExecutionPlanner<T> implements ParameterizedTransformer<T>, ParserInterface
Implements the execution planner by providing the boilerplate code for setting up an input, a lexer and a parser. The transformation manager is meant to be used to transform many strings and be re-used for many transformation jobs of the same kind. For entirely different jobs a new manager should be created. Common transformations can be shared between them. For printing a tree without transforming it, a manager without and transformations can be used. Creating manager instances isn't costly as ANTLR's parser and lexer instantiation is efficient. The transformation manager also manages job parameters. It has a private field that it stores the job parameters, that are passed to it along with the string to be transformed, during transformation. This means that the entire chain of objects that are involved in the transformation have to be generic in order to be able to make use of job parameters. If no job parameter is used the Void type can be used and object constructors can use the default parameter <> which assigns an Object. This is fine as long as the anonymous class being constructed doesn't need to use the job parameters. If it does need to use them, the whole chain of participating objects needs to be properly parameterized. (transformation manager -> transformation -> transformation phase)
  • Constructor Details

    • CSTTransformer

      public CSTTransformer(Transformation<T> rootTransformation, boolean throwParseErrors)
      Creates a new transformation manager with a given root transformation and parse error throwing behavior.
      Parameters:
      rootTransformation - The root transformation to use
      throwParseErrors - If parse errors should be thrown
    • CSTTransformer

      public CSTTransformer(Transformation<T> rootTransformation)
      Creates a new transformation manager with a given root transformation that throws parse errors by default.
      Parameters:
      rootTransformation - The root transformation to use
    • CSTTransformer

      public CSTTransformer()
    • CSTTransformer

      public CSTTransformer(boolean throwParseErrors)
  • Method Details