File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,14 @@ impl<'a> SpannedDiagnosticFormatter<'a> {
267267 let ( _r1_prod_names, _r1_prod_spans) = pidx_prods_data ( ast, * r1_prod_idx) ;
268268 let ( _r2_prod_names, _r2_prod_spans) = pidx_prods_data ( ast, * r2_prod_idx) ;
269269
270- let t_name = grm. token_name ( * t_idx) . unwrap_or ( "$" ) ;
270+ let ( t_name, t_span) = if let Some ( name) = grm. token_name ( * t_idx) {
271+ ( name, grm. token_span ( * t_idx) )
272+ } else {
273+ (
274+ "$" ,
275+ grm. token_idx ( "$" ) . and_then ( |t_idx| grm. token_span ( t_idx) ) ,
276+ )
277+ } ;
271278 let r1_rule_idx = grm. prod_to_rule ( * r1_prod_idx) ;
272279 let r2_rule_idx = grm. prod_to_rule ( * r2_prod_idx) ;
273280 let r1_span = grm. rule_name_span ( r1_rule_idx) ;
@@ -287,6 +294,9 @@ impl<'a> SpannedDiagnosticFormatter<'a> {
287294 ) ;
288295 out. pushln ( self . underline_span_with_text ( r1_span, "First reduce" . to_string ( ) , '^' ) ) ;
289296 out. pushln ( self . underline_span_with_text ( r2_span, "Second reduce" . to_string ( ) , '-' ) ) ;
297+ if let Some ( t_span) = t_span {
298+ out. pushln ( self . underline_span_with_text ( t_span, "Lookahead" . to_string ( ) , '+' ) ) ;
299+ }
290300 out. push ( '\n' ) ;
291301 }
292302 for ( s_tok_idx, r_prod_idx, _st_idx) in c. sr_conflicts ( ) {
You can’t perform that action at this time.
0 commit comments