Implement constructors for some parser types

This commit is contained in:
Johannes Altmanninger 2023-03-04 01:19:43 +01:00
parent 913eeffa7e
commit 386f952c53

View File

@ -238,6 +238,9 @@ pub use parse_constants_ffi::{
};
impl SourceRange {
pub fn new(start: SourceOffset, length: SourceOffset) -> Self {
SourceRange { start, length }
}
pub fn end(&self) -> SourceOffset {
self.start.checked_add(self.length).expect("Overflow")
}
@ -248,6 +251,12 @@ impl SourceRange {
}
}
impl Default for ParseTokenType {
fn default() -> Self {
ParseTokenType::invalid
}
}
impl From<ParseTokenType> for &'static wstr {
#[widestrs]
fn from(token_type: ParseTokenType) -> Self {
@ -274,6 +283,12 @@ fn token_type_description(token_type: ParseTokenType) -> wcharz_t {
wcharz!(s)
}
impl Default for ParseKeyword {
fn default() -> Self {
ParseKeyword::none
}
}
impl From<ParseKeyword> for &'static wstr {
#[widestrs]
fn from(keyword: ParseKeyword) -> Self {