001/*
002 * Copyright (C) 2009-2011 Mathias Doenitz
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.parboiled.parserunners;
018
019import org.parboiled.buffers.InputBuffer;
020import org.parboiled.errors.ParseError;
021import org.parboiled.support.ParsingResult;
022import org.parboiled.support.ValueStack;
023import org.parboiled.support.ParsingResult;
024import org.parboiled.support.ValueStack;
025
026import java.util.List;
027
028/**
029 * A ParseRunner performs the actual parsing run of a given parser rule on a given input text.
030 */
031public interface ParseRunner<V> {
032
033    /**
034     * Initializes the parse runner with the given error list.
035     *
036     * @param parseErrors the error list to start off with
037     * @return this instance
038     */
039    ParseRunner<V> withParseErrors(List<ParseError> parseErrors);
040
041    /**
042     * Initializes the parse runner with the given ValueStack instance.
043     *
044     * @param valueStack the ValueStack to use
045     * @return this instance
046     */
047    ParseRunner<V> withValueStack(ValueStack<V> valueStack);
048
049    /**
050     * Performs the actual parse and creates a corresponding ParsingResult instance.
051     *
052     * @param input the input text to parse
053     * @return the ParsingResult for the run
054     */
055    ParsingResult<V> run(String input);
056
057    /**
058     * Performs the actual parse and creates a corresponding ParsingResult instance.
059     *
060     * @param input the input text to parse
061     * @return the ParsingResult for the run
062     */
063    ParsingResult<V> run(char[] input);
064
065    /**
066     * Performs the actual parse and creates a corresponding ParsingResult instance.
067     *
068     * @param inputBuffer the inputBuffer to use
069     * @return the ParsingResult for the run
070     */
071    ParsingResult<V> run(InputBuffer inputBuffer);
072}