Package wyrl.core

Examples of wyrl.core.Pattern


    // ====================================================================
    // Third, check all remaining elements against the unbounded match.
    // ====================================================================

    int lastPatternElementIndex = pattern_elements.length-1;
    Pattern lastPatternElement = pattern_elements[lastPatternElementIndex].first();
    Type lastDeclaredElement = declared_elements[declared_elements.length-1];
    int element = environment.allocate(Type.T_VOID());

    if(!willSkip(lastPatternElement,lastDeclaredElement)) {
View Full Code Here


    // collection and attempts to match the element. In doing this, we must
    // ensure that no previously matched elements are matched again.

    int[] indices = new int[elements.length];
    for (int i = 0, j = 0; i != elements.length; ++i) {
      Pattern pat = elements[i].first();
      int item = environment.allocate(Type.T_ANY());
      int index = environment.allocate(Type.T_ANY());
      String idx = "r" + index;
      indices[i] = index;
View Full Code Here

    // simply go through all unmatched elements making sure they match the
    // required pattern.

    int[] indices = new int[pattern_elements.length];
    for (int i = 0, j = 0; i != pattern_elements.length - 1; ++i) {
      Pattern pat = pattern_elements[i].first();
      int item = environment.allocate(Type.T_ANY());
      int index = environment.allocate(Type.T_ANY());
      String idx = "r" + index;
      indices[i] = index;

      // Construct the for-loop for this element
      myOut(level++, "for(int " + idx + "=0;" + idx + "!=c" + source
          + ".size();++" + idx + ") {");

      // Check that the current element from the source collection is not
      // already matched. If this is the first pattern element (i.e. i ==
      // 0), then we don't need to do anything since nothing could have
      // been matched yet.
      if (i != 0) {
        indent(level);
        out.print("if(");
        // check against earlier indices
        for (int k = 0; k < i; ++k) {
          if (k != 0) {
            out.print(" || ");
          }
          out.print(idx + " == r" + indices[k]);
        }
        out.println(") { continue; }");
      }
      myOut(level, "int r" + item + " = c" + source + ".get(" + idx
          + ");");

      level = translatePatternMatch(level, pat, declared_elements[j], item, environment);

      // Increment j upto (but not past) the final declared element.
      j = Math.min(j + 1, declared_elements.length - 1);
    }

    // ====================================================================
    // Third, check all remaining elements against the unbounded match.
    // ====================================================================
    int lastPatternElementIndex = pattern_elements.length-1;
    Pattern lastPatternElement = pattern_elements[lastPatternElementIndex].first();
    Type lastDeclaredElement = declared_elements[declared_elements.length-1];
    int item = environment.allocate(Type.T_VOID());

    if(!willSkip(lastPatternElement,lastDeclaredElement)) {
View Full Code Here

      }
      out.print("new Pattern." + kind + "(" + pc.unbounded
          + ", new Pair[]{");
      for (int i = 0; i != pc.elements.length; ++i) {
        Pair<Pattern, String> e = pc.elements[i];
        Pattern ep = e.first();
        String es = e.second();
        if (i != 0) {
          out.println(", ");
        } else {
          out.println();
View Full Code Here

TOP

Related Classes of wyrl.core.Pattern

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.