mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:17:12 +08:00
Implement constructors for some parser types
This commit is contained in:
parent
913eeffa7e
commit
386f952c53
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user