From 8bfd61773e9cc1075a57f847fe3c431151ccfd67 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 23 Oct 2005 06:01:44 +0000 Subject: [PATCH] * gas-bison.y, gas-token.re: Support multiple instructions on a single line with ';' separator. List output with this is currently broken however. * gas-semi.asm: New test for this. svn path=/trunk/yasm/; revision=1291 --- modules/parsers/gas/gas-bison.y | 25 +- modules/parsers/gas/gas-token.re | 2 +- modules/parsers/gas/tests/Makefile.inc | 3 + modules/parsers/gas/tests/gas-semi.asm | 5 + modules/parsers/gas/tests/gas-semi.errwarn | 0 modules/parsers/gas/tests/gas-semi.hex | 408 +++++++++++++++++++++ 6 files changed, 433 insertions(+), 10 deletions(-) create mode 100644 modules/parsers/gas/tests/gas-semi.asm create mode 100644 modules/parsers/gas/tests/gas-semi.errwarn create mode 100644 modules/parsers/gas/tests/gas-semi.hex diff --git a/modules/parsers/gas/gas-bison.y b/modules/parsers/gas/gas-bison.y index 3a883335..e81ae258 100644 --- a/modules/parsers/gas/gas-bison.y +++ b/modules/parsers/gas/gas-bison.y @@ -112,7 +112,7 @@ static void gas_parser_directive %token DIR_TFLOAT DIR_TYPE DIR_QUAD DIR_ULEB128 DIR_VALUE DIR_WEAK DIR_WORD %token DIR_ZERO -%type line lineexp instr +%type lineexp instr %type expr_id label_id %type memaddr @@ -130,28 +130,35 @@ static void gas_parser_directive %% input: /* empty */ | input line { - parser_gas->temp_bc = - yasm_section_bcs_append(parser_gas->cur_section, $2); - if (parser_gas->temp_bc) - parser_gas->prev_bc = parser_gas->temp_bc; if (parser_gas->save_input) yasm_linemap_add_source(parser_gas->linemap, - parser_gas->temp_bc, + parser_gas->prev_bc, parser_gas->save_line[parser_gas->save_last ^ 1]); yasm_linemap_goto_next(parser_gas->linemap); } ; -line: '\n' { $$ = (yasm_bytecode *)NULL; } - | lineexp '\n' +line: '\n' + | linebcs '\n' | error '\n' { yasm__error(cur_line, N_("label or instruction expected at start of line")); - $$ = (yasm_bytecode *)NULL; yyerrok; } ; +linebcs: linebc + | linebc ';' linebcs +; + +linebc: lineexp { + parser_gas->temp_bc = + yasm_section_bcs_append(parser_gas->cur_section, $1); + if (parser_gas->temp_bc) + parser_gas->prev_bc = parser_gas->temp_bc; + } +; + lineexp: instr | label_id ':' { $$ = (yasm_bytecode *)NULL; diff --git a/modules/parsers/gas/gas-token.re b/modules/parsers/gas/gas-token.re index 9692559e..876b95ca 100644 --- a/modules/parsers/gas/gas-token.re +++ b/modules/parsers/gas/gas-token.re @@ -250,7 +250,7 @@ scan: ">>" { RETURN(RIGHT_OP); } "<" { RETURN(LEFT_OP); } ">" { RETURN(RIGHT_OP); } - [-+|^!*&/~$():@=,] { RETURN(s->tok[0]); } + [-+|^!*&/~$():;@=,] { RETURN(s->tok[0]); } /* arch-independent directives */ '.2byte' { RETURN(DIR_2BYTE); } diff --git a/modules/parsers/gas/tests/Makefile.inc b/modules/parsers/gas/tests/Makefile.inc index 30ca0c2b..2a54bcc7 100644 --- a/modules/parsers/gas/tests/Makefile.inc +++ b/modules/parsers/gas/tests/Makefile.inc @@ -12,6 +12,9 @@ EXTRA_DIST += modules/parsers/gas/tests/datavis.hex EXTRA_DIST += modules/parsers/gas/tests/datavis2.asm EXTRA_DIST += modules/parsers/gas/tests/datavis2.errwarn EXTRA_DIST += modules/parsers/gas/tests/datavis2.hex +EXTRA_DIST += modules/parsers/gas/tests/gas-semi.asm +EXTRA_DIST += modules/parsers/gas/tests/gas-semi.errwarn +EXTRA_DIST += modules/parsers/gas/tests/gas-semi.hex EXTRA_DIST += modules/parsers/gas/tests/jmpcall.asm EXTRA_DIST += modules/parsers/gas/tests/jmpcall.errwarn EXTRA_DIST += modules/parsers/gas/tests/jmpcall.hex diff --git a/modules/parsers/gas/tests/gas-semi.asm b/modules/parsers/gas/tests/gas-semi.asm new file mode 100644 index 00000000..49c9a217 --- /dev/null +++ b/modules/parsers/gas/tests/gas-semi.asm @@ -0,0 +1,5 @@ +pushl %eax;ret + +x: pushl %eax; ret +y: pushl %eax; z: ret + diff --git a/modules/parsers/gas/tests/gas-semi.errwarn b/modules/parsers/gas/tests/gas-semi.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/parsers/gas/tests/gas-semi.hex b/modules/parsers/gas/tests/gas-semi.hex new file mode 100644 index 00000000..3a0857f5 --- /dev/null +++ b/modules/parsers/gas/tests/gas-semi.hex @@ -0,0 +1,408 @@ +7f +45 +4c +46 +01 +01 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +03 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +d0 +00 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +05 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +50 +c3 +50 +c3 +50 +c3 +00 +00 +00 +2e +74 +65 +78 +74 +00 +2e +73 +74 +72 +74 +61 +62 +00 +2e +73 +79 +6d +74 +61 +62 +00 +2e +73 +68 +73 +74 +72 +74 +61 +62 +00 +00 +00 +00 +00 +2d +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +f1 +ff +00 +00 +00 +00 +05 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +00 +00 +00 +00 +04 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +00 +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +04 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +17 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +48 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +07 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +6c +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +0f +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +70 +00 +00 +00 +60 +00 +00 +00 +02 +00 +00 +00 +06 +00 +00 +00 +04 +00 +00 +00 +10 +00 +00 +00 +01 +00 +00 +00 +01 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 -- 2.40.0