2
* Copyright (C) 2009-2011 Mathias Doenitz
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package org.parboiled;
19
import org.parboiled.annotations.BuildParseTree;
20
import org.parboiled.test.TestNgParboiledTest;
21
import org.testng.annotations.Test;
23
public class ParserInheritanceTest extends TestNgParboiledTest<Object> {
25
public static class Actions extends BaseActions<Object> {
26
public boolean dummyAction() {
32
public static class ParentParser extends BaseParser<Object> {
33
public Actions actions = new Actions();
36
return Sequence("ab", "cd", actions.dummyAction());
41
public static class DerivedParser extends ParentParser {
43
return Sequence(OneOrMore(Abcd()), actions.dummyAction());
49
ParentParser parentParser = Parboiled.createParser(ParentParser.class);
50
test(parentParser.Abcd(), "abcd")
57
DerivedParser derivedParser = Parboiled.createParser(DerivedParser.class);
58
Rule rule = derivedParser.Abcds();
59
test(rule, "abcdabcd")
62
"[Abcds] 'abcdabcd'\n" +
63
" [OneOrMore] 'abcdabcd'\n" +
b'\\ No newline at end of file'