### Question:
GrammarSugar { public static NonTerminal separated(Symbol item, Symbol separator) { return separated(item, separator, false); }  static NonTerminal seq(Symbol... symbols); static NonTerminal optional(Symbol symbol); static NonTerminal plus(Symbol symbol); static NonTerminal star(Symbol symbol); static NonTerminal star(Symbol symbol, StarRulesUpdater updater); static NonTerminal oneOf(Symbol first, Symbol... symbols); static NonTerminal oneOf(OneOfRuleUpdater updater, Symbol first, Symbol... symbols); static NonTerminal separated(Symbol item, Symbol separator); static NonTerminal separated(Symbol item, Symbol separator, boolean atLeastOne); static NonTerminal terminated(Symbol item, Symbol separator); static NonTerminal terminated(Symbol item, Symbol separator, boolean trailingOptional); static NonTerminal terminated(Symbol item, Symbol separator, boolean trailingOptional, boolean emptyStart); static NonTerminal terminated(Symbol item, Symbol separator, Symbol terminator, boolean trailingOptional, boolean emptyStart);  }### Answer:
@Test public void separatedPart() { Grammar g = new Grammar(); Terminal id = g.newTerminal("id"); Terminal comma = g.newTerminal(","); g.newRule(g.getStart(), separated(id, comma)); LRParser parser = new LRParser(new SLRTableGenerator(g).generateTable()); assertFalse(parser.parse(comma)); assertFalse(parser.parse(id, comma)); assertFalse(parser.parse(id, comma, id, comma)); assertEquals("[]", "" + parser.parse(asLexemes())); assertEquals("[id]", "" + parser.parse(asLexemes(id))); assertEquals("[id, id]", "" + parser.parse(asLexemes(id, comma, id))); }
@Test public void separated1Part() { Grammar g = new Grammar(); Terminal id = g.newTerminal("id"); Terminal comma = g.newTerminal(","); g.newRule(g.getStart(), separated(id, comma, true)); LRParser parser = new LRParser(new SLRTableGenerator(g).generateTable()); assertFalse(parser.parse(new Terminal[0])); assertFalse(parser.parse(comma)); assertFalse(parser.parse(id, comma)); assertFalse(parser.parse(id, comma, id, comma)); assertEquals("[id]", "" + parser.parse(asLexemes(id))); assertEquals("[id, id]", "" + parser.parse(asLexemes(id, comma, id))); }