use crate::{
parser::{ast::Section, errors::ParseIssue},
ScriptVersion,
};
use alloc::vec::Vec;
#[cfg(feature = "plugins")]
use crate::plugin::ExtensionRegistry;
pub(in crate::parser) struct Parser<'a> {
pub(super) source: &'a str,
pub(super) position: usize,
pub(super) line: usize,
pub(super) version: ScriptVersion,
pub(super) sections: Vec<Section<'a>>,
pub(super) issues: Vec<ParseIssue>,
pub(super) styles_format: Option<Vec<&'a str>>,
pub(super) events_format: Option<Vec<&'a str>>,
#[cfg(feature = "plugins")]
pub(super) registry: Option<&'a ExtensionRegistry>,
}
impl<'a> Parser<'a> {
pub const fn new(source: &'a str) -> Self {
Self {
source,
position: 0,
line: 1,
version: ScriptVersion::AssV4, sections: Vec::new(),
issues: Vec::new(),
styles_format: None,
events_format: None,
#[cfg(feature = "plugins")]
registry: None,
}
}
#[cfg(feature = "plugins")]
pub const fn new_with_registry(
source: &'a str,
registry: Option<&'a ExtensionRegistry>,
) -> Self {
Self {
source,
position: 0,
line: 1,
version: ScriptVersion::AssV4, sections: Vec::new(),
issues: Vec::new(),
styles_format: None,
events_format: None,
registry,
}
}
}