Vend a new {@link GrammaticalStructure} based on the given {@link Tree}.

@param t the tree to analyze
@return a GrammaticalStructure based on the tree
540048
public GrammaticalStructure newGrammaticalStructure(Tree t) {
    try {
      if (puncFilter == null) {
        if (hf == null) {
          return (GrammaticalStructure) con.newInstance(t);
        } else {
          return (GrammaticalStructure) con.newInstance(t, hf);
        }
      } else {
        if (hf == null) {
          return (GrammaticalStructure) con.newInstance(t, puncFilter);
        } else {
          return (GrammaticalStructure) con.newInstance(t, puncFilter, hf);
        }
      }
    } catch (InstantiationException e) {
      throw new RuntimeException("Cannot instantiate " + con.getDeclaringClass().getName(), e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(con.getDeclaringClass().getName() + "(Tree t) does not have public access", e);
    } catch (InvocationTargetException e) {
      throw new RuntimeException("Failed to invoke " + con, e);
    }
  }
646130
public Tree<T> addLeaf( T child )
    {
        Tree<T> leaf = new Tree<T>( child );
        leaf.parent = this;
        children.add( leaf );
        return leaf;
    }
35971
public static <T> Predicate<T> TRUE() {
	return new Predicate<T>() {
	    public boolean check(T obj) { return true; }
	};
    }
178797
public static <T extends Tree> Matcher<T> isPrimitiveOrVoidType() {
    return new Matcher<T>() {
      @Override
      public boolean matches(T t, VisitorState state) {
        Type type = getType(t);
        return type != null && type.isPrimitiveOrVoid();
      }
    };
  }
628326
public static <T> TreeSetJsonDeserializer<T> newInstance( JsonDeserializer<T> deserializer ) {
        return new TreeSetJsonDeserializer<T>( deserializer );
    }
892443
private static void doTransform(Tree t) {

    if (t.value().startsWith("QP")) {
      //look at the children
      List<Tree> children = t.getChildrenAsList();
      if (children.size() >= 3 && children.get(0).isPreTerminal()) {
        //go through the children and check if they match the structure we want
        String child1 = children.get(0).value();
        String child2 = children.get(1).value();
        String child3 = children.get(2).value();
        if((child3.startsWith("CD") || child3.startsWith("DT")) &&
           (child1.startsWith("RB") || child1.startsWith("JJ") || child1.startsWith("IN")) &&
           (child2.startsWith("IN") || child2.startsWith("JJ"))) {
          transformQP(t);
        }
      }
    /* --- to be written or deleted
    } else if (t.value().startsWith("NP")) {
      //look at the children
      List<Tree> children = t.getChildrenAsList();
      if (children.size() >= 3) {

      }
    ---- */
    } else if (t.isPhrasal()) {
      for (Tree child : t.getChildrenAsList()) {
        doTransform(child);
      }
    }
  }
842147
private boolean isValidTreeType(Tree t) {
    if (t instanceof LambdaExpressionTree) {
      return true;
    }
    if (t instanceof ClassTree) {
      NestingKind nestingKind = ASTHelpers.getSymbol((ClassTree) t).getNestingKind();
      return nestingKind.equals(NestingKind.ANONYMOUS) || nestingKind.equals(NestingKind.LOCAL);
    }
    return false;
  }
992201
private TokenDefinition getTokenDefinition(ParseTreeNode tokenDefinition,
	    Map<String, ParseTreeNode> helpers, Map<String, ParseTreeNode> tokens)
	    throws GrammarException, TreeException {
	String tokenName = tokenDefinition.getChild("IDENTIFIER").getText();
	String pattern = createTokenDefinitionPattern(tokenDefinition, helpers,
		tokens);
	boolean ignoreCase = Boolean.valueOf((String) options
		.get("grammar.ignore-case"));
	if (tokenVisibility.get(tokenName) != null) {
	    return new TokenDefinition(tokenName, pattern,
		    tokenVisibility.get(tokenName), ignoreCase);
	} else {
	    return new TokenDefinition(tokenName, pattern, ignoreCase);
	}
    }
663199
public static <T, U> SameType<T> of(TreeNode<T> expected, TreeDef<U> treeDef, U actual, Function<? super U, ? extends T> mapper) {
		return of(TreeNode.treeDef(), expected, treeDef, actual).mapToSame(TreeNode::getContent, mapper);
	}
1225621
public Grammar getFragmentGrammar() {
		/*
		 * Fragment Content
		 */
		Grammar builtInFragmentContentGrammar = new BuiltInFragmentContent();

		/*
		 * Fragment
		 */
		fragmentGrammar = new Fragment("Fragment");
		fragmentGrammar.addProduction(new StartDocument(),
				builtInFragmentContentGrammar);

		return fragmentGrammar;
	}
647399
private static Map<Class<? extends CoreAnnotation>, Set<TreeGraphNode>> getAllDependents(TreeGraphNode node) {
    Map<Class<? extends CoreAnnotation>, Set<TreeGraphNode>> newMap = Generics.newHashMap();

    for (Class<?> o : node.label.keySet()) {
      try {
        // The line below will exception unless it's a GrammaticalRelationAnnotation,
        // so the effect is that only the GrammaticalRelationAnnotation things get put into newMap
        o.asSubclass(GrammaticalRelationAnnotation.class);
        newMap.put((Class<? extends CoreAnnotation>) o, (Set<TreeGraphNode>) node.label.get((Class<? extends CoreAnnotation>) o));//javac doesn't compile properly if generics are fully specified (but eclipse does...)
      } catch (Exception e) {
        // ignore a non-GrammaticalRelationAnnotation element
      }
    }
    return newMap;
  }
1217322
protected void newCompositeNode(EObject grammarElement) {
		XtextTokenStream input = (XtextTokenStream) this.input;
		int lookAhead = input.getCurrentLookAhead();
		currentNode = nodeBuilder.newCompositeNode(grammarElement, lookAhead, currentNode);
	}
55748
function Rule(rules) {
            this.rules = rules;
            // Identifies individual rule
            this.name = "";
            // Identifies the grammar that this rule belongs to 
            this.grammarName = "";
            // Identifies types of rules. Rules can have "types" that are different than the class name
            this.type = "";
            // Used to provide access to the name of the class 
            this.className = "Rule";
            // Indicates whether generated nodes should be added to the abstract syntax tree
            this._createAstNode = false;
            // A parser function, computed in a rule's constructor. If successful returns either the original or a new 
            // ParseState object. If it fails it returns null.
            this.parser = null;
            // A lexer function, computed in a rule's constructor. The lexer may update the ParseState if successful.
            // If it fails it is required that the lexer restore the ParseState index to the previous state. 
            // Lexers should only update the index. 
            this.lexer = null;
        }
36371
public DependencyTree parse2T(String[] words, String[] pos){
		return parse2T(new Sentence(words, pos));
	}
1221010
public static GrammarRules performPruning(double[] ts, GrammarRules grammarRules) {
    RulePruningAlgorithm pruner = new RulePruningAlgorithm(grammarRules, ts.length);
    pruner.pruneRules();
    return pruner.regularizePrunedRules();
  }
1186971
public Flowable<Tree<T>> parents() {
    return Flowable.generate(() -> Wrapper.of(this), (n, e) -> {
      Tree<T> parent = n.get().getParent();
      if (parent != null) {
        e.onNext(parent);
        n.set(parent);
      } else {
        e.onComplete();
      }
    });
  }
60281
public T ceiling(T T) {
      if (T == null) {
         return null;
      }
      NodeIterator<T> iterator = new NodeIterator<>(root, T.end(), Integer.MAX_VALUE, true);
      if (iterator.hasNext()) {
         return iterator.next();
      }
      return null;
   }