print the set of things we are interpreting

makes debugging easier
This commit is contained in:
Niko Matsakis 2017-04-02 17:53:24 -04:00
parent f924cb857d
commit c489c805d0
4 changed files with 9 additions and 8 deletions

View File

@ -35,7 +35,7 @@ fn random_test<'g>(grammar: &Grammar,
macro_rules! tokens {
($($x:expr),*) => {
vec![$(TerminalString::quoted(intern($x))),*].into_iter()
vec![$(TerminalString::quoted(intern($x))),*]
}
}

View File

@ -12,7 +12,7 @@ fn nt(t: &str) -> NonterminalString {
macro_rules! tokens {
($($x:expr),*) => {
vec![$(TerminalString::quoted(intern($x))),*].into_iter()
vec![$(TerminalString::quoted(intern($x))),*]
}
}

View File

@ -11,12 +11,12 @@ use util::Sep;
pub type InterpretError<'grammar, L> = (&'grammar State<'grammar, L>, Token);
/// Feed in the given tokens and then EOF, returning the final parse tree that is reduced.
pub fn interpret<'grammar, TOKENS, L>(states: &'grammar [State<'grammar, L>],
tokens: TOKENS)
-> Result<ParseTree, InterpretError<'grammar, L>>
where TOKENS: IntoIterator<Item = TerminalString>,
L: LookaheadInterpret
pub fn interpret<'grammar, L>(states: &'grammar [State<'grammar, L>],
tokens: Vec<TerminalString>)
-> Result<ParseTree, InterpretError<'grammar, L>>
where L: LookaheadInterpret
{
println!("interpret(tokens={:?})", tokens);
let mut m = Machine::new(states);
m.execute(tokens.into_iter())
}

View File

@ -15,7 +15,7 @@ use super::table::*;
macro_rules! tokens {
($($x:expr),*) => {
vec![$(TerminalString::quoted(intern($x))),*].into_iter()
vec![$(TerminalString::quoted(intern($x))),*]
}
}
@ -117,6 +117,7 @@ fn build_table<'grammar>(grammar: &'grammar Grammar,
let first_sets = FirstSets::new(&grammar);
let state_graph = StateGraph::new(&lr0_err.states);
let mut tracer = LaneTracer::new(&grammar,
nt("G"),
&lr0_err.states,
&first_sets,
&state_graph,