mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Implement constructors for some parser types
This commit is contained in:
parent
913eeffa7e
commit
386f952c53
1 changed files with 15 additions and 0 deletions
|
@ -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 a new issue