1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::fmt::Display;
pub mod str;
mod slice;
pub mod error;
#[derive(Clone)]
pub enum RuleResult<T> {
Matched(usize, T),
Failed,
}
pub trait Parse {
type PositionRepr: Display;
fn start<'input>(&'input self) -> usize;
fn position_repr<'input>(&'input self, p: usize) -> Self::PositionRepr;
}
pub trait ParseElem: Parse {
type Element;
fn parse_elem(&self, pos: usize) -> RuleResult<Self::Element>;
}
pub trait ParseLiteral: Parse {
fn parse_string_literal(&self, pos: usize, literal: &str) -> RuleResult<()>;
}
pub trait ParseSlice<'input>: Parse {
type Slice;
fn parse_slice(&'input self, p1: usize, p2: usize) -> Self::Slice;
}