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 ParserRuleContext> RuleType parse(String str, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser,RuleType> parseMethod)
      Overrides:
      parse in class EnhancedParser
    • parse

      public <RuleType extends ParserRuleContext> RuleType parse(String str, ParserRuleContext parent, Class<RuleType> ruleType, Function<io.github.douira.glsl_transformer.GLSLParser,RuleType> parseMethod)
      Overrides:
      parse in class EnhancedParser
    • setTokenFilter

      public void setTokenFilter(TokenFilter<?> tokenFilter)
      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:
      setTokenFilter in interface ParserInterface
      Overrides:
      setTokenFilter in class EnhancedParser
      Parameters:
      tokenFilter - The new token filter