public void copyAttributesFrom(JavaSymbolicObject variable) { this.att.addAll(variable.att); } // TODO(YilongL): remove the comments below to enforce that every subclass
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())); }
private static Att getCellPropertiesAsAtt(K k, String cellName, K ensures) { Att att = Att(); if (cellName.equals("k")) { att = att.add("maincell"); } if (ensures != null) { att = att.add("topcell"); } att = att.add("cell").add("cellName", cellName); return att.addAll(getCellPropertiesAsAtt(k)); }
private static Att getCellPropertiesAsAtt(K k) { if (k instanceof KApply) { KApply kapp = (KApply) k; if (kapp.klabel().name().equals("#cellPropertyListTerminator")) { return Att(); } else if (kapp.klabel().name().equals("#cellPropertyList")) { if (kapp.klist().size() == 2) { Tuple2<String, String> attribute = getCellProperty(kapp.klist().items().get(0)); return Att().add(attribute._1(), attribute._2()).addAll(getCellPropertiesAsAtt(kapp.klist().items().get(1))); } } } throw KEMException.compilerError("Malformed cell properties", k); }
private Stream<? extends K> performParse(Map<String, ParsedSentence> cache, ParseInModule parser, Scanner scanner, Bubble b) { int startLine = b.att().get("contentStartLine", Integer.class); int startColumn = b.att().get("contentStartColumn", Integer.class); Source source = b.att().get(Source.class); Tuple2<Either<java.util.Set<ParseFailedException>, K>, java.util.Set<ParseFailedException>> result; if (cache.containsKey(b.contents())) { ParsedSentence parse = cache.get(b.contents()); Optional<Source> cacheSource = parse.getParse().source(); //Cache might contain content from an identical file but another source path. //The content will have wrong Source attribute and must be invalidated. if (cacheSource.isPresent() && cacheSource.get().equals(source)) { cachedBubbles.getAndIncrement(); kem.addAllKException(parse.getWarnings().stream().map(e -> e.getKException()).collect(Collectors.toList())); return Stream.of(parse.getParse()); } } result = parser.parseString(b.contents(), START_SYMBOL, scanner, source, startLine, startColumn, !b.att().contains("macro") && !b.att().contains("alias")); parsedBubbles.getAndIncrement(); kem.addAllKException(result._2().stream().map(e -> e.getKException()).collect(Collectors.toList())); if (result._1().isRight()) { KApply k = (KApply) new TreeNodesToKORE(Outer::parseSort, isStrict).down(result._1().right().get()); k = KApply(k.klabel(), k.klist(), k.att().addAll(b.att().remove("contentStartLine").remove("contentStartColumn").remove(Source.class).remove(Location.class))); cache.put(b.contents(), new ParsedSentence(k, new HashSet<>(result._2()))); return Stream.of(k); } else { errors.addAll(result._1().left().get()); return Stream.empty(); } } }
Att att = cellProperties.addAll(configAtt); StringBuilder format = new StringBuilder(); format.append("%1%i");