Esempio n. 1
0
  public Rule newRule(NonTerminal head, Symbol... symbols) {
    try {
      if (head.getGrammar() != this) {
        throw new IllegalArgumentException();
      }
      for (Symbol s : symbols) {
        if (s.getGrammar() != this) {
          throw new IllegalArgumentException();
        }
      }

      Rule result = new Rule(this, head, symbols);
      myRules.add(result);
      head.addRule(result);
      return result;
    } finally {
      invalidateGrammarData();
    }
  }