File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -867,7 +867,8 @@ impl YaccParser {
867
867
if !syms. is_empty ( )
868
868
| !( self . lookahead_is ( "|" , k) . is_some ( )
869
869
|| self . lookahead_is ( ";" , k) . is_some ( )
870
- || self . lookahead_is ( "{" , k) . is_some ( ) )
870
+ || self . lookahead_is ( "{" , k) . is_some ( )
871
+ || self . lookahead_is ( "%prec" , k) . is_some ( ) )
871
872
{
872
873
return Err ( self . mk_error ( YaccGrammarErrorKind :: NonEmptyProduction , i) ) ;
873
874
}
@@ -1909,6 +1910,20 @@ x"
1909
1910
assert_eq ! ( grm. prods[ grm. rules[ "expr" ] . pidxs[ 4 ] ] . precedence, Some ( "*" . to_string( ) ) ) ;
1910
1911
}
1911
1912
1913
+ #[ test]
1914
+ fn test_prec_empty ( ) {
1915
+ let src = "
1916
+ %%
1917
+ expr : 'a'
1918
+ | %empty %prec 'a';
1919
+ " ;
1920
+ let grm = parse ( YaccKind :: Original ( YaccOriginalActionKind :: NoAction ) , src) . unwrap ( ) ;
1921
+ assert_eq ! (
1922
+ grm. prods[ grm. rules[ "expr" ] . pidxs[ 1 ] ] . precedence,
1923
+ Some ( "a" . to_string( ) )
1924
+ ) ;
1925
+ }
1926
+
1912
1927
#[ test]
1913
1928
fn test_bad_prec_overrides ( ) {
1914
1929
let src = "
You can’t perform that action at this time.
0 commit comments