Package aterm

Examples of aterm.ATermAppl


    return false;
  }

  protected boolean match(ATerm pattern, List<Object> list) {
    if (pattern.getType() == APPL) {
      ATermAppl appl = (ATermAppl) pattern;
      if (fun.equals(appl.getAFun())) {
        return matchArguments(appl.getArgumentArray(), list);
      }
      return false;
    }

    if (pattern.getType() == PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("appl") && !afun.isQuoted()) {
          list.add(fun.getName());
          return matchArguments(appl.getArgumentArray(), list);
        } else if (afun.getName().equals("str") && !afun.isQuoted()) {
          if (fun.isQuoted()) {
            list.add(fun.getName());
            return matchArguments(appl.getArgumentArray(), list);
          }
        } else if (afun.getName().equals("fun") && !afun.isQuoted()) {
          if (!fun.isQuoted()) {
            list.add(fun.getName());
            return matchArguments(appl.getArgumentArray(), list);
          }
        } else if (afun.getName().equals("id") && !afun.isQuoted()) {
          if (!fun.isQuoted()) {
            list.add(fun.getName());
            return matchArguments(appl.getArgumentArray(), list);
          }
        }
      }
    }
View Full Code Here


      if (pattern_arg.getType() == PLACEHOLDER) {
        ATerm ph_type = ((ATermPlaceholder) pattern_arg)
          .getPlaceholder();
        if (ph_type.getType() == APPL) {
          ATermAppl appl = (ATermAppl) ph_type;
          if (appl.getName().equals("list") && appl.getArguments().isEmpty()) {
            ATermList result = getPureFactory().getEmpty();
            for (int j = args.length - 1; j >= i; j--) {
              result = result.insert(args[j]);
            }
            list.add(result);
View Full Code Here

   
    ATerm result;
   
    switch(term.getType()){
      case ATerm.APPL:
        ATermAppl appl = (ATermAppl) term;
       
        AFun fun = (AFun) importTerm(appl.getAFun());
       
        int nrOfArguments = appl.getArity();
        ATerm[] newArguments = new ATerm[nrOfArguments];
        for(int i = nrOfArguments - 1; i >= 0; i--){
          newArguments[i] = importTerm(appl.getArgument(i));
        }
       
        result = makeAppl(fun, newArguments);
        break;
      case ATerm.LIST:
View Full Code Here

  public boolean match(ATerm pattern, List<Object> list) {
    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm t = ((ATermPlaceholder) pattern).getPlaceholder();
      if (t.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) t;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("placeholder") && afun.getArity() == 0 && !afun.isQuoted()) {
          list.add(t);
          return true;
        }
      }
View Full Code Here

    return super.match(pattern, list);
  }

  public ATerm make(List<Object> args) {
    ATermAppl appl;
    AFun fun;
    String name;

    appl = (ATermAppl) type;
    fun = appl.getAFun();
    name = fun.getName();
    if (!fun.isQuoted()) {
      if (fun.getArity() == 0) {
        if (name.equals("term")) {
          ATerm t = (ATerm) args.get(0);
          args.remove(0);

          return t;
        } else if (name.equals("list")) {
          ATermList l = (ATermList) args.get(0);
          args.remove(0);

          return l;
        } else if (name.equals("bool")) {
          Boolean b = (Boolean) args.get(0);
          args.remove(0);

          return factory.makeAppl(factory.makeAFun(b.toString(), 0,
                false));
        } else if (name.equals("int")) {
          Integer i = (Integer) args.get(0);
          args.remove(0);

          return factory.makeInt(i.intValue());
        } else if (name.equals("real")) {
          Double d = (Double) args.get(0);
          args.remove(0);

          return factory.makeReal(d.doubleValue());
        } else if (name.equals("blob")) {
            byte[] data = (byte[]) args.get(0);
            args.remove(0);

            return factory.makeBlob(data);
        } else if (name.equals("placeholder")) {
          ATerm t = (ATerm) args.get(0);
          args.remove(0);
          return factory.makePlaceholder(t);
        } else if (name.equals("str")) {
          String str = (String) args.get(0);
          args.remove(0);
          return factory.makeAppl(factory.makeAFun(str, 0, true));
        } else if (name.equals("id")) {
          String str = (String) args.get(0);
          args.remove(0);
          return factory.makeAppl(factory.makeAFun(str, 0, false));
        } else if (name.equals("fun")) {
          String str = (String) args.get(0);
          args.remove(0);
          return factory.makeAppl(factory.makeAFun(str, 0, false));
        }
      }
      if (name.equals("appl")) {
        ATermList oldargs = appl.getArguments();
        String newname = (String) args.get(0);
        args.remove(0);
        ATermList newargs = (ATermList) oldargs.make(args);
        AFun newfun = factory.makeAFun(newname, newargs.getLength(),
            false);
View Full Code Here

  boolean match(ATerm pattern, List<Object> list){
    if(pattern.getType() == PLACEHOLDER){
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if(type.getType() == ATerm.APPL){
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if(afun.getName().equals("term") && afun.getArity() == 0 && !afun.isQuoted()){
          list.add(this);
          return true;
        }
      }
View Full Code Here

    }

    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("blob")
            && afun.getArity() == 0
            && !afun.isQuoted()) {
          list.add(data);
          return true;
View Full Code Here

    }

    if (pattern.getType() == ATerm.PLACEHOLDER) {
      ATerm type = ((ATermPlaceholder) pattern).getPlaceholder();
      if (type.getType() == ATerm.APPL) {
        ATermAppl appl = (ATermAppl) type;
        AFun afun = appl.getAFun();
        if (afun.getName().equals("real") && afun.getArity() == 0 && !afun.isQuoted()) {
          list.add(new Double(value));
          return true;
        }
      }
View Full Code Here

    return result;
  }

  private String buildPlaceholderSubstitution(ATerm pattern) {
    ATermAppl hole = (ATermAppl) ((ATermPlaceholder) pattern)
        .getPlaceholder();
    String name = StringConversions.makeIdentifier(hole.getName());
    String type = hole.getArgument(0).toString();
    TypeConverter converter = new TypeConverter(
        new CTypeConversions(prefix));

    return "(ATerm) " + converter.makeBuiltinToATermConversion(type, name);
  }
View Full Code Here

  }

  private String buildApplConstructorImpl(ATerm pattern)
      throws GenerationException {
    String result;
    ATermAppl appl = (ATermAppl) pattern;
    int arity = appl.getArity();
    if (arity > 0) {
      ATerm last = appl.getArgument(arity - 1);
      if (last.getType() == ATerm.PLACEHOLDER) {
        ATerm ph = ((ATermPlaceholder) last).getPlaceholder();
        if (ph.getType() == ATerm.LIST) {
          throw new RuntimeException(
              "list placeholder not supported in"
                  + " argument list of function application");
        }
      }
    }
    result = "(ATerm)ATmakeAppl"
        + (arity <= 6 ? String.valueOf(arity) : "") + "(";
    result += prefix + afunRegister.lookup(appl.getAFun());
    for (int i = 0; i < arity; i++) {
      ATerm arg = appl.getArgument(i);
      result += ", " + genConstructorImpl(arg);
    }
    result += ")";
    return result;
  }
View Full Code Here

TOP

Related Classes of aterm.ATermAppl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.