Package erjang

Examples of erjang.ETuple


   * @param ctx
   * @return
   */
  private static Expr parse_TermConstruct(EObject expr, ParseContext ctx) {

    ETuple t = expr.testTuple();
    if (t != null) {

      // {const, X}
      if (t.arity() == 2 && t.elm(1) == am_const) {
        return new ConstantExpr(t.elm(2));
      }

      // {{}} | {{ConditionExpression, ...}}
      ETuple inner_t;
      if (t.arity() == 1 && (inner_t = t.elm(1).testTuple()) != null) {
        return new TupleConstruct(inner_t, ctx);
      }

      throw ERT.badarg();
View Full Code Here


    return res.toArray(new GuardCall[res.size()]);
  }

  private static GuardCall parse_MatchCondition(EObject expr, ParseContext ctx) {
    ETuple t = expr.testTuple();
    if (t == null || t.arity() < 1 || !GuardFunctions.contains(t.elm(1))) {
      throw ERT.badarg(expr);
    }

    return new GuardCall(t, ctx);
  }
View Full Code Here

  }

  private static Pattern compile_Match(EObject head, ParseContext ctx) {
    EAtom am;
    ECons cons;
    ETuple tuple;

    // is it '_'
    if (head == am_ANY) {
      return (AnyPattern.INSTANCE);
View Full Code Here

          EqualsPattern ep = (EqualsPattern) tp.elems[keypos1 - 1];
          return ep.value;
        }
      } else if (funs[0].head instanceof EqualsPattern) {
        EqualsPattern ep = (EqualsPattern) funs[0].head;
        ETuple tup;
        if ((tup=ep.value.testTuple()) != null && tup.arity() >= keypos1) {
          return tup.elm(keypos1);
        }
      }
    }

    return null;
View Full Code Here

   */
  public ESeq matching_keys(ESeq values, Map<EObject, ETuple> map) {

    for (Map.Entry<EObject, ETuple> ent : map.entrySet()) {

      ETuple val = ent.getValue();
      if (matches(val)) {
        values = values.cons(ent.getKey());
      }
    }

View Full Code Here

   
    for (Map.Entry<EObject, IPersistentCollection> ent : map.entrySet()) {

      IPersistentCollection values = ent.getValue();
      for (ISeq seq = values.seq(); seq != null; seq = seq.next()) {
        ETuple val = (ETuple) seq.first();
        if (matches(val)) {
          vals = vals.cons(val);
        }
      }
    }
View Full Code Here

      }
    }

    @Override
    public EObject eval(EMatchContext ctx) {
      ETuple res = ETuple.make(elems.length);
      for (int idx0 = 0; idx0 < elems.length; idx0++) {
        res.set(idx0 + 1, elems[idx0].eval(ctx));
      }
      return res;
    }
View Full Code Here

        // extended
        // | firstline | multiline | no_auto_capture | dupnames |
        // ungreedy
        // | {newline, NLSpec}| bsr_anycrlf | bsr_unicode

        ETuple tup;
        ESmall off;
        if (opt == am_unicode) {
          unicode = true;
        } else if (opt == am_anchored) {
          anchored = true;
        } else if (opt == am_global) {
          global = true;
        } else if (opt == am_caseless) {
          flags |= Pattern.CASE_INSENSITIVE;
        } else if (opt == am_dollar_endonly) {
          throw new NotImplemented("regex option "+opt);
        } else if (opt == am_dotall) {
          flags |= Pattern.DOTALL;
        } else if (opt == am_extended) {
          flags |= Pattern.COMMENTS;
        } else if (opt == am_firstline) {
          throw new NotImplemented("regex option "+opt);
        } else if (opt == am_multiline) {
          flags |= Pattern.MULTILINE;
        } else if (opt == am_no_auto_capture) {
          throw new NotImplemented("regex option "+opt);
        } else if (opt == am_dupnames) {
          throw new NotImplemented("regex option "+opt);
        } else if (opt == am_ungreedy) {
          throw new NotImplemented("regex option "+opt);
        } else if (opt == am_bsr_anycrlf) {
          newline_cr = true;
          newline_crlf = true;
          newline_lf = true;
          newline_any = false;

        } else if (opt == am_bsr_unicode) {
          newline_any = true;

        } else if ((tup = opt.testTuple()) != null && tup.arity() == 2
            && tup.elm(1) == am_newline) {

          newline_cr = false;
          newline_crlf = false;
          newline_lf = false;
          newline_any = false;

          EObject val = tup.elm(2);
          if (val == am_cr) {
            newline_cr = true;
          } else if (val == am_lf) {
            newline_lf = true;
          } else if (val == am_crlf) {
            newline_crlf = true;
          } else if (val == am_anycrlf) {
            newline_cr = true;
            newline_lf = true;
            newline_crlf = true;
          } else if (val == am_any) {
            newline_any = true;
          } else {
            return false;
          }
         
        } else if (tup != null && tup.arity() == 2 && tup.elm(1) == am_capture) {
          this.capture_spec = tup.elm(2);
          this.capture_type = am_index;

        } else if (tup != null && tup.arity() == 3 && tup.elm(1) == am_capture) {
          this.capture_spec = tup.elm(2);
          this.capture_type = tup.elm(3);

        } else if (tup != null && tup.arity() == 2
            && tup.elm(1) == am_offset
            && (off=tup.elm(2).testSmall()) != null) {
          this.offset = off.value;

        } else {
          return false;
        }
View Full Code Here

  }

  ESeq match(ESeq out, Map<EObject, ETuple> in) {

    for (ETuple elm : in.values()) {
      ETuple val = elm.testTuple();
      EMatchContext res = new EMatchContext(out_vars, val);
      if (matcher.match(val, res)) {
        out = out.cons(res.makeList());
      }
    }
View Full Code Here

  /** return list of matching members */
  ESeq match_members(ESeq out, ISeq in) {

    while (in != null) {
      ETuple elm = (ETuple) in.first();
      if (elm == null)
        break;

      EMatchContext res = new EMatchContext(out_vars, elm);
      if (matcher.match(elm, res)) {
View Full Code Here

TOP

Related Classes of erjang.ETuple

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.