Package org.rascalmpl.ast

Examples of org.rascalmpl.ast.Expression$Enumerator


        return processFormals(formals);
      }
     
      private String processFormals(List<Expression> formals) {
        if (formals.size() > 0) {
          Expression first = formals.get(0);
         
          if (first.isAsType()) {
            first = first.getArgument();
          }
          else if (first.isTypedVariableBecomes() || first.isVariableBecomes()) {
            first = first.getPattern();
          }
         
          if (first.isCallOrTree() && first.getExpression().isQualifiedName()) {
            return ((org.rascalmpl.semantics.dynamic.QualifiedName.Default) first.getExpression().getQualifiedName()).lastName();
          }
        }

        return null;
      }
View Full Code Here


   
    formals = params.getFormals().getFormals();
   
    if (params.isVarArgs() && formals.size() > 0) {
      // deal with varags, change the last argument to a list if its not a pattern
      Expression last = formals.get(formals.size() - 1);
      if (last.isTypedVariable()) {
        org.rascalmpl.ast.Type oldType = last.getType();
        ISourceLocation origin = last.getLocation();
        Structured newType = ASTBuilder.make("Type","Structured", origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg","Default", origin,oldType))));
        last = ASTBuilder.make("Expression","TypedVariable",origin, newType, last.getName());
        formals = replaceLast(formals, last);
      }
      else if (last.isQualifiedName()) {
        ISourceLocation origin = last.getLocation();
        org.rascalmpl.ast.Type newType = ASTBuilder.make("Type","Structured",origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg",origin, ASTBuilder.make("Type","Basic", origin, ASTBuilder.make("BasicType","Value", origin))))));
        last = ASTBuilder.makeExp("TypedVariable", origin, newType, Names.lastName(last.getQualifiedName()));
        formals = replaceLast(formals, last);
      }
      else {
        throw new UnsupportedPattern("...", last);
      }
View Full Code Here

        return processFormals(formals);
      }
     
      private IConstructor processFormals(List<Expression> formals) {
        if (formals.size() > 0) {
          Expression first = formals.get(0);
         
          if (first.isAsType()) {
            first = first.getArgument();
          }
          else if (first.isTypedVariableBecomes() || first.isVariableBecomes()) {
            first = first.getPattern();
          }
         
          if (first instanceof Tree.Appl) {
            Tree.Appl appl = (Appl) first;
            return appl.getProduction();
View Full Code Here

    throw new NonGroundSymbolException();
  }
 
  @Override
  public IConstructor visitExpressionCallOrTree(CallOrTree x) {
    Expression namePart = x.getExpression();
    if (!namePart.isQualifiedName()) {
      throw new ImplementationError("weird AST");
    }
    String name = ((org.rascalmpl.semantics.dynamic.QualifiedName.Default) namePart.getQualifiedName()).lastName();
   
    if (name.equals("lit")) {
      StringConstant.Lexical arg =
        (org.rascalmpl.ast.StringConstant.Lexical) x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      // TODO: escaping etc.
View Full Code Here

    if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
      pattern = pattern.getPattern();
    }
   
    if (pattern.isCallOrTree()) {
      Expression func =  pattern.getExpression();
      if (func.isQualifiedName() && IUPTR_NAMES.contains(Names.fullName(func.getQualifiedName()))) {
        return true;
      }
    }

    return false;
View Full Code Here

    public boolean allConcrete = false;
    public abstract boolean matchAndEval(IEvaluator<Result<IValue>> eval, Result<IValue> subject);
   
    protected void computePredicates(Case c) {
      if (c.hasPatternWithAction()) {
        Expression pattern = c.getPatternWithAction().getPattern();
        hasRegExp |= pattern.isLiteral() && pattern.getLiteral().isRegExp();

        Type type = pattern._getType();
        allConcrete &= isNonTerminalType(type);
      }
    }
View Full Code Here

      allConcrete = true;
      hasRegExp = false;
    }
   
    void add(Case c) {
      Expression pattern = c.getPatternWithAction().getPattern();
      if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
        pattern = pattern.getPattern();
      }

      IConstructor key = ((Tree.Appl) pattern).getProduction();
      List<DefaultBlock> same = table.get(key);
      if (same == null) {
View Full Code Here

      hasRegExp = false;
      allConcrete = false;
    }

    void add(Case c) {
      Expression pattern = c.getPatternWithAction().getPattern();
      org.rascalmpl.ast.Expression name;
      if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
        name = pattern.getPattern().getExpression();
      }
      else {
        name = pattern.getExpression();
      }
      String key = null;

      if (name.isQualifiedName()) {
        key = ((QualifiedName.Default) name.getQualifiedName()).lastName();
View Full Code Here

                  env.declareVariable(kwType, kwparam);
                  env.storeVariable(kwparam, ResultFactory.makeResult(kwType, r, ctx));
              }
              else {
                  env.declareVariable(kwType, kwparam);
                  Expression def = getKeywordParameterDefaults().get(kwparam);
                  Result<IValue> kwResult = def.interpret(eval);
                  env.storeVariable(kwparam, kwResult);
              }
          }
      }
      // TODO: what if the caller provides more arguments then are declared? They are
View Full Code Here

    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

TOP

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

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.