-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add named variable for reduce action:
add Punct(Equal) to Tokenizer add NonTermData and TermData fix syntax for named variable from Token in production rule bump Cargo version to 0.8.0
- Loading branch information
Showing
14 changed files
with
315 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::ops::Deref; | ||
use std::ops::DerefMut; | ||
|
||
/// type for NonTerminal data in reduce action | ||
#[derive(Debug, Clone)] | ||
pub struct NonTermData<'a, Term, T> { | ||
/// the slice of terms that this non-terminal data is reduced from | ||
pub slice: &'a [Term], | ||
/// the value of this non-terminal data | ||
pub value: T, | ||
/// the range of terms that this non-terminal data is reduced from | ||
pub range: std::ops::Range<usize>, | ||
} | ||
|
||
impl<'a, Term, T> NonTermData<'a, Term, T> { | ||
pub fn new(slice: &'a [Term], value: T, range: std::ops::Range<usize>) -> Self { | ||
Self { | ||
slice, | ||
value, | ||
range, | ||
} | ||
} | ||
} | ||
impl<'a, Term, T> Deref for NonTermData<'_, Term, T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.value | ||
} | ||
} | ||
impl<'a, Term, T> DerefMut for NonTermData<'_, Term, T> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::ops::Deref; | ||
use std::ops::DerefMut; | ||
|
||
/// type for Terminal data in reduce action | ||
#[derive(Debug, Clone)] | ||
pub struct TermData<'a, Term> { | ||
/// the terminal symbol | ||
pub value: &'a Term, | ||
/// the index of the terminal symbol | ||
pub index: usize, | ||
} | ||
impl<'a, Term> TermData<'a, Term> { | ||
pub fn new(value: &'a Term, index: usize) -> Self { | ||
Self { value, index } | ||
} | ||
} | ||
impl<'a, Term> Deref for TermData<'a, Term> { | ||
type Target = &'a Term; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.value | ||
} | ||
} | ||
impl<'a, Term> DerefMut for TermData<'a, Term> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.