| OLD | NEW |
| 1 /* | 1 /* |
| 2 * GAS-compatible re2c lexer | 2 * GAS-compatible re2c lexer |
| 3 * | 3 * |
| 4 * Copyright (C) 2005-2007 Peter Johnson | 4 * Copyright (C) 2005-2007 Peter Johnson |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
| 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 * POSSIBILITY OF SUCH DAMAGE. | 28 * POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 #include <util.h> | 30 #include <util.h> |
| 31 RCSID("$Id: gas-token.re 2266 2010-01-03 22:02:30Z peter $"); | |
| 32 | 31 |
| 33 #include <libyasm.h> | 32 #include <libyasm.h> |
| 34 | 33 |
| 35 #include "modules/parsers/gas/gas-parser.h" | 34 #include "modules/parsers/gas/gas-parser.h" |
| 36 | 35 |
| 37 | 36 |
| 38 #define BSIZE 8192 | 37 #define BSIZE 8192 |
| 39 | 38 |
| 40 #define YYCURSOR cursor | 39 #define YYCURSOR cursor |
| 41 #define YYLIMIT (s->lim) | 40 #define YYLIMIT (s->lim) |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 /* string constant values */ | 515 /* string constant values */ |
| 517 stringconst: | 516 stringconst: |
| 518 strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE); | 517 strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE); |
| 519 strbuf_size = STRBUF_ALLOC_SIZE; | 518 strbuf_size = STRBUF_ALLOC_SIZE; |
| 520 count = 0; | 519 count = 0; |
| 521 | 520 |
| 522 stringconst_scan: | 521 stringconst_scan: |
| 523 SCANINIT(); | 522 SCANINIT(); |
| 524 | 523 |
| 525 /*!re2c | 524 /*!re2c |
| 526 /* Handle escaped double-quote by copying and continuing */ | 525 /* Handle escaped character by copying both and continuing. */ |
| 527 "\\\"" { | 526 "\\". { |
| 528 if (cursor == s->eof) { | 527 if (cursor == s->eof) { |
| 529 yasm_error_set(YASM_ERROR_SYNTAX, | 528 yasm_error_set(YASM_ERROR_SYNTAX, |
| 530 N_("unexpected end of file in string")); | 529 N_("unexpected end of file in string")); |
| 531 lvalp->str.contents = (char *)strbuf; | 530 lvalp->str.contents = (char *)strbuf; |
| 532 lvalp->str.len = count; | 531 lvalp->str.len = count; |
| 533 RETURN(STRING); | 532 RETURN(STRING); |
| 534 } | 533 } |
| 535 strbuf_append(count++, cursor, s, '"'); | 534 strbuf_append(count++, cursor, s, '\\'); |
| 535 strbuf_append(count++, cursor, s, s->tok[1]); |
| 536 goto stringconst_scan; | 536 goto stringconst_scan; |
| 537 } | 537 } |
| 538 | 538 |
| 539 dquot { | 539 dquot { |
| 540 strbuf_append(count, cursor, s, '\0'); | 540 strbuf_append(count, cursor, s, '\0'); |
| 541 yasm_unescape_cstring(strbuf, &count); | 541 yasm_unescape_cstring(strbuf, &count); |
| 542 lvalp->str.contents = (char *)strbuf; | 542 lvalp->str.contents = (char *)strbuf; |
| 543 lvalp->str.len = count; | 543 lvalp->str.len = count; |
| 544 RETURN(STRING); | 544 RETURN(STRING); |
| 545 } | 545 } |
| 546 | 546 |
| 547 any { | 547 any { |
| 548 if (cursor == s->eof) { | 548 if (cursor == s->eof) { |
| 549 yasm_error_set(YASM_ERROR_SYNTAX, | 549 yasm_error_set(YASM_ERROR_SYNTAX, |
| 550 N_("unexpected end of file in string")); | 550 N_("unexpected end of file in string")); |
| 551 lvalp->str.contents = (char *)strbuf; | 551 lvalp->str.contents = (char *)strbuf; |
| 552 lvalp->str.len = count; | 552 lvalp->str.len = count; |
| 553 RETURN(STRING); | 553 RETURN(STRING); |
| 554 } | 554 } |
| 555 strbuf_append(count++, cursor, s, s->tok[0]); | 555 strbuf_append(count++, cursor, s, s->tok[0]); |
| 556 goto stringconst_scan; | 556 goto stringconst_scan; |
| 557 } | 557 } |
| 558 */ | 558 */ |
| 559 } | 559 } |
| OLD | NEW |