Permalink
Browse files

at least produce something if the input is not a valid b machine

  • Loading branch information...
1 parent eb5d022 commit 254516495e8f1830a11cf9526b8d0d76fb59dba9 @bendisposto committed Jul 16, 2012
@@ -440,10 +440,19 @@ public int fullParsing(final File bfile, final ParsingBehaviour options,
tree.apply(new ASTDisplay());
}
+ final long start2 = System.currentTimeMillis();
+
if (options.prologOutput) {
printASTasProlog(out, this, bfile, tree, options.useIndention,
options.addLineNumbers, contentProvider);
}
+ final long end2 = System.currentTimeMillis();
+
+ if (options.printTime) {
+ out.println("Time for Prolog output: " + (end2 - start2) + "ms");
+ }
+
+
if (options.fastPrologOutput) {
// try {
// String fp = getASTasFastProlog(this, bfile, tree);
@@ -214,7 +214,7 @@ private void recursivlyLoadMachine(final File machineFile,
- ancestors.add(name);
+ if (name != null) ancestors.add(name);
if (isMain) {
main = name;
}
@@ -249,7 +249,7 @@ private void checkForCycles(final Set<String> ancestors,
private void intersect(final Set<String> a, final Set<String> b) {
for (final Iterator<String> it = a.iterator(); it.hasNext();) {
final String elem = it.next();
- if (!b.contains(elem)) {
+ if (elem != null && !b.contains(elem)) {
it.remove();
}
}
@@ -106,6 +106,9 @@ private void escape(final String input, final boolean single_quotes,
}
private static boolean escapeIsNeeded(final String input) {
+ if (input == null) {
+ return false; // null is a valid atom
+ }
final int length = input.length();
if (length > 0
&& Arrays.binarySearch(VALID_ATOM_CHARS, input.charAt(0)) >= 0

0 comments on commit 2545164

Please sign in to comment.