@Test
public void testRule() {

  Parser<Rule> parser = RuleParser.rule();
  assertParser(parser, "foo", RuleReference.class, "foo");
  assertParser(parser, "'foo'", LiteralRule.class, "'foo'");
  assertParser(parser, "foo bar", SequentialRule.class, "foo bar");
  assertParser(parser, "foo bar | baz |'foo'", AltRule.class, "(foo bar | baz | 'foo')");
  assertParser(parser, "foo bar | \n  baz |'foo'", AltRule.class, "(foo bar | (baz | 'foo'))");
  assertParser(parser, "foo bar  baz |'foo'", AltRule.class, "(foo bar baz | 'foo')");
  assertParser(parser, "foo bar \n  baz |'foo'", SequentialRule.class, "foo bar (baz | 'foo')");
  assertParser(parser, "foo bar (baz |'foo')", SequentialRule.class, "foo bar (baz | 'foo')");
  assertParser(parser, "foo \n| bar", AltRule.class, "(foo | bar)");
  assertParser(parser, "foo | \n  bar | baz \n| 'foo'",
      AltRule.class, "(foo | (bar | baz) | 'foo')");
}