Merge "Replace vanilla parboiled with grappa library"

This commit is contained in:
Shawn Pearce 2015-06-12 23:56:24 +00:00 committed by Gerrit Code Review
commit 5b85e238f8
3 changed files with 24 additions and 26 deletions

View File

@ -34,6 +34,7 @@ java_library(
'//gerrit-util-ssl:ssl',
'//lib:args4j',
'//lib:automaton',
'//lib:grappa',
'//lib:gson',
'//lib:guava',
'//lib:gwtjsonrpc',
@ -41,7 +42,6 @@ java_library(
'//lib:jsch',
'//lib:juniversalchardet',
'//lib:mime-util',
'//lib:parboiled-core',
'//lib:pegdown',
'//lib:protobuf',
'//lib:velocity',
@ -210,6 +210,7 @@ java_test(
'//gerrit-reviewdb:server',
'//gerrit-server/src/main/prolog:common',
'//lib:args4j',
'//lib:grappa',
'//lib:gwtorm',
'//lib:truth',
'//lib/guice:guice',
@ -217,8 +218,6 @@ java_test(
'//lib/jgit:jgit',
'//lib/jgit:junit',
'//lib/joda:joda-time',
'//lib:parboiled-core',
'//lib:parboiled-java',
'//lib/prolog:runtime',
],
source_under_test = [':server'],

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'));
}
}
}

View File

@ -120,30 +120,29 @@ maven_jar(
id = 'org.pegdown:pegdown:1.4.2',
sha1 = 'd96db502ed832df867ff5d918f05b51ba3879ea7',
license = 'Apache2.0',
deps = [':parboiled-java'],
deps = [':grappa'],
)
maven_jar(
name = 'parboiled-core',
id = 'org.parboiled:parboiled-core:1.1.7',
sha1 = 'a60ff9a54cbeb30ec44c89e16ac4c35913cbad5a',
license = 'Apache2.0',
attach_source = False,
)
maven_jar(
name = 'parboiled-java',
id = 'org.parboiled:parboiled-java:1.1.7',
sha1 = '2298c64ce8ee8e2fb37e97e16d7be52f0c7cf61f',
name = 'grappa',
id = 'com.github.parboiled1:grappa:1.0.4',
sha1 = 'ad4b44b9c305dad7aa1e680d4b5c8eec9c4fd6f5',
license = 'Apache2.0',
deps = [
':parboiled-core',
'//lib/ow2:ow2-asm-tree',
':jitescript',
'//lib/ow2:ow2-asm',
'//lib/ow2:ow2-asm-analysis',
'//lib/ow2:ow2-asm-tree',
'//lib/ow2:ow2-asm-util',
],
attach_source = False,
visibility = ['//gerrit-server:server_tests'],
)
maven_jar(
name = 'jitescript',
id = 'me.qmx.jitescript:jitescript:0.4.0',
sha1 = '2e35862b0435c1b027a21f3d6eecbe50e6e08d54',
license = 'Apache2.0',
visibility = ['//lib:grappa'],
)
maven_jar(