Class CachingParser
java.lang.Object
io.github.douira.glsl_transformer.basic.EnhancedParser
io.github.douira.glsl_transformer.basic.CachingParser
- All Implemented Interfaces:
ParserInterface
The caching parser extends the enhanced parser and returns previous parse
trees if they are available. This can't be used if the parse tree is
modified after parsing since then the contents of the cache would be modified
too. The
ASTBuilder does not modify the parse tree, and therefore it
is safe to use this.-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.basic.EnhancedParser
EnhancedParser.ParsingStrategy -
Field Summary
Fields inherited from class io.github.douira.glsl_transformer.basic.EnhancedParser
input, internalErrorConsumer, tokenStream -
Constructor Summary
ConstructorsConstructorDescriptionCachingParser(boolean throwParseErrors) CachingParser(boolean throwParseErrors, int cacheSize) CachingParser(int cacheSize) -
Method Summary
Modifier and TypeMethodDescriptionio.github.douira.glsl_transformer.GLSLParser.TranslationUnitContextParses a string as a translation unit.<RuleType extends ParserRuleContext>
RuleTypeparse(String str, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser, RuleType> parseMethod) <RuleType extends ParserRuleContext>
RuleTypeparse(String str, ParserRuleContext parent, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser, RuleType> parseMethod) voidsetParseCacheSizeAndClear(int size) voidsetTokenFilter(TokenFilter<?> tokenFilter) Sets the token filter to use before parsing.Methods inherited from class io.github.douira.glsl_transformer.basic.EnhancedParser
getInternalInstance, getLexer, getParser, getTokenStream, parse, parse, setLLOnly, setParsingStrategy, setSLLOnly, setThrowParseErrors
-
Constructor Details
-
CachingParser
public CachingParser(boolean throwParseErrors, int cacheSize) -
CachingParser
public CachingParser(int cacheSize) -
CachingParser
public CachingParser(boolean throwParseErrors) -
CachingParser
public CachingParser()
-
-
Method Details
-
setParseCacheSizeAndClear
public void setParseCacheSizeAndClear(int size) -
parse
Description copied from class:EnhancedParserParses a string as a translation unit.- Overrides:
parsein classEnhancedParser- Parameters:
str- The string to parse- Returns:
- The parsed string as a translation unit parse tree
-
parse
public <RuleType extends ParserRuleContext> RuleType parse(String str, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser, RuleType> parseMethod) - Overrides:
parsein classEnhancedParser
-
parse
public <RuleType extends ParserRuleContext> RuleType parse(String str, ParserRuleContext parent, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser, RuleType> parseMethod) - Overrides:
parsein classEnhancedParser
-
setTokenFilter
Description copied from class:EnhancedParserSets the token filter to use before parsing. It's placed between the lexer and the token stream.- Specified by:
setTokenFilterin interfaceParserInterface- Overrides:
setTokenFilterin classEnhancedParser- Parameters:
tokenFilter- The new token filter
-