OLD | NEW |
1 /* | 1 /* |
2 * GAS-compatible parser | 2 * GAS-compatible parser |
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 /*@unused@*/ RCSID("$Id: gas-parser.c 2167 2009-01-02 08:36:09Z peter $"); | 31 /*@unused@*/ RCSID("$Id: gas-parser.c 2279 2010-01-19 07:57:43Z peter $"); |
32 | 32 |
33 #include <libyasm.h> | 33 #include <libyasm.h> |
34 | 34 |
35 #include "gas-parser.h" | 35 #include "gas-parser.h" |
36 | 36 |
37 | 37 |
38 static void | 38 static void |
39 gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, | 39 gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, |
40 int save_input, yasm_linemap *linemap, | 40 int save_input, yasm_linemap *linemap, |
41 yasm_errwarns *errwarns) | 41 yasm_errwarns *errwarns) |
(...skipping 22 matching lines...) Expand all Loading... |
64 | 64 |
65 parser_gas.peek_token = NONE; | 65 parser_gas.peek_token = NONE; |
66 | 66 |
67 parser_gas.line = NULL; | 67 parser_gas.line = NULL; |
68 | 68 |
69 /* initialize scanner structure */ | 69 /* initialize scanner structure */ |
70 yasm_scanner_initialize(&parser_gas.s); | 70 yasm_scanner_initialize(&parser_gas.s); |
71 | 71 |
72 parser_gas.state = INITIAL; | 72 parser_gas.state = INITIAL; |
73 | 73 |
74 parser_gas.rept = NULL; | |
75 | |
76 for (i=0; i<10; i++) | 74 for (i=0; i<10; i++) |
77 parser_gas.local[i] = 0; | 75 parser_gas.local[i] = 0; |
78 | 76 |
| 77 parser_gas.intel_syntax = 0; |
| 78 |
79 parser_gas.is_cpp_preproc = | 79 parser_gas.is_cpp_preproc = |
80 yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "cpp") == 0; | 80 yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "cpp") == 0; |
81 parser_gas.is_nasm_preproc = | 81 parser_gas.is_nasm_preproc = |
82 yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "nasm") == 0
; | 82 yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "nasm") == 0
; |
83 | 83 |
84 gas_parser_parse(&parser_gas); | 84 gas_parser_parse(&parser_gas); |
85 | 85 |
86 /* Check for ending inside a rept */ | |
87 if (parser_gas.rept) { | |
88 yasm_error_set(YASM_ERROR_SYNTAX, N_("rept without matching endr")); | |
89 yasm_errwarn_propagate(errwarns, parser_gas.rept->startline); | |
90 } | |
91 | |
92 /* Check for ending inside a comment */ | 86 /* Check for ending inside a comment */ |
93 if (parser_gas.state == COMMENT) { | 87 if (parser_gas.state == COMMENT) { |
94 yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment")); | 88 yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment")); |
95 /* XXX: Minus two to compensate for already having moved past the EOF | 89 /* XXX: Minus two to compensate for already having moved past the EOF |
96 * in the linemap. | 90 * in the linemap. |
97 */ | 91 */ |
98 yasm_errwarn_propagate(errwarns, | 92 yasm_errwarn_propagate(errwarns, |
99 yasm_linemap_get_current(parser_gas.linemap)-2); | 93 yasm_linemap_get_current(parser_gas.linemap)-2); |
100 } | 94 } |
101 | 95 |
102 yasm_scanner_delete(&parser_gas.s); | 96 yasm_scanner_delete(&parser_gas.s); |
103 | 97 |
104 /* Free locallabel base if necessary */ | 98 /* Free locallabel base if necessary */ |
105 if (parser_gas.locallabel_base) | 99 if (parser_gas.locallabel_base) |
106 yasm_xfree(parser_gas.locallabel_base); | 100 yasm_xfree(parser_gas.locallabel_base); |
107 | 101 |
108 if (parser_gas.dir_file) | 102 if (parser_gas.dir_file) |
109 yasm_xfree(parser_gas.dir_file); | 103 yasm_xfree(parser_gas.dir_file); |
110 | 104 |
111 /* Convert all undefined symbols into extern symbols */ | 105 /* Convert all undefined symbols into extern symbols */ |
112 yasm_symtab_parser_finalize(object->symtab, 1, errwarns); | 106 yasm_symtab_parser_finalize(object->symtab, 1, errwarns); |
113 } | 107 } |
114 | 108 |
115 /* Define valid preprocessors to use with this parser */ | 109 /* Define valid preprocessors to use with this parser */ |
116 static const char *gas_parser_preproc_keywords[] = { | 110 static const char *gas_parser_preproc_keywords[] = { |
| 111 "gas", |
117 "raw", | 112 "raw", |
118 "cpp", | 113 "cpp", |
119 "nasm", | 114 "nasm", |
120 NULL | 115 NULL |
121 }; | 116 }; |
122 | 117 |
123 /* Define parser structure -- see parser.h for details */ | 118 /* Define parser structure -- see parser.h for details */ |
124 yasm_parser_module yasm_gas_LTX_parser = { | 119 yasm_parser_module yasm_gas_LTX_parser = { |
125 "GNU AS (GAS)-compatible parser", | 120 "GNU AS (GAS)-compatible parser", |
126 "gas", | 121 "gas", |
127 gas_parser_preproc_keywords, | 122 gas_parser_preproc_keywords, |
128 "raw", | 123 "gas", |
129 NULL, /* No standard macros */ | 124 NULL, /* No standard macros */ |
130 gas_parser_do_parse | 125 gas_parser_do_parse |
131 }; | 126 }; |
132 yasm_parser_module yasm_gnu_LTX_parser = { | 127 yasm_parser_module yasm_gnu_LTX_parser = { |
133 "GNU AS (GAS)-compatible parser", | 128 "GNU AS (GAS)-compatible parser", |
134 "gnu", | 129 "gnu", |
135 gas_parser_preproc_keywords, | 130 gas_parser_preproc_keywords, |
136 "raw", | 131 "gas", |
137 NULL, /* No standard macros */ | 132 NULL, /* No standard macros */ |
138 gas_parser_do_parse | 133 gas_parser_do_parse |
139 }; | 134 }; |
OLD | NEW |