public boolean isDone() throws ParseFailed {
if (token != null) return false;
if (token==null && finalResult==null)
- throw new ParseFailed(ParseFailed.error(("unexpected end of file\n"),
- token, hash.values()),
- getLocation().createRegion(getLocation()), input);
+ ParseFailed.error("unexpected end of file",
+ getLocation(),
+ token,
+ hash.values(),
+ getLocation().createRegion(getLocation()),
+ input,
+ GSS.this);
return true;
}
return true;
}
+ LinkedList<Node> reductionQueue = new LinkedList<Node>();
+
/** perform all reduction operations */
public void reduce() throws ParseFailed {
try {
// INVARIANT: we never "see" a node until its parent-set is complete, modulo merges
}
for(int i=0; i<num; i++) {
- Node n = reducing_list[i];
+ reductionQueue.add(reducing_list[i]);
reducing_list[i] = null;
- n.performReductions();
+ }
+ while(!reductionQueue.isEmpty()) {
+ reductionQueue.remove().performReductions();
}
if (reset) {
reset = false;
}
if (!good && token!=null)
- throw new ParseFailed(ParseFailed.error(("unexpected character ")+" \'"+
- ANSI.purple(StringUtil.escapify(token+"", "\\\'\r\n"))+
- "\' encountered at "+
- ANSI.green(next.getRegion())+"\n", token, hash.values()),
- next.getRegion(), input);
+ ParseFailed.error("unexpected character",
+ getLocation(),
+ token,
+ hash.values(),
+ getRegion(),
+ input,
+ GSS.this);
+
if (token==null && finalResult==null)
- throw new ParseFailed(ParseFailed.error(("unexpected end of file at "+getLocation()+"\n"), token, hash.values()),
- getLocation().createRegion(getLocation()), input);
+ ParseFailed.error("unexpected end of file",
+ getLocation(),
+ token,
+ hash.values(),
+ getLocation().createRegion(getLocation()),
+ input,
+ GSS.this);
}
/** a node in the GSS */
final class Node implements Invokable<Position, Node, Node>, IntegerMappable, GraphViz.ToGraphViz {
public FastSet<Node> set = new FastSet<Node>();
-
-
private boolean allqueued = false;
/** what state this node is in */
}
public void performReductions(Node n2) {
- if (!allqueued) performReductions();
+ if (!allqueued) reductionQueue.add(this);//performReductions();
else state.invokeReductions(token, this, this, n2);
}