Tabnine Logo
GenerateSentencesFromConfigDecl
Code IndexAdd Tabnine to your IDE (free)

How to use
GenerateSentencesFromConfigDecl
in
org.kframework.compile

Best Java code snippets using org.kframework.compile.GenerateSentencesFromConfigDecl (Showing top 11 results out of 315)

origin: kframework/k

/**
 * Takes a configuration declaration and returns the sentences that it desugars into.
 *
 * Cells of multiplicity 1 desugar into an initializer production, an initializer rule, and a cell production.
 * Cells of multiplicity * desugar into an initializer production, an initializer rule, a cell production, and a bag
 * sort to represent a bag of those cells.
 * Cells of multiplicity ? desugar into an initializer production, an initializer rule, a cell production, and an
 * empty production indicating the absence of that cell.
 * Cells with children additionally generate a *CellFragment sort with the same arity as the cell production,
 *  but the arguments made optional by generating additional sorts.
 * Cells which have parents and are not multiplicity * generate a CellOpt sort which is a supersort of the cell sort
 *  and has an additional production name like {@code <cell>-absent}. (For a cell with multiplicitly ? this is
 *  necessary to distinguish a fragment that did capture the state of the cell when it wasn't present, from
 *  a cell fragment that didn't even try to capture the cell).
 *
 * Currently the implementation does not handle initializer rules; we will address this eventually.
 * @param body The body of the configuration declaration.
 * @param ensures The ensures clause of the configuration declaration.
 * @param att The attributes of the configuration declaration.
 * @param m The module the configuration declaration exists in.
 * @return A set of sentences representing the configuration declaration.
 */
public static Set<Sentence> gen(K body, K ensures, Att att, Module m, boolean kore) {
  return genInternal(body, ensures, att, m, kore)._1();
}
origin: kframework/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);
}
origin: kframework/k

private KList getContentsOfInitRule(Production streamProduction) {
  String streamName = streamProduction.att().get("stream"); // stdin, stdout
  String initLabel = GenerateSentencesFromConfigDecl.getInitLabel(
      Sort(GenerateSentencesFromConfigDecl.getSortOfCell(streamName))); // initStdinCell, initStdoutCell
  String cellLabel = "<" + streamName + ">"; // <stdin>, <stdout>
  java.util.List<Sentence> initRules =
      stream(getStreamModule(streamName).localSentences())
          .filter(s -> isInitRule(initLabel, cellLabel, s))
          .collect(Collectors.toList());
  assert initRules.size() == 1;
  Sentence initRule = initRules.get(0);
  // rule initXCell(Init) => <x> ... </x>
  KRewrite body = (KRewrite) ((Rule) initRule).body();
  KApply right = (KApply) body.right();
  return right.klist();
}
origin: kframework/k

    if (label.sort().equals(Sort("#CellName"))) {
      String cellName = label.s();
      Att cellProperties = getCellPropertiesAsAtt(kapp.klist().items().get(1), cellName, ensures);
      Multiplicity multiplicity = convertStringMultiplicity(
          cellProperties.getOption("multiplicity"), term);
      boolean isStream = cellProperties.getOption("stream").isDefined();
      Tuple4<Set<Sentence>, List<Sort>, K, Boolean> childResult = genInternal(
          cellContents, null, cfgAtt, m, kore);
      Tuple4<Set<Sentence>, Sort, K, Boolean> myResult = computeSentencesOfWellFormedCell(isLeafCell, isStream, kore, multiplicity, cfgAtt, m, cellName, cellProperties,
          childResult._2(), childResult._3(), ensures, hasConfigOrRegularVariable(cellContents));
      return Tuple4.apply((Set<Sentence>)childResult._1().$bar(myResult._1()), Lists.newArrayList(myResult._2()), myResult._3(), false);
  if (label.sort().equals(Sort("#CellName"))) {
    String cellName = label.s();
    Sort sort = Sort(getSortOfCell(cellName));
    Option<Set<Production>> initializerProduction = m.productionsFor().get(KLabel(getInitLabel(sort)));
    if (initializerProduction.isDefined()) {
      Set<Production> realProds = stream(initializerProduction.get()).filter(p -> !p.att().contains("recordPrd", Production.class)).collect(Collections.toSet());
          return Tuple4.apply(Set(), Lists.newArrayList(sort), KApply(KLabel(getInitLabel(sort))), true);
        } else if (realProds.head().items().size() == 4) {
          return Tuple4.apply(Set(), Lists.newArrayList(sort), KApply(KLabel(getInitLabel(sort)), INIT), true);
return genInternal(generatedTop, ensures, cfgAtt, m, kore);
Tuple4<Set<Sentence>, List<Sort>, K, Boolean> childResult = genInternal(cell, null, cfgAtt, m, kore);
origin: kframework/k

    configDecl -> stream(GenerateSentencesFromConfigDecl.gen(configDecl.body(), configDecl.ensures(), configDecl.att(), parser.getExtensionModule(), kore)))
.collect(Collections.toSet());
origin: kframework/k

  K ensures,
  boolean hasConfigurationOrRegularVariable) {
String sortName = getSortOfCell(cellName);
Sort sort = Sort(sortName);
String initLabel = getInitLabel(sort);
Sentence initializer;
Rule initializerRule;
  rhs = optionalCellInitializer(hasConfigurationOrRegularVariable, cellProperties, initLabel);
} else if (multiplicity == Multiplicity.OPTIONAL) {
  rhs = optionalCellInitializer(hasConfigurationOrRegularVariable, cellProperties, initLabel);
} else {
origin: kframework/k

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));
}
origin: kframework/k

private Rule resolveInitRule(Production streamProduction, Rule rule) {
  Sort streamSort = streamProduction.sort(); // InCell, OutCell
  String initLabel = GenerateSentencesFromConfigDecl.getInitLabel(streamSort); // initInCell, initOutCell
  KLabel cellLabel = streamProduction.klabel().get(); // <in>, <out>
  // rule initInCell(Init) => <in> ... </in>
  if (isInitRule(initLabel, cellLabel.name(), rule)) {
    KRewrite body = (KRewrite) rule.body();
    KApply right = (KApply) body.right();
    KList klist = getContentsOfInitRule(streamProduction);
    right = KApply(right.klabel(), klist, right.att());
    body = KRewrite(body.left(), right, body.att());
    return Rule(body, rule.requires(), rule.ensures(), rule.att());
  }
  return rule;
}
origin: kframework/k

private static Set<Sentence> genProjection(Sort sort, Module m) {
  KLabel lbl = getProjectLbl(sort, m);
  KVariable var = KVariable("K", Att.empty().add(Sort.class, sort));
  Rule r = Rule(KRewrite(KApply(lbl, var), var), BooleanUtils.TRUE, BooleanUtils.TRUE, Att().add("projection"));
  if (m.definedKLabels().contains(lbl)) {
    return Set(r);
  }
  return Set(Production(lbl, sort, Seq(Terminal(lbl.name()), Terminal("("), NonTerminal(Sorts.K()), Terminal(")")), Att().add("function").add("projection")), r);
}
origin: kframework/k

  Set<Sentence> newSentences = GenerateSentencesFromConfigDecl.gen(generatedTop, BooleanUtils.TRUE, Att.empty(), mod.getExtensionModule(), true);
  sentences = (Set<Sentence>) sentences.$bar(newSentences);
RuleGrammarGenerator gen = new RuleGrammarGenerator(def);
ParseInModule mod = RuleGrammarGenerator.getCombinedGrammar(gen.getConfigGrammar(m), true);
Set<Sentence> newSentences = GenerateSentencesFromConfigDecl.gen(freshCell, BooleanUtils.TRUE, Att.empty(), mod.getExtensionModule(), true);
sentences = (Set<Sentence>) sentences.$bar(newSentences);
origin: kframework/k

RuleGrammarGenerator parserGen = new RuleGrammarGenerator(def);
Module m = RuleGrammarGenerator.getCombinedGrammar(parserGen.getConfigGrammar(m1), true).getExtensionModule();
Set<Sentence> gen = GenerateSentencesFromConfigDecl.gen(configuration, BooleanUtils.FALSE, Att(), m, false);
Att initializerAtts = Att().add("initializer");
Att productionAtts = initializerAtts.add("function").add("noThread");
org.kframework.compileGenerateSentencesFromConfigDecl

Javadoc

Created by dwightguth on 3/27/15.

Most used methods

  • gen
    Takes a configuration declaration and returns the sentences that it desugars into. Cells of multipli
  • computeSentencesOfWellFormedCell
    Generates the sentences associated with a particular cell. As a special case, cells with the maincel
  • convertStringMultiplicity
  • genInternal
    Recurses over a cell and computes all the sentences corresponding to its children, and then generate
  • getCellPropertiesAsAtt
  • getCellProperty
  • getInitLabel
  • getLeafInitializer
    Returns the body of an initializer for a leaf cell: replaces any configuration variables with map lo
  • getProjectLbl
  • getSortOfCell
  • hasConfigOrRegularVariable
    Returns true if the specified term has a configuration or regular variable
  • optionalCellInitializer
    Returns the term used to initialize an optinoal cell. An optional cell is initialized to the empty b
  • hasConfigOrRegularVariable,
  • optionalCellInitializer

Popular in Java

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now