Replace vanilla parboiled with grappa library

Grappa library was chosen by Gitiles project to implement markdown
rendering. Grappa library includes non-relocated parboiled library
that is incompatible with vanilla parboiled library.

When Grappa driven gitiles-plugin is deployed in Gerrit, there is
a class collision. The only way to make them co-exist is to relocate
one of them, using JarJar utility. But doing it can be error prone
as this issue has shown: [2].

This change takes another approach and replace parboiled library in
Gerrit core with Grappa library. This fixed the deployment problem
with gitiles-plugin: markdown files rendering work as expected.

[1] https://github.com/fge/grappa
[2] https://github.com/sirthias/parboiled/issues/80

Change-Id: I793a84013468bf9fd07e62960bc2e789674ff35c
This commit is contained in:
David Ostrovsky
2015-06-11 23:42:47 +02:00
parent 6efebfcad8
commit 0db7612e09
3 changed files with 24 additions and 26 deletions

View File

@@ -35,8 +35,8 @@ public class ParboiledTest {
" [Number] '42'\n" +
" [0..9] '4'\n" +
" [0..9] '2'\n" +
" [ZeroOrMore]\n" +
" [ZeroOrMore]\n";
" [zeroOrMore]\n" +
" [zeroOrMore]\n";
private CalculatorParser parser;
@@ -49,7 +49,7 @@ public class ParboiledTest {
public void test() {
ParsingResult<String> result =
new ReportingParseRunner<String>(parser.Expression()).run("42");
assertThat(result.hasErrors()).isFalse();
assertThat(result.isSuccess()).isTrue();
// next test is optional; we could stop here.
assertThat(ParseTreeUtils.printNodeTree(result)).isEqualTo(EXPECTED);
}
@@ -57,19 +57,19 @@ public class ParboiledTest {
@BuildParseTree
static class CalculatorParser extends BaseParser<Object> {
Rule Expression() {
return Sequence(Term(), ZeroOrMore(AnyOf("+-"), Term()));
return sequence(Term(), zeroOrMore(anyOf("+-"), Term()));
}
Rule Term() {
return Sequence(Factor(), ZeroOrMore(AnyOf("*/"), Factor()));
return sequence(Factor(), zeroOrMore(anyOf("*/"), Factor()));
}
Rule Factor() {
return FirstOf(Number(), Sequence('(', Expression(), ')'));
return firstOf(Number(), sequence('(', Expression(), ')'));
}
Rule Number() {
return OneOrMore(CharRange('0', '9'));
return oneOrMore(charRange('0', '9'));
}
}
}