本文整理汇总了Java中beaver.comp.run.Options类的典型用法代码示例。如果您正苦于以下问题:Java Options类的具体用法?Java Options怎么用?Java Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Options类属于beaver.comp.run包,在下文中一共展示了Options类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTerminalsSource
import beaver.comp.run.Options; //导入依赖的package包/类
public void writeTerminalsSource(File src_file, File dir, String output_file_name, Options opts) throws IOException
{
FileWriter out = new FileWriter(new File(dir, output_file_name + SOURCE_FILE_EXT));
try
{
if (grammar.package_name != null)
{
out.write("package ");
out.write(grammar.package_name);
out.write(";\n\n");
}
out.write("/**\n");
out.write(" * This class lists terminals used by the\n");
out.write(" * grammar specified in \"");
out.write(src_file.getName());
out.write("\".\n");
out.write(" */\n");
writeTerminalsClass(grammar, opts, "", out);
}
finally
{
out.close();
}
}
示例2: writeParserSource
import beaver.comp.run.Options; //导入依赖的package包/类
/**
* Writes a Java class that is a parser from the user point of view. Actual implementation though simply extends
* LALR parser implementation from Page and supplies action implementations for all productions and "enum" for all
* terminal symbols.
*
* @throws IOException
* when writing to a file fails
*/
public void writeParserSource(File src_file, File dir, String class_name, Options opts) throws IOException
{
FileWriter out = new FileWriter(new File(dir, class_name + SOURCE_FILE_EXT));
try
{
if (grammar.prolog != null)
{
out.write(grammar.prolog);
out.write('\n');
}
if (grammar.package_name != null)
{
out.write("package ");
out.write(grammar.package_name);
out.write(";\n\n");
}
for (int i = 0; i < grammar.imports.length; i++)
{
out.write("import ");
out.write(grammar.imports[i]);
out.write(";\n");
}
out.write('\n');
out.write("/**\n");
out.write(" * This class is a LALR parser generated by\n");
out.write(" * <a href=\"http://beaver.sourceforge.net\">Beaver</a> v");
out.write(VERSION);
out.write('\n');
out.write(" * from the grammar specification \"");
out.write(src_file.getName());
out.write("\".\n");
out.write(" */\n");
writeClass(class_name, opts, out);
}
finally
{
out.close();
}
}
示例3: compile
import beaver.comp.run.Options; //导入依赖的package包/类
static public ParserGenerator.CompiledParser compile(Grammar grammar, Options opts, Log log) throws Grammar.Exception
{
grammar.markNullableProductions();
grammar.buildFirstSets();
State first = makeStates(grammar);
findLookaheads(first);
buildActions(grammar, first);
checkAndResolveConflicts(first, log);
checkUnreducibleProductions(grammar, first, log);
if (!opts.no_compression)
compressActions(first);
splitActions(first);
return new CompiledParser(grammar, new ParsingTables(grammar, first));
}
示例4: writeTerminalsClass
import beaver.comp.run.Options; //导入依赖的package包/类
static private void writeTerminalsClass(Grammar grammar, Options opts, String indent, Writer out) throws IOException
{
out.write(indent);
if (indent.length() > 0)
out.write("static ");
out.write("public class Terminals {\n");
Terminal[] terms;
if (opts.sort_terminals)
{
terms = new Terminal[grammar.terminals.length];
System.arraycopy(grammar.terminals, 0, terms, 0, terms.length);
Arrays.sort(terms, TERMINAL_NAME_CMP);
}
else
{
terms = grammar.terminals;
}
for (int i = 0; i < terms.length; i++)
{
if (terms[i].name.charAt(0) == '$')
continue;
out.write(indent);
out.write("\tstatic public final short ");
out.write(terms[i].name);
out.write(" = ");
out.write(String.valueOf(terms[i].id));
out.write(";\n");
}
if (opts.terminal_names)
{
terms = grammar.terminals;
out.write('\n');
out.write(indent);
out.write("\tstatic public final String[] NAMES = {\n");
for (int i = 0; i < terms.length - 1; i++)
{
if (terms[i].name.charAt(0) == '$')
continue;
out.write(indent);
out.write("\t\t\"");
out.write(terms[i].name);
out.write("\",\n");
}
if (terms.length > 0 && terms[terms.length - 1].name.charAt(0) != '$')
{
out.write(indent);
out.write("\t\t\"");
out.write(terms[terms.length - 1].name);
out.write("\"\n");
}
out.write(indent);
out.write("\t};\n");
}
out.write(indent);
out.write("}\n");
}