Ejemplo n.º 1
0
 private static void addFacet(
     final ISyntacticElement e,
     final String key,
     final IExpressionDescription expr,
     final Set<Diagnostic> errors) {
   if (e.hasFacet(key)) {
     // if ( key.equals(TYPE) ) {
     // GuiUtils.debug("GamlCompatibilityConverter.addFacet:");
     // }
     addWarning(
         "Double definition of facet " + key + ". Only the last one will be considered",
         e.getElement(),
         errors);
   }
   e.setFacet(key, expr);
 }
Ejemplo n.º 2
0
  private static void convertFacets(
      final Statement stm,
      final String keyword,
      final ISyntacticElement elt,
      final Set<Diagnostic> errors) {
    SymbolProto p = DescriptionFactory.getProto(keyword, null);
    for (Facet f : EGaml.getFacetsOf(stm)) {
      String fname = EGaml.getKey.caseFacet(f);

      // We change the "<-" and "->" symbols into full names
      if (fname.equals("<-")) {
        fname = keyword.equals(LET) || keyword.equals(SET) ? VALUE : INIT;
      } else if (fname.equals("->")) {
        fname = FUNCTION;
      }

      // We compute (and convert) the expression attached to the facet
      boolean label = p == null ? false : p.isLabel(fname);
      IExpressionDescription fexpr = convExpr(f, label, errors);
      addFacet(elt, fname, fexpr, errors);
    }

    // We add the "default" (or omissible) facet to the syntactic element
    String def = stm.getFirstFacet();
    if (def != null) {
      if (def.endsWith(":")) {
        def = def.substring(0, def.length() - 1);
      }
    } else {
      def = DescriptionFactory.getOmissibleFacetForSymbol(keyword);
    }
    if (def != null && !def.isEmpty() && !elt.hasFacet(def)) {
      IExpressionDescription ed = findExpr(stm, errors);
      if (ed != null) {
        elt.setFacet(def, ed);
      }
    }
  }