Last active
August 29, 2015 14:15
-
-
Save strangeglyph/ba728683dd5e39d70360 to your computer and use it in GitHub Desktop.
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
type Rules<'a> = HashMap<ProdElem<'a>, Vec<Vec<ProdElem<'a>>>>; | |
type ParseTable<'a> = HashMap<ProdElem<'a>, HashMap<ProdElem<'a>, &'a Vec<ProdElem<'a>>>>; | |
fn mk_parse_table<'a>(rules: &Rules<'a>, first_set: &FirstSet<'a>, follow_set: &FollowSet<'a>) -> ParseTable<'a> { | |
let mut result = HashMap::new(); | |
/// :t elem = ProdElem<'a> | |
/// :t productions = &Vec<Vec<ProdElem<'a>> | |
for (&elem, productions) in rules.iter() { | |
let mut row = HashMap::new(); | |
/// :t production = &Vec<ProdElem<'a> | |
for production in productions.iter() { | |
let (firsts, potential_empty) = Grammar::firsts(first_set, &production[]); | |
for &f in firsts.iter() { | |
if row.contains_key(&f) { panic!("Not a LL(1) grammar: More than one parse rule for {:?} => {:?}", elem, f); } | |
/// Insert production into row with a lifetime of however long 'rules' exists? | |
row.insert(f, production); | |
} | |
} | |
result.insert(elem, row); | |
} | |
result | |
} |
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
parser.rs:37:43: 37:49 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements | |
parser.rs:37 for (&elem, productions) in rules.iter() { | |
^~~~~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment