org.snapscript.parse.ReferenceGrammar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
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;
}
}