
org.snapscript.parse.SyntaxTreeBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
The newest version!
package org.snapscript.parse;
public class SyntaxTreeBuilder {
private final SourceProcessor processor;
private final GrammarIndexer indexer;
public SyntaxTreeBuilder(GrammarIndexer indexer) {
this.processor = new SourceProcessor(100);
this.indexer = indexer;
}
public SyntaxTree create(String resource, String text, String grammar) {
char[] array = text.toCharArray();
if(array.length == 0) {
throw new ParseException("Source text is empty for '" + resource + "'");
}
SourceCode source = processor.process(text);
char[] original = source.getOriginal();
char[] compress = source.getSource();
short[] lines = source.getLines();
short[]types = source.getTypes();
int count = source.getCount();
return new SyntaxTree(indexer, resource, grammar, original, compress, lines, types, count);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy