Package org.rascalmpl.interpreter.matching

Examples of org.rascalmpl.interpreter.matching.IMatchingResult


    java.util.List<IMatchingResult> kids = new java.util.ArrayList<IMatchingResult>(alts.size());
    for (org.rascalmpl.ast.Expression arg : alts) {
      kids.add(arg.buildMatcher(eval));
    }

    IMatchingResult setMatcher = new SetPattern(eval, this,  kids);
    java.util.List<IMatchingResult> wrap = new ArrayList<IMatchingResult>(1);
    wrap.add(setMatcher);

    Result<IValue> ambCons = eval.getCurrentEnvt().getVariable("amb");
    return new NodePattern(eval, this, new LiteralPattern(eval, this,  ambCons.getValue()), null, Factory.Tree_Amb, wrap, Collections.<String,IMatchingResult>emptyMap());
View Full Code Here


    }

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext eval) {
      Type type = getType().typeOf(eval.getCurrentEnvt(), true, eval.getEvaluator());
      IMatchingResult pat = this.getPattern().buildMatcher(eval);
      IMatchingResult var = new TypedVariablePattern(eval, this, type, this.getName());
      return new VariableBecomesPattern(eval, this, var, pat);

    }
View Full Code Here

      super(__param1, __param2, __param3);
    }

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext eval) {
      IMatchingResult pat = this.getPattern().buildMatcher(eval);
      LinkedList<Name> names = new LinkedList<Name>();
      names.add(this.getName());
      IMatchingResult var = new QualifiedNamePattern(eval, this, ASTBuilder.<org.rascalmpl.ast.QualifiedName> make("QualifiedName", "Default", this.getLocation(), names));
      return new VariableBecomesPattern(eval, this, var, pat);

    }
View Full Code Here

    boolean debug = false;
    Environment old = eval.getCurrentEnvt();
    eval.pushEnv();
 
    try {
      IMatchingResult mp = pat.getMatcher(eval);
      mp.initMatch(subject);
 
      while (mp.hasNext()) {
        eval.pushEnv();
       
        if (eval.isInterrupted()) {
          throw new InterruptException(eval.getStackTrace(), eval.getCurrentAST().getLocation());
        }
 
        if (mp.next()) {
          try {
            try {
              stat.interpret(eval);
            } catch (Insert e) {
              // Make sure that the match pattern is set
              if (e.getMatchPattern() == null) {
                e.setMatchPattern(mp);
              }
              e.setStaticType(mp.getType(eval.getCurrentEnvt(), null));
              throw e;
            }
            return true;
          } catch (Failure e) {
            // unwind(old); // can not clean up because you don't
View Full Code Here

    }
    
    public static boolean matchEvalAndReplace(Result<IValue> subject, Expression pat, List<Expression> conditions, Expression replacementExpr, IEvaluator<Result<IValue>> eval) {
      Environment old = eval.getCurrentEnvt();
      try {
        IMatchingResult mp = pat.getMatcher(eval);
        mp.initMatch(subject);

        while (mp.hasNext()) {
          if (eval.isInterrupted())
            throw new InterruptException(eval.getStackTrace(), eval.getCurrentAST().getLocation());
          if (mp.next()) {
            int size = conditions.size();
           
            if (size == 0) {
               throw new Insert(replacementExpr.interpret(eval), mp, mp.getType(eval.getCurrentEnvt(), null));
            }
           
            IBooleanResult[] gens = new IBooleanResult[size];
            Environment[] olds = new Environment[size];
            Environment old2 = eval.getCurrentEnvt();

            int i = 0;
            try {
              olds[0] = eval.getCurrentEnvt();
              eval.pushEnv();
              gens[0] = conditions.get(0).getBacktracker(eval);
              gens[0].init();

              while (i >= 0 && i < size) {

                if (eval.isInterrupted()) {
                  throw new InterruptException(eval.getStackTrace(), eval.getCurrentAST().getLocation());
                }
                if (gens[i].hasNext() && gens[i].next()) {
                  if (i == size - 1) {
                    // in IfThen the body is executed, here we insert the expression
                    // NB: replaceMentExpr sees the latest bindings of the when clause
                    throw new Insert(replacementExpr.interpret(eval), mp, mp.getType(eval.getCurrentEnvt(), null));
                  }

                  i++;
                  gens[i] = conditions.get(i).getBacktracker(eval);
                  gens[i].init();
View Full Code Here

    }

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext eval) {
      Type type = getType().typeOf(eval.getCurrentEnvt(), true, eval.getEvaluator());
      IMatchingResult absPat = this.getArgument().buildMatcher(eval);
      return new GuardedPattern(eval, this, type, absPat);
    }
View Full Code Here

      super(__param1, __param2);
    }

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext __eval) {
      IMatchingResult absPat = getPattern().buildMatcher(__eval);
      return new AntiPattern(__eval, this, absPat);
    }
View Full Code Here

      super(__param1, __param2);
    }

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext eval) {
      IMatchingResult absPat = this.getPattern().buildMatcher(eval);
      return new DescendantPattern(eval, this, absPat);
    }
View Full Code Here

TOP

Related Classes of org.rascalmpl.interpreter.matching.IMatchingResult

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.