mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-22 01:55:51 +01:00
pawarser: make raw_tokens vec owned in input
This commit is contained in:
parent
becc4b4041
commit
91f766c18e
3 changed files with 12 additions and 13 deletions
|
@ -4,7 +4,7 @@ use crate::{syntax_error::SyntaxError, syntax_kind::SyntaxKind};
|
|||
|
||||
use self::object::object;
|
||||
|
||||
type Parser<'src, 'toks> = pawarser::Parser<'src, 'toks, SyntaxKind, SyntaxError>;
|
||||
type Parser<'src> = pawarser::Parser<'src, SyntaxKind, SyntaxError>;
|
||||
type CompletedMarker = pawarser::CompletedMarker<SyntaxKind, SyntaxError>;
|
||||
|
||||
const BASIC_VALUE_TOKENS: EnumSet<SyntaxKind> =
|
||||
|
|
|
@ -21,8 +21,8 @@ where
|
|||
const ERROR: Self;
|
||||
}
|
||||
|
||||
pub struct Parser<'src, 'toks, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
||||
input: Input<'src, 'toks, SyntaxKind>,
|
||||
pub struct Parser<'src, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError> {
|
||||
input: Input<'src, SyntaxKind>,
|
||||
pos: usize,
|
||||
events: Vec<Event<SyntaxKind, SyntaxErr>>,
|
||||
step_limit: u32,
|
||||
|
@ -30,7 +30,7 @@ pub struct Parser<'src, 'toks, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError
|
|||
}
|
||||
|
||||
impl<'src, 'toks, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError>
|
||||
Parser<'src, 'toks, SyntaxKind, SyntaxErr>
|
||||
Parser<'src, SyntaxKind, SyntaxErr>
|
||||
{
|
||||
/// eat all meaningless tokens at the end of the file.
|
||||
pub fn eat_succeeding_meaningless(&mut self) {
|
||||
|
@ -97,17 +97,16 @@ impl<'src, 'toks, SyntaxKind: SyntaxElement, SyntaxErr: SyntaxError>
|
|||
|
||||
pub struct ParserBuilder<
|
||||
'src,
|
||||
'toks,
|
||||
SyntaxKind: SyntaxElement,
|
||||
// SyntaxErr: SyntaxError,
|
||||
> {
|
||||
raw_toks: &'toks Vec<(SyntaxKind, &'src str)>,
|
||||
raw_toks: Vec<(SyntaxKind, &'src str)>,
|
||||
meaningless_token_kinds: EnumSet<SyntaxKind>,
|
||||
step_limit: u32,
|
||||
}
|
||||
|
||||
impl<'src, 'toks, SyntaxKind: SyntaxElement> ParserBuilder<'src, 'toks, SyntaxKind> {
|
||||
pub fn new(raw_toks: &'toks Vec<(SyntaxKind, &'src str)>) -> Self {
|
||||
impl<'src, SyntaxKind: SyntaxElement> ParserBuilder<'src, SyntaxKind> {
|
||||
pub fn new(raw_toks: Vec<(SyntaxKind, &'src str)>) -> Self {
|
||||
Self {
|
||||
raw_toks,
|
||||
meaningless_token_kinds: EnumSet::new(),
|
||||
|
@ -133,7 +132,7 @@ impl<'src, 'toks, SyntaxKind: SyntaxElement> ParserBuilder<'src, 'toks, SyntaxKi
|
|||
self
|
||||
}
|
||||
|
||||
pub fn build<SyntaxErr: SyntaxError>(self) -> Parser<'src, 'toks, SyntaxKind, SyntaxErr> {
|
||||
pub fn build<SyntaxErr: SyntaxError>(self) -> Parser<'src, SyntaxKind, SyntaxErr> {
|
||||
let Self {
|
||||
raw_toks,
|
||||
meaningless_token_kinds,
|
||||
|
|
|
@ -2,17 +2,17 @@ use enumset::{EnumSet, EnumSetType};
|
|||
|
||||
use super::SyntaxElement;
|
||||
|
||||
pub struct Input<'src, 'toks, SyntaxKind: SyntaxElement> {
|
||||
raw: &'toks Vec<(SyntaxKind, &'src str)>,
|
||||
pub struct Input<'src, SyntaxKind: SyntaxElement> {
|
||||
raw: Vec<(SyntaxKind, &'src str)>,
|
||||
// enumset of meaningless tokens
|
||||
semantically_meaningless: EnumSet<SyntaxKind>,
|
||||
// indices of non-meaningless tokens
|
||||
meaningful_toks: Vec<usize>,
|
||||
}
|
||||
|
||||
impl<'src, 'toks, SyntaxKind: SyntaxElement> Input<'src, 'toks, SyntaxKind> {
|
||||
impl<'src, SyntaxKind: SyntaxElement> Input<'src, SyntaxKind> {
|
||||
pub fn new(
|
||||
raw_toks: &'toks Vec<(SyntaxKind, &'src str)>,
|
||||
raw_toks: Vec<(SyntaxKind, &'src str)>,
|
||||
meaningless: Option<EnumSet<SyntaxKind>>,
|
||||
) -> Self {
|
||||
let mut meaningful_toks = Vec::new();
|
||||
|
|
Loading…
Reference in a new issue