@Test void getUnaryRules() { List<Rule> rules = Collections.singletonList(new Rule("$A", "$B")); Grammar grammar = new Grammar(rules, "$ROOT"); assertEquals(rules.get(0), grammar.getUnaryRules("$B").get(0)); assertEquals(0, grammar.getBinaryRules("$B", "$C").size()); assertEquals(0, grammar.getLexicalRules(Arrays.asList("$B", "$C")).size()); }
public List<Rule> getUnaryRules(String rhs){ StringTuple tuple = StringTuple.fromParts(rhs); return unaryRules.containsKey(tuple) ? unaryRules.get(tuple) : Collections.emptyList(); }
Grammar { public List<Rule> getUnaryRules(String rhs){ StringTuple tuple = StringTuple.fromParts(rhs); return unaryRules.containsKey(tuple) ? unaryRules.get(tuple) : Collections.emptyList(); } }
Grammar { public List<Rule> getUnaryRules(String rhs){ StringTuple tuple = StringTuple.fromParts(rhs); return unaryRules.containsKey(tuple) ? unaryRules.get(tuple) : Collections.emptyList(); } Grammar(List<Rule> rules, String rootCategory); }
Grammar { public List<Rule> getUnaryRules(String rhs){ StringTuple tuple = StringTuple.fromParts(rhs); return unaryRules.containsKey(tuple) ? unaryRules.get(tuple) : Collections.emptyList(); } Grammar(List<Rule> rules, String rootCategory); boolean isRoot(Rule rule); List<Rule> getLexicalRules(List<String> rhs); List<Rule> getUnaryRules(String rhs); List<Rule> getBinaryRules(String left, String right); Set<Rule> getNonTerminalRules(); }
Grammar { public List<Rule> getUnaryRules(String rhs){ StringTuple tuple = StringTuple.fromParts(rhs); return unaryRules.containsKey(tuple) ? unaryRules.get(tuple) : Collections.emptyList(); } Grammar(List<Rule> rules, String rootCategory); boolean isRoot(Rule rule); List<Rule> getLexicalRules(List<String> rhs); List<Rule> getUnaryRules(String rhs); List<Rule> getBinaryRules(String left, String right); Set<Rule> getNonTerminalRules();  }