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

yajco.generator.parsergen.beaver.templates.LALRParserClassMetaLexerTemplate.vm Maven / Gradle / Ivy

Go to download

YAJCo - Yet Another Java Compiler Compiler - object oriented language specification - beaver parser generator

The newest version!
##
## Input - parserClassName
## Input - parserPackageName
## Input - packageClassPackageName
## Input - mainElementClassName
## Input - scannerClassName
## Input - referenceResolverClassName
package $parserClassPackageName;

import java.io.StringReader;
import ${parserPackageName}.$scannerClassName;

public class $parserClassName {
	private static ${parserPackageName}.$parserClassName parser;

	public $mainElementClassName parse(String input) throws LALRParseException {
		return parse(new StringReader(input));
	}

	public $mainElementClassName parse(java.io.Reader reader) throws LALRParseException {
		$scannerClassName scanner = new ${scannerClassName}(reader);
		if (parser == null) {
			parser = new ${parserPackageName}.${parserClassName}();
		}

		try {
			${referenceResolverClassName} referenceResolver = ${referenceResolverClassName}.createInstance();
			$mainElementClassName root = ((${parserPackageName}.SymbolWrapper<${mainElementClassName}>) parser.parse(scanner)).getWrappedObject();
			referenceResolver.resolveReferences();
			return root;
		} catch (java.io.IOException e) {
			throw new ParseException("Problem parsing source code ", e);
		} catch (${parserPackageName}.${parserClassName}.Exception e) {
			throw new ParseException("Problem parsing source code ", e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy