コード例 #1
0
ファイル: ParseTreeTools.java プロジェクト: siwiwit/EMFText
  /**
   * Given a production or application returns the constructor name attached to the production, or
   * null if there is no constructor.
   *
   * @author Martin Bravenboer
   * @author Lennart Kats
   */
  public String getConstructor(ATerm arg) {
    ATermAppl appl = assertAppl(arg, applFun);

    ATermAppl prod;
    if (appl.getAFun() == prodFun) {
      prod = appl;
    } else if (appl.getAFun() == applFun) {
      prod = assertAppl(appl.getArgument(APPL_PROD), prodFun);
    } else {
      throw new IllegalArgumentException("Expected prod or appl: " + arg);
    }

    ATermAppl attrs = assertAppl(prod.getArgument(PROD_ATTRS));
    if (attrs.getAFun() == noattrsFun) {
      return null;
    } else {
      for (ATerm attr : (ATermList) attrs.getChildAt(ATTRS_LIST)) {
        if (attr instanceof ATermAppl) {
          ATermAppl namedAttr = (ATermAppl) attr;
          if (namedAttr.getAFun() == termFun) {
            namedAttr = (ATermAppl) namedAttr.getArgument(TERM_CONS);
            if (namedAttr.getAFun() == consFun) {
              namedAttr = (ATermAppl) namedAttr.getArgument(CONS_NAME);
              return namedAttr.getName();
            }
          }
        }
      }
    }

    return null;
  }
コード例 #2
0
ファイル: DChar.java プロジェクト: JorgeFerreira93/TP-ATS
 /**
  * Apply a conversion on the ATerm contained in the String and returns a gram.i.types.DefTipo from
  * it
  *
  * @param trm ATerm to convert into a Gom term
  * @param atConv ATerm Converter used to convert the ATerm
  * @return the Gom term
  */
 public static gram.i.types.DefTipo fromTerm(
     aterm.ATerm trm, tom.library.utils.ATermConverter atConv) {
   trm = atConv.convert(trm);
   if (trm instanceof aterm.ATermAppl) {
     aterm.ATermAppl appl = (aterm.ATermAppl) trm;
     if (symbolName.equals(appl.getName()) && !appl.getAFun().isQuoted()) {
       return make();
     }
   }
   return null;
 }
コード例 #3
0
 /**
  * Apply a conversion on the ATerm contained in the String and returns a parser.rec.types.RelExp
  * from it
  *
  * @param trm ATerm to convert into a Gom term
  * @param atConv ATerm Converter used to convert the ATerm
  * @return the Gom term
  */
 public static parser.rec.types.RelExp fromTerm(
     aterm.ATerm trm, tom.library.utils.ATermConverter atConv) {
   trm = atConv.convert(trm);
   if (trm instanceof aterm.ATermAppl) {
     aterm.ATermAppl appl = (aterm.ATermAppl) trm;
     if (symbolName.equals(appl.getName()) && !appl.getAFun().isQuoted()) {
       return make(parser.rec.types.AritExp.fromTerm(appl.getArgument(0), atConv));
     }
   }
   return null;
 }
コード例 #4
0
  @Override
  protected void printURI(PrintWriter out, ATermAppl c) {
    String str = null;

    if (c.equals(ATermUtils.TOP)) str = "owl:Thing";
    else if (c.equals(ATermUtils.BOTTOM)) str = "owl:Nothing";
    else if (ATermUtils.isPrimitive(c)) str = qnames.shortForm(c.getName());
    else str = c.toString();

    out.print(str);
  }
コード例 #5
0
ファイル: E.java プロジェクト: JorgeFerreira93/TP-ATS
 /**
  * Apply a conversion on the ATerm contained in the String and returns a gram.i.types.Expressao
  * from it
  *
  * @param trm ATerm to convert into a Gom term
  * @param atConv ATerm Converter used to convert the ATerm
  * @return the Gom term
  */
 public static gram.i.types.Expressao fromTerm(
     aterm.ATerm trm, tom.library.utils.ATermConverter atConv) {
   trm = atConv.convert(trm);
   if (trm instanceof aterm.ATermAppl) {
     aterm.ATermAppl appl = (aterm.ATermAppl) trm;
     if (symbolName.equals(appl.getName()) && !appl.getAFun().isQuoted()) {
       return make(
           gram.i.types.Expressao.fromTerm(appl.getArgument(0), atConv),
           gram.i.types.LComentarios.fromTerm(appl.getArgument(1), atConv),
           gram.i.types.LComentarios.fromTerm(appl.getArgument(2), atConv),
           gram.i.types.Expressao.fromTerm(appl.getArgument(3), atConv));
     }
   }
   return null;
 }
コード例 #6
0
ファイル: TermCons.java プロジェクト: rusurazvangabriel/k
  public TermCons(ATermAppl atm, Context context) {
    super(atm);
    this.cons = atm.getName();
    this.sort = StringUtil.getSortNameFromCons(cons);
    this.production = context.conses.get(cons);
    assert this.production != null;

    contents = new ArrayList<Term>();
    if (atm.getArity() == 0) {
      contents = new ArrayList<Term>();
    } else if (atm.getArgument(0) instanceof ATermList) {
      ATermList list = (ATermList) atm.getArgument(0);
      for (; !list.isEmpty(); list = list.getNext()) {
        if (isColon(list.getFirst())) continue;
        contents.add((Term) JavaClassesFactory.getTerm(list.getFirst()));
      }
      contents.add(new ListTerminator(sort, null));
    } else {
      for (int i = 0; i < atm.getArity(); i++) {
        if (isColon(atm.getArgument(i))) continue;
        contents.add((Term) JavaClassesFactory.getTerm(atm.getArgument(i)));
      }
    }
  }
コード例 #7
0
  private static IRI iri(ATermAppl term) {
    if (term.getArity() != 0)
      throw new OWLRuntimeException("Trying to convert an anonymous term " + term);

    return IRI.create(term.getName());
  }