// <label1>&<label2>&... => p(label1),p(label2),... private ArrayList<Predicate> getPredicateListFromArc(String placeName, Arc arc) throws ParseException { if (!MIDParser.isIdentifier(placeName)) throw new ParseException( placeName + " " + LocaleBundle.bundleString("should start with a letter")); String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID(); int pos = CreateGui.getModel().getPosInList(activeTokenClassID, arc.getWeight()); if (pos >= 0) { String arcLabel = arc.getWeight().get(pos).getCurrentMarking().trim(); ArrayList<Predicate> predicates = new ArrayList<Predicate>(); try { ArrayList<ArrayList<String>> arcLabelList = MIDParser.parseArcLabelString(arcLabel); for (ArrayList<String> labelArguments : arcLabelList) predicates.add(new Predicate(placeName, labelArguments, arc instanceof InhibitorArc)); return predicates; } catch (ParseException e) { throw new ParseException( LocaleBundle.bundleString("Arc label") + " " + arcLabel + " (" + arc.getSource().getName() + " , " + arc.getTarget().getName() + "). " + e.toString()); } } return new ArrayList<Predicate>(); }
private boolean isRESETArcLabel(Arc outputArc) { String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID(); int pos = CreateGui.getModel().getPosInList(activeTokenClassID, outputArc.getWeight()); if (pos >= 0) { String arcLabel = outputArc.getWeight().get(pos).getCurrentMarking().trim(); try { ArrayList<ArrayList<String>> arcLabelList = MIDParser.parseArcLabelString(arcLabel); if (arcLabelList.size() > 1) return false; ArrayList<String> labelArguments = arcLabelList.get(0); return labelArguments.size() == 1 && labelArguments.get(0).equalsIgnoreCase(MID.RESET); } catch (ParseException e) { return false; } } return false; }
private void parseTokens(Marking marking, PipePlace place) throws ParseException { String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID(); DataLayerInterface net = mainNet.getModel(); int pos = net.getPosInList(activeTokenClassID, place.getCurrentMarking()); if (pos >= 0) { String tokenString = place.getCurrentMarking().get(pos).getCurrentMarking().trim(); if (tokenString != null && !tokenString.equals("")) { ArrayList<Tuple> tokenList = new ArrayList<Tuple>(); try { tokenList = MIDParser.parseTokenString(tokenString); } catch (ParseException e) { throw new ParseException(place.getName() + ": " + tokenString + ". " + e.toString()); } if (tokenList.size() > 0) { // check arity consistency int firstArity = tokenList.get(0).arity(); for (int index = 1; index < tokenList.size(); index++) if (tokenList.get(0).arity() != firstArity) throw new ParseException( place.getName() + " " + LocaleBundle.bundleString("has inconsistent token length")); // check duplication checkDuplicateTokens(tokenList, place.getName(), tokenString); } marking.addTuples(place.getName(), tokenList); } } }