From 5b98beec8b2ff81c8f25229d9d406fd2ec1c1f60 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sat, 14 Mar 2020 16:22:33 +0100 Subject: [PATCH] Use left recursion instead of right > Any kind of sequence can be defined using either left recursion or right > recursion, but you should always use left recursion, because it can > parse a sequence of any number of elements with bounded stack space. https://www.gnu.org/software/bison/manual/html_node/Recursion.html --- src/asm/asmy.y | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/asm/asmy.y b/src/asm/asmy.y index 2a4bbdfd..4a907333 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -775,7 +775,7 @@ opt : T_POP_OPT { ; opt_list : opt_list_entry - | opt_list_entry ',' opt_list + | opt_list ',' opt_list_entry ; opt_list_entry : T_STRING { opt_Parse($1); } @@ -883,6 +883,7 @@ ds : T_POP_DS uconst { out_Skip($2); } } ; +/* Authorize empty entries if there is only one */ db : T_POP_DB constlist_8bit_entry ',' constlist_8bit { if (nListCountEmpty > 0) warning(WARNING_EMPTY_ENTRY, "Empty entry in list of 8-bit elements (treated as padding)."); @@ -912,7 +913,7 @@ purge : T_POP_PURGE { ; purge_list : purge_list_entry - | purge_list_entry ',' purge_list + | purge_list ',' purge_list_entry ; purge_list_entry : scoped_id { sym_Purge($1); } @@ -931,7 +932,7 @@ export_token : T_POP_EXPORT ; export_list : export_list_entry - | export_list_entry ',' export_list + | export_list ',' export_list_entry ; export_list_entry : scoped_id { sym_Export($1); } @@ -1066,7 +1067,7 @@ const_3bit : const { ; constlist_8bit : constlist_8bit_entry - | constlist_8bit_entry ',' constlist_8bit + | constlist_8bit ',' constlist_8bit_entry ; constlist_8bit_entry : /* empty */ { @@ -1084,7 +1085,7 @@ constlist_8bit_entry : /* empty */ { ; constlist_16bit : constlist_16bit_entry - | constlist_16bit_entry ',' constlist_16bit + | constlist_16bit ',' constlist_16bit_entry ; constlist_16bit_entry : /* empty */ { @@ -1095,7 +1096,7 @@ constlist_16bit_entry : /* empty */ { ; constlist_32bit : constlist_32bit_entry - | constlist_32bit_entry ',' constlist_32bit + | constlist_32bit ',' constlist_32bit_entry ; constlist_32bit_entry : /* empty */ {