All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.parse.ReferenceGrammar Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.parse;

public class ReferenceGrammar implements Grammar {

   private final ReferenceBuilder resolver; 
   private final int index;
   
   public ReferenceGrammar(GrammarResolver resolver, String name, int index) {
      this.resolver = new ReferenceBuilder(resolver, name, index);
      this.index = index;
   }   
   
   @Override
   public GrammarMatcher create(GrammarCache cache, int length) {
      GrammarMatcher matcher = cache.resolve(index); 
      
      if(matcher == null) {
         matcher = resolver.create(cache, length);
         cache.cache(index, matcher);
      }
      return matcher;
   }  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy