/*
 * Copyright (C) 2009-2011 Mathias Doenitz
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.parboiled;

import org.parboiled.annotations.BuildParseTree;
import org.parboiled.test.ParboiledTest;
import org.testng.annotations.Test;

public class SplitParserTest extends ParboiledTest<Object>
{

    @BuildParseTree
    public static class Parser extends BaseParser<Object> {
        final Primitives primitives = Parboiled.createParser(Primitives.class);

        public Rule Clause() {
            return sequence(
                    primitives.Digit(),
                    primitives.Operator(),
                    primitives.Digit(),
                    EOI
            );
        }
    }

    @BuildParseTree
    public static class Primitives extends BaseParser<Object> {

        public Rule Operator() {
            return firstOf('+', '-');
        }

        public Rule Digit() {
            return charRange('0', '9');
        }

    }

    @Test
    public void test() {
        Parser parser = Parboiled.createParser(Parser.class);
        test(parser.Clause(), "1+5")
                .hasNoErrors()
                .hasParseTree("" +
                        "[Clause] '1+5'\n" +
                        "  [Digit] '1'\n" +
                        "  [Operator] '+'\n" +
                        "    ['+'] '+'\n" +
                        "  [Digit] '5'\n" +
                        "  [EOI]\n");
    }

}
@@ -810,17 +810,244 @@
 ject%3E%0A%7B%0A
+    /*%0A     * This one is intersting... It basically means that parsers are%0A     * %22reentrant%22.%0A     *%0A     * Not that surprising since BaseParser implements ContextAware; but still,%0A     * this is an interesting trick!%0A     */
 %0A
-
     @Bui
@@ -1282,33 +1282,33 @@
      primitives.
-D
+d
 igit(),%0A        
@@ -1373,17 +1373,17 @@
 mitives.
-D
+d
 igit(),%0A
@@ -1609,89 +1609,8 @@
  %7D%0A%0A
-        public Rule Digit() %7B%0A            return charRange('0', '9');%0A        %7D%0A%0A
     
@@ -1881,25 +1881,25 @@
         %22  %5B
-D
+d
 igit%5D '1'%5Cn%22
@@ -2020,17 +2020,17 @@
     %22  %5B
-D
+d
 igit%5D '5

Modify one parser example...