From b8dd5d2640f2011d016d0dfd750e804824771c68 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 4 Jan 2019 15:27:35 -0800 Subject: [PATCH] Fix handling of precedence and associativity with inlining --- src/prepare_grammar/process_inlines.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/prepare_grammar/process_inlines.rs b/src/prepare_grammar/process_inlines.rs index 9fd2f2c6..557b0fa4 100644 --- a/src/prepare_grammar/process_inlines.rs +++ b/src/prepare_grammar/process_inlines.rs @@ -90,7 +90,6 @@ impl InlinedProductionMapBuilder { while i < productions_to_add.len() { if let Some(step) = productions_to_add[i].steps.get(step_index) { let symbol = step.symbol.clone(); - if grammar.variables_to_inline.contains(&symbol) { // Remove the production from the vector, replacing it with a placeholder. let production = productions_to_add @@ -116,8 +115,12 @@ impl InlinedProductionMapBuilder { } } if let Some(last_inserted_step) = inserted_steps.last_mut() { - last_inserted_step.precedence = removed_step.precedence; - last_inserted_step.associativity = removed_step.associativity; + if last_inserted_step.precedence == 0 { + last_inserted_step.precedence = removed_step.precedence; + } + if last_inserted_step.associativity == None { + last_inserted_step.associativity = removed_step.associativity; + } } production }),