mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-16 17:00:53 +00:00
distinguish lifetimes of the state table from the underlying grammar
This commit is contained in:
parent
a661d9ee94
commit
5c71e53c6b
@ -11,22 +11,21 @@ pub enum ParseTree {
|
||||
Terminal(TerminalString),
|
||||
}
|
||||
|
||||
pub fn interpret<'g,TOKENS>(states: &'g [State<'g>], tokens: TOKENS)
|
||||
-> Result<ParseTree, ()>
|
||||
pub fn interpret<TOKENS>(states: &[State], tokens: TOKENS) -> Result<ParseTree, ()>
|
||||
where TOKENS: Iterator<Item=TerminalString>
|
||||
{
|
||||
let mut m = Machine::new(states);
|
||||
m.execute(tokens)
|
||||
}
|
||||
|
||||
struct Machine<'grammar> {
|
||||
states: &'grammar [State<'grammar>],
|
||||
state_stack: Vec<&'grammar State<'grammar>>,
|
||||
struct Machine<'states, 'grammar:'states> {
|
||||
states: &'states [State<'grammar>],
|
||||
state_stack: Vec<&'states State<'grammar>>,
|
||||
data_stack: Vec<ParseTree>,
|
||||
}
|
||||
|
||||
impl<'grammar> Machine<'grammar> {
|
||||
fn new(states: &'grammar [State<'grammar>]) -> Machine<'grammar> {
|
||||
impl<'states, 'grammar> Machine<'states, 'grammar> {
|
||||
fn new(states: &'states [State<'grammar>]) -> Machine<'states,'grammar> {
|
||||
Machine { states: states,
|
||||
state_stack: vec![],
|
||||
data_stack: vec![] }
|
||||
|
Loading…
x
Reference in New Issue
Block a user