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