protected <T> boolean match( int bid, SequenceMatcher.MatchedStates<T> matchedStates, boolean consume) { if (consume) { // Get element and return if it matched or not T node = matchedStates.get(); // TODO: Fix type checking if (pattern.match(node)) { // If matched, need to add next states to the queue of states to be processed matchedStates.addStates(bid, next); return true; } else { return false; } } else { // Not consuming element - add this state back to queue of states to be processed // This state was not successfully matched matchedStates.addState(bid, this); return false; } }
public final NodePattern Description(GraphRelation r) throws ParseException { Token name = null; boolean link = false; boolean isRoot = false; boolean isEmpty = false; Token attr = null; Token value = null; Map<String, String> attributes = Generics.newHashMap(); NodePattern pat; jj_consume_token(23); switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case IDENTIFIER: { attr = jj_consume_token(IDENTIFIER); jj_consume_token(12); switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case IDENTIFIER: { value = jj_consume_token(IDENTIFIER); break; } case REGEX: { value = jj_consume_token(REGEX); break; } default: jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } if (attr != null && value != null) attributes.put(attr.image, value.image); label_6: while (true) { switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case 24: {; break; } default: jj_la1[23] = jj_gen; break label_6; } jj_consume_token(24); attr = jj_consume_token(IDENTIFIER); jj_consume_token(12); switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case IDENTIFIER: { value = jj_consume_token(IDENTIFIER); break; } case REGEX: { value = jj_consume_token(REGEX); break; } default: jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } if (attr != null && value != null) attributes.put(attr.image, value.image); } jj_consume_token(25); break; } case ROOT: { attr = jj_consume_token(ROOT); jj_consume_token(25); isRoot = true; break; } case EMPTY: { attr = jj_consume_token(EMPTY); jj_consume_token(25); isEmpty = true; break; } case 25: { jj_consume_token(25); break; } default: jj_la1[25] = jj_gen; jj_consume_token(-1); throw new ParseException(); } switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case 22: { jj_consume_token(22); link = true; name = jj_consume_token(IDENTIFIER); String nodeName = name.image; if (underNegation) { if (!knownVariables.contains(nodeName)) { { if (true) throw new ParseException( "Cannot add new variable names under negation. Node '" + nodeName + "' not seen before"); } } } else { knownVariables.add(nodeName); } break; } default: jj_la1[26] = jj_gen; ; } pat = new NodePattern( r, underNodeNegation, attributes, isRoot, isEmpty, name != null ? name.image : null); if (link) pat.makeLink(); { if ("" != null) return pat; } throw new Error("Missing return statement in function"); }