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 Summary
ConstructorsConstructorDescriptionCSTTransformer(boolean throwParseErrors) CSTTransformer(Transformation<T> rootTransformation) Creates a new transformation manager with a given root transformation that throws parse errors by default.CSTTransformer(Transformation<T> rootTransformation, boolean throwParseErrors) Creates a new transformation manager with a given root transformation and parse error throwing behavior. -
Method Summary
Modifier and TypeMethodDescriptionio.github.douira.glsl_transformer.GLSLLexergetLexer()Returns the execution planner's lexer.io.github.douira.glsl_transformer.GLSLParserReturns this execution planner's parser.voidvoidsetParseTokenFilter(TokenFilter<T> parseTokenFilter) voidsetParsingStrategy(EnhancedParser.ParsingStrategy parsingStrategy) voidsetPrintTokenFilter(TokenFilter<T> printTokenFilter) Sets the token filter to use before printing.voidtransformBare(String str) Methods inherited from class io.github.douira.glsl_transformer.cst.transform.ExecutionPlanner
addConcurrent, getJobParameters, getRootNode, getRootTransformation, planExecutionFor, setJobParameters, setRootTransformation, transformTree, withJobParametersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.douira.glsl_transformer.job_parameter.ParameterHolder
getJobParameters, setJobParameters, withJobParametersMethods inherited from interface io.github.douira.glsl_transformer.job_parameter.ParameterizedTransformer
transform, transform
-
Constructor Details
-
CSTTransformer
Creates a new transformation manager with a given root transformation and parse error throwing behavior.- Parameters:
rootTransformation- The root transformation to usethrowParseErrors- If parse errors should be thrown
-
CSTTransformer
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
-
getLexer
public io.github.douira.glsl_transformer.GLSLLexer getLexer()Description copied from class:ExecutionPlannerReturns the execution planner's lexer.- Specified by:
getLexerin interfaceParserInterface- Specified by:
getLexerin classExecutionPlanner<T extends JobParameters>- Returns:
- The lexer
-
getParser
public io.github.douira.glsl_transformer.GLSLParser getParser()Description copied from class:ExecutionPlannerReturns this execution planner's parser. How the parser is stored is up to the implementing class.- Specified by:
getParserin interfaceParserInterface- Specified by:
getParserin classExecutionPlanner<T extends JobParameters>- Returns:
- The parser
-
getInternalParser
- Specified by:
getInternalParserin interfaceParserInterface
-
setParsingStrategy
- Specified by:
setParsingStrategyin interfaceParserInterface
-
setSLLOnly
public void setSLLOnly()- Specified by:
setSLLOnlyin interfaceParserInterface
-
setLLOnly
public void setLLOnly()- Specified by:
setLLOnlyin interfaceParserInterface
-
setPrintTokenFilter
Sets the token filter to use before printing.- Parameters:
printTokenFilter- The new print token filter
-
setParseTokenFilter
-
transformBare
- Specified by:
transformBarein interfaceParameterizedTransformer<T extends JobParameters>- Throws:
RecognitionException
-