oni_comb_parser_rs/core/
parser_runner.rs

1use crate::core::ParserMonad;
2use crate::core::{ParseError, ParseResult, ParseState};
3
4pub trait ParserRunner<'a> {
5  type Input;
6  type Output;
7  type P<'m, X, Y: 'm>: ParserMonad<'m, Input = X, Output = Y>
8  where
9    X: 'm;
10
11  /// Analyze input value(for [ParseResult]).<br/>
12  /// 入力を解析する。
13  fn parse(&self, input: &'a [Self::Input]) -> ParseResult<'a, Self::Input, Self::Output>;
14
15  /// Analyze input value(for [Result]).<br/>
16  /// 入力を解析する。
17  fn parse_as_result(&self, input: &'a [Self::Input]) -> Result<Self::Output, ParseError<'a, Self::Input>> {
18    self.parse(input).to_result()
19  }
20
21  /// Analyze input value(for [ParseResult]).<br/>
22  /// 入力を解析する。
23  ///
24  /// Requires [ParseState] argument.<br/>
25  /// 引数に[ParseState]が必要です。
26  fn run(&self, param: &ParseState<'a, Self::Input>) -> ParseResult<'a, Self::Input, Self::Output>;
27}