Class CachingParser

java.lang.Object
io.github.douira.glsl_transformer.basic.EnhancedParser
io.github.douira.glsl_transformer.basic.CachingParser
All Implemented Interfaces:
ParserInterface

public class CachingParser extends EnhancedParser
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.
  • 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

      public io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext parse(String str)
      Description copied from class: EnhancedParser
      Parses a string as a translation unit.
      Overrides:
      parse in class EnhancedParser
      Parameters:
      str - The string to parse
      Returns:
      The parsed string as a translation unit parse tree
    • parse

      public <RuleType extends ExtendedContext> RuleType parse(String str, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser,RuleType> parseMethod)
    • parse

      public <RuleType extends ExtendedContext> RuleType parse(String str, ExtendedContext parent, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser,RuleType> parseMethod)
    • setParseTokenFilter

      public void setParseTokenFilter(TokenFilter<?> parseTokenFilter)
      Description copied from class: EnhancedParser
      Sets the token filter to use before parsing. It's placed between the lexer and the token stream.
      Specified by:
      setParseTokenFilter in interface ParserInterface
      Overrides:
      setParseTokenFilter in class EnhancedParser
      Parameters:
      parseTokenFilter - The new parse token filter