Package org.rascalmpl.ast

Examples of org.rascalmpl.ast.Expression$Closure


    super();
  }
 
  private Statement surroundWithSingleIterForLoop(ISourceLocation loc, Name label, Statement body) {
    Name dummy = ASTBuilder.make("Name","Lexical",loc, "_");
    Expression var = ASTBuilder.make("Expression","QualifiedName",loc, ASTBuilder.make("QualifiedName", loc, Arrays.asList(dummy)));
    Expression truth = ASTBuilder.make("Expression","Literal",loc, ASTBuilder.make("Literal","Boolean",loc, ASTBuilder.make("BooleanLiteral","Lexical",loc, "true")));
    Expression list = ASTBuilder.make("Expression","List", loc, Arrays.asList(truth));
    Expression enumerator = ASTBuilder.make("Expression","Enumerator",loc, var, list);
    Statement stat = ASTBuilder.make("Statement","For",loc, ASTBuilder.make("Label","Default", loc, label), Arrays.asList(enumerator), body);
    return stat;
  }
View Full Code Here


    constructorCache.putUnsafe(in, out);
    return out;
  }
 
  private Expression liftRec(IConstructor tree, boolean lexicalFather, String layoutOfFather) {
    Expression cached = constructorCache.get(tree);
    if (cached != null) {
      return cached;
    }
   
    if (layoutOfFather == null) {
      throw new ImplementationError("layout is null");
    }
   
    if (TreeAdapter.isAppl(tree)) {
      String cons = TreeAdapter.getConstructorName(tree);
     
      if (cons != null && (cons.equals("hole"))) { // TODO: this is unsafe, what if somebody named their own production "hole"??
        return liftHole(tree);
      }

      boolean lex = lexicalFather ? !TreeAdapter.isSort(tree) : TreeAdapter.isLexical(tree);
     
      IList args = TreeAdapter.getArgs(tree);
      String layout = layoutOfFather;
     
      if (cons != null && !lex) {
        String newLayout = getLayoutName(TreeAdapter.getProduction(tree));
       
        // this approximation is possibly harmfull. Perhaps there is a chain rule defined in another module, which nevertheless
        // switched the applicable layout. Until we have a proper type-analysis there is nothing we can do here.
        if (newLayout != null) {
          layout = newLayout;
        }
      }
     
      java.util.List<Expression> kids = new ArrayList<Expression>(args.length());
      for (IValue arg : args) {
        Expression ast = liftRec((IConstructor) arg, lex, layout);
        if (ast == null) {
          return null;
        }
        kids.add(ast);
      }
View Full Code Here

    IConstructor type = (IConstructor) tree.asAnnotatable().getAnnotation("holeType");
    tree = (IConstructor) TreeAdapter.getArgs(tree).get(0);
    IList args = TreeAdapter.getArgs(tree);
    IConstructor nameTree = (IConstructor) args.get(4);
    ISourceLocation src = TreeAdapter.getLocation(tree);
    Expression result = new Tree.MetaVariable(tree, type, TreeAdapter.yield(nameTree));
    result.setSourceLocation(src);
    return result;
  }
View Full Code Here

        return cached;
      }
     
      IConstructor concrete = (IConstructor) TreeAdapter.getArgs(tree).get(0);
      IConstructor fragment = (IConstructor) TreeAdapter.getArgs(concrete).get(7);
      Expression ast = liftRec(fragment, false,  getPatternLayout(tree));
     
      constructorCache.putUnsafe(tree, ast);
      return ast;
    }
View Full Code Here

TOP

Related Classes of org.rascalmpl.ast.Expression$Closure

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.