Package com.blazebit.regex.node

Examples of com.blazebit.regex.node.RepeatNode


      switch (c) {
      case '?':
        e = new OptionalNode(e);
        break;
      case '*':
        e = new RepeatNode(e);
        break;
      case '+':
        e = new RepeatNode(e, 1);
        break;
      case '{':
        int n = parseInteger();

        if (n == -1) {
          throw new IllegalArgumentException(
              "integer expected at position " + cursor);
        }

        int m = match(',') ? parseInteger() : n;

        if (!match('}')) {
          throw new IllegalArgumentException(
              "expected '}' at position " + cursor);
        }

        if (m == -1) {
          e = new RepeatNode(e, n);
        } else {
          e = new RepeatNode(e, n, m);
        }

        break;
      }
    }
View Full Code Here


      for (int i = 0; i < nodes.size(); i++) {
        newNodes.addAll(traverse(nodes.get(i), context, trieNodes,
            negated));
      }
    } else if (node instanceof RepeatNode) {
      RepeatNode repeatNode = (RepeatNode) node;
      TrieNode<V> tempNode = new TrieNode<V>();
      List<TrieNode<V>> tempNodeList = new ArrayList<TrieNode<V>>(1);
      tempNodeList.add(tempNode);

      newNodes = traverse(repeatNode.getDecorated(), context,
          tempNodeList, negated);

      if (repeatNode.getMax() != Integer.MAX_VALUE) {
        List<TrieNode<V>> tempNodes = newNodes;
        newNodes = new ArrayList<TrieNode<V>>();

        for (int i = 1; i < repeatNode.getMax(); i++) {
          tempNodes = traverse(repeatNode.getDecorated(), context,
              tempNodes, negated);

          if (i + 1 >= repeatNode.getMin()) {
            newNodes.addAll(tempNodes);
          }
        }
      } else if (repeatNode.getMin() != 0) {
        List<TrieNode<V>> tempNodes = newNodes;
        newNodes = new ArrayList<TrieNode<V>>();

        for (int i = 1; i < repeatNode.getMin() - 1; i++) {
          tempNodes = traverse(repeatNode.getDecorated(), context,
              tempNodes, negated);
        }

        if (repeatNode.getMin() != 1) {
          TrieNode<V> minFulfilledNode = new TrieNode<V>();
          List<TrieNode<V>> minFulfilledNodeList = new ArrayList<TrieNode<V>>(
              1);
          minFulfilledNodeList.add(minFulfilledNode);

          newNodes = traverse(repeatNode.getDecorated(), context,
              minFulfilledNodeList, negated);

          mergeIntoNodes(tempNodes, minFulfilledNode);
          mergeIntoNodes(newNodes, minFulfilledNode);
        } else {
          newNodes = tempNodes;
          mergeIntoNodes(newNodes, tempNode);
        }
      } else {
        mergeIntoNodes(newNodes, tempNode);
      }

      mergeIntoNodes(trieNodes, tempNode);

      if (repeatNode.getMin() == 0) {
        newNodes.addAll(trieNodes);
      }
    } else if (node instanceof OptionalNode) {
      newNodes = traverse(((OptionalNode) node).getDecorated(), context,
          trieNodes, negated);
View Full Code Here

TOP

Related Classes of com.blazebit.regex.node.RepeatNode

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.