/** * Updates the value of an attribute in the list of attributes. *get * @param key * @param val */ public void putAttribute(String key, String val) { addAttribute(key, val); }
/** * Copy constructor * * @param astNode */ public ASTNode(ASTNode astNode) { copyAttributesFrom(astNode); location = astNode.location; source = astNode.source; }
/** * Initializes an ASTNode from XML describing the parse tree * * @param elem * The XML element describing the ASTNode */ public ASTNode(Element elem) { this(getElementLocation(elem), getElementSource(elem)); }
/** * Constructor with specified location and filename. * * @param loc * @param file */ public ASTNode(Location loc, Source source) { setLocation(loc); setSource(source); }
public String makeErrorMessage(ASTNode t) { return t.toString() + " at location " + t.getLocation() + " in file " + t.getSource() + " of class " + t.getClass().toString(); } }
public static org.kframework.attributes.Att convertAttributes(ASTNode t) { Attributes attributes = t.getAttributes(); Map<String, String> attributesSet = attributes .keySet() .stream() .map(key -> { String keyString = key.toString(); String valueString = attributes.get(key).getValue().toString(); if (keyString.equals("klabel")) { return Tuple2.apply("klabel", valueString); } else { return Tuple2.apply(keyString, valueString); } }).collect(Collectors.toMap(Tuple2::_1, Tuple2::_2)); return Att().addAll(attributesSet) .addAll(attributesFromLocation(t.getLocation())) .addAll(attributesFromSource(t.getSource())); }
/** * Retrieves the attribute by key from the list of attributes * * @param key * @return a value for key in the list of attributes or the default value. */ public String getAttribute(String key) { return getAttribute(Attribute.keyOf(key)); }
/** * Copies attributes from another node into this node. * Use this in preference to {@link ASTNode#getAttributes} where appropriate because * the latter will create a new object if no attributes exist. * @param node The ASTNode to copy all attributes from. */ public void copyAttributesFrom(ASTNode node) { if (node.attributes == null) return; this.getAttributes().putAll(node.attributes); }
/** Marks 'node' with the location in 'loc'.Returns 'node' (which simplifies many uses of this function). */ private <T extends ASTNode> T markLocExplicit(Location loc, T node) { node.setSource(source); node.setLocation(loc); return node; }
public scala.collection.Set<Tag> toTags(List<Tag> labels, ASTNode loc) { return immutable(labels.stream().flatMap(l -> { java.util.Set<Production> productions = context.tags.get(l.name()); if (productions.isEmpty()) throw KEMException.outerParserError("Could not find any productions for tag: " + l.name(), loc.getSource(), loc.getLocation()); return productions.stream().map(p -> Tag(p.getKLabel(kore))); }).collect(Collectors.toSet())); }
public <T> T getAttribute(Class<T> cls, String annotation) { return getAttribute(Key.get(cls, Names.named(annotation))); }
public void removeAttribute(String key) { getAttributes().remove(Attribute.keyOf(key)); }
/** * Appends an attribute to the list of attributes. * * @param key * @param val */ public void addAttribute(String key, String val) { addAttribute(Attribute.of(key, val)); }
public <T> T getAttribute(TypeToken<T> type, Annotation annotation) { return getAttribute(Key.get(type, annotation)); }
public <T> void addAttribute(Key<T> key, T val) { addAttribute(new Attribute<>(key, val)); }
public <T> T getAttribute(Class<T> cls) { return getAttribute(Key.get(cls)); }
public <T> void addAttribute(TypeToken<T> key, String annotation, T val) { addAttribute(Key.get(key, Names.named(annotation)), val); }
public <T> T getAttribute(TypeToken<T> type, String annotation) { return getAttribute(Key.get(type, Names.named(annotation))); }
public <T> void addAttribute(Class<T> key, Annotation annotation, T val) { addAttribute(Key.get(key, annotation), val); }
public <T> T getAttribute(Class<T> cls, Annotation annotation) { return getAttribute(Key.get(cls, annotation)); }