Commit f6f1e3ff authored by Dr. Michael Petter's avatar Dr. Michael Petter

added a new parsing method with parametric nonterminal name

parent 31790179
......@@ -394,6 +394,8 @@ public class Generate
}
out.line("import " + runName + ".Source;");
out.line("import java.lang.reflect.Method;");
out.line("import java.lang.reflect.InvocationTargetException;");
out.line("");
out.line("public class " + parsName + " extends " + basePars);
out.line("{");
......@@ -425,6 +427,18 @@ public class Generate
out.line(" }");
out.line("");
out.box("Run the parser on an arbitrary Non Terminal");
out.line("public boolean parse(Source src, String nonterminal) throws NoSuchMethodException, SecurityException,IllegalAccessException,InvocationTargetException ");
out.line(" {");
out.line(" super.init(src);");
out.line(" sem.init();");
out.line(" Method m = this.getClass().getMethod(nonterminal);");
out.line(" boolean result = ((Boolean)m.invoke(this)).booleanValue();");
out.line(" closeParser(result);");
out.line(" return result;");
out.line(" }");
out.line("");
out.box("Get semantics");
out.line("public " + semName+ " semantics()");
out.line(" { return sem; }");
......@@ -1331,4 +1345,4 @@ public class Generate
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment