Examples of IList


Examples of org.eclipse.imp.pdb.facts.IList

        for (String elem : ctx.getResolverRegistry().listEntries(resolved.getURI())) {
          w.append(resRes.add(makeResult(stringType, vf.string(elem), ctx)).getValue());
        }

        IList result = w.done();
        // a list of loc's
        return makeResult(result.getType(), result, ctx);
       
      } catch (IOException e) {
        throw RuntimeExceptionFactory.io(vf.string(e.getMessage()), ctx.getCurrentAST(), ctx.getStackTrace());
      }
     
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

        return arg;
      }
      @Override
      public IConstructor visitTreeAppl(IConstructor arg) throws IOException {
        if (!result) {
          IList children = (IList) arg.get("args");
          for (IValue child : children) {
            child.accept(this);
            if (result) {
              break;
            }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    IConstructor sym = ctype.getSymbol();
        if(SymbolAdapter.isAnyList(sym)){
          sym = SymbolAdapter.getSymbol(sym);
         
          int delta = 1;          // distance between "real" list elements, e.g. non-layout and non-separator
          IList listElems = (IList) tree.get(1);
      if(SymbolAdapter.isIterPlus(sym) || SymbolAdapter.isIterStar(sym)){
        if(debug)System.err.println("pushConcreteSyntaxChildren: isIterPlus or isIterStar");
        delta = 1; // new iters never have layout separators
      } else if (SymbolAdapter.isIterPlusSeps(sym) || SymbolAdapter.isIterStarSeps(sym)) {
        if(debug)System.err.println("pushConcreteSyntaxChildren: isIterPlusSeps or isIterStarSeps");
        delta = SymbolAdapter.getSeparators(sym).length() + 1;
      }
      if(debug)
        for(int i = 0; i < listElems.length(); i++){
          System.err.println("#" + i + ": " + listElems.get(i));
        }
         
      for(int i = listElems.length() - 1; i >= 0 ; i -= delta){
        if(debug)System.err.println("adding: " + listElems.get(i));
        pushConcreteSyntaxNode((IConstructor)listElems.get(i));
      }
    } else {
      if(debug)System.err.println("pushConcreteSyntaxNode: appl");
      /*
       * appl(prod(...), [child0, layout0, child1, ...])
       */
      spine.push(tree);
      IList applArgs = (IList) tree.get(1);
      int delta = (SymbolAdapter.isLiteral(sym)) ? 1 : 2;   // distance between elements
     
      for(int i = applArgs.length() - 1; i >= 0 ; i -= delta){
        //spine.push(applArgs.get(i));
        pushConcreteSyntaxNode((IConstructor) applArgs.get(i));
      }
    }
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

  public static IList getASTSymbols(IConstructor tree) {
    if (isLexical(tree)) {
      throw new ImplementationError("This is not a context-free production: " + tree);
    }

    IList children = getSymbols(tree);
    IListWriter writer = ValueFactoryFactory.getValueFactory().listWriter(Factory.Args.getElementType());

    for (int i = 0; i < children.length(); i++) {
      IConstructor kid = (IConstructor) children.get(i);
      if (!SymbolAdapter.isLiteral(kid) && !SymbolAdapter.isCILiteral(kid)) {
        writer.append(kid);
      }
      // skip layout
      i++;
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    if (name.equals("empty")) {
      return vf.constructor(Factory.Symbol_Empty)
    }
   
    if (name.equals("seq")) {
      IList list = vf.list(Factory.Symbol);
      Expression.List arg = (List) x.getArguments().get(0);
      for (Expression y: arg.getElements()) {
        list = list.append(y.accept(this));
      }
      return vf.constructor(Factory.Symbol_Seq, list);
     
    }
   
    if (name.equals("opt")) {
      IConstructor arg = x.getArguments().get(0).accept(this);
      return vf.constructor(Factory.Symbol_Opt, arg);
    }
   
    if (name.equals("alt")) {
      ISet set = vf.set(Factory.Symbol);
      Expression.Set arg = (Set) x.getArguments().get(0);
      for(Expression y: arg.getElements()){
        set = set.insert(y.accept(this));
      }
      return vf.constructor(Factory.Symbol_Alt, set);
    }
   
    if (name.equals("tuple")) {
      java.util.List<Expression> args = x.getArguments();
      IConstructor head = args.get(0).accept(this);
      IList rest = vf.list(Factory.Symbol);
      for (Expression arg: ((Expression.List)args.get(1)).getElements()) {
        rest = rest.append(arg.accept(this));
      }
      return vf.constructor(Factory.Symbol_Tuple, head, rest);
    }
   
    if (name.equals("sort")) {
      StringConstant.Lexical arg = (org.rascalmpl.ast.StringConstant.Lexical)
        x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      String str = arg.getString();
      str = str.substring(1, str.length() - 1);
      return vf.constructor(Factory.Symbol_Sort, vf.string(str));
    }
   
    if (name.equals("layouts")) {
      StringConstant.Lexical arg = (org.rascalmpl.ast.StringConstant.Lexical)
        x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      String str = arg.getString();
      str = str.substring(1, str.length() - 1);
      return vf.constructor(Factory.Symbol_LayoutX, vf.string(str));
    }
   

    if (name.equals("iter")) {
      IConstructor arg = x.getArguments().get(0).accept(this);
      return vf.constructor(Factory.Symbol_IterPlus, arg);
    }
   
    if (name.equals("iter-star")) {
      IConstructor arg = x.getArguments().get(0).accept(this);
      return vf.constructor(Factory.Symbol_IterStar, arg);
    }
   
    if (name.equals("iter-star-seps")) {
      IConstructor arg = x.getArguments().get(0).accept(this);
      Expression.List args = (Expression.List) x.getArguments().get(1);
      IList seps = vf.list(Factory.Args);
      for (Expression elem: args.getElements()) {
        seps = seps.append(elem.accept(this));
      }
      return vf.constructor(Factory.Symbol_IterStarSepX, arg, seps);
    }
   
    if (name.equals("iter-seps")) {
      IConstructor arg = x.getArguments().get(0).accept(this);
      Expression.List args = (Expression.List) x.getArguments().get(1);
      IList seps = vf.list(Factory.Args);
      for (Expression elem: args.getElements()) {
        seps = seps.append(elem.accept(this));
      }
      return vf.constructor(Factory.Symbol_IterSepX, arg, seps);
    }

    if (name.equals("parameterized-sort")) {
      java.util.List<Expression> args = x.getArguments();
      StringConstant.Lexical sort = (org.rascalmpl.ast.StringConstant.Lexical)
        x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      IList rest = vf.list(Factory.Symbol);
      for (Expression arg: ((Expression.List)args.get(1)).getElements()) {
        rest = rest.append(arg.accept(this));
      }
      return vf.constructor(Factory.Symbol_ParameterizedSort, vf.string(sort.getString()), rest);
     
    }
   
    if (name.equals("lit")) {
      StringConstant.Lexical arg = (org.rascalmpl.ast.StringConstant.Lexical)
        x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      // TODO: escaping etc.
      return vf.constructor(Factory.Symbol_Lit, vf.string(arg.getString()));
    }
   
    if (name.equals("char-class")) {
      java.util.List<Expression> args = x.getArguments();
      IList ranges = vf.list(Factory.CharRange);
      for (Expression arg: ((Expression.List)args.get(0)).getElements()) {
        ranges = ranges.append(arg.accept(this));
      }
      return vf.constructor(Factory.Symbol_CharClass, ranges);
    }
   
    if (name.equals("single")) {
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

 
  PropertyManager parent;
  IRunTimePropertyChanges runTimeChanges;
 
  public static PropertyManager extendProperties(IFigureConstructionEnv fpa, IConstructor c, PropertyManager pm, IList childProps){
    IList props = (IList) c.get(c.arity()-1);
       return new PropertyManager(fpa, pm, props);                        
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    IList props = (IList) c.get(c.arity()-1);
       return new PropertyManager(fpa, pm, props);                        
  }
 
  public static IList getChildProperties(IList props){
    IList result = null;
    for (IValue v : props) {
      if(v instanceof IConstructor && ((IConstructor)v).getName().equals("_child")){
        IList childList = (IList)((IConstructor)v).get(0);
        if(result == null){
          result = childList;
        } else {
          result.concat(childList);
        }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

      put("_xaxis",    Primitives.XAXIS);
    }};
 
   
    public static Figure[] makeList(IFigureConstructionEnv env, IValue list, PropertyManager properties, IList childProps){
      IList elems = (IList)list;
      Figure[] result = new Figure[elems.length()];
      for (int i = 0; i < elems.length(); i++) {
        IConstructor c = (IConstructor)elems.get(i);
      result[i] = FigureFactory.make(env, c, properties, childProps);
    }
      return result;
    }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    }
      return result;
    }
   
    public static Figure[][] make2DList(IFigureConstructionEnv env, IValue list, PropertyManager properties, IList childProps){
      IList elems = (IList)list;
      Figure[][] result = new Figure[elems.length()][];
      for (int i = 0; i < elems.length(); i++) {
        IList c = (IList)elems.get(i);
      result[i] = makeList(env, c, properties, childProps);
    }
      return result;
    }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

 
  @SuppressWarnings("incomplete-switch")
  public static Figure make(IFigureConstructionEnv env, IConstructor c, PropertyManager properties, IList childProps){
    String ename = c.getName();
    properties = PropertyManager.extendProperties(env, c, properties, childProps);
    IList childPropsNext = PropertyManager.getChildProperties((IList) c.get(c.arity()-1));
    if(childProps != null){
      IList childchildProps = PropertyManager.getChildProperties(childProps);
      if(childchildProps != null){
        if(childPropsNext != null){
          childPropsNext = childchildProps.concat(childPropsNext);
        } else {
          childPropsNext = childchildProps;
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.