OLD | NEW |
1 /* $Id: gas-parser.h 2167 2009-01-02 08:36:09Z peter $ | 1 /* $Id: gas-parser.h 2279 2010-01-19 07:57:43Z peter $ |
2 * GAS-compatible parser header file | 2 * GAS-compatible parser header file |
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. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 yasm_floatnum *flt; | 57 yasm_floatnum *flt; |
58 yasm_bytecode *bc; | 58 yasm_bytecode *bc; |
59 uintptr_t arch_data; | 59 uintptr_t arch_data; |
60 struct { | 60 struct { |
61 char *contents; | 61 char *contents; |
62 size_t len; | 62 size_t len; |
63 } str; | 63 } str; |
64 } yystype; | 64 } yystype; |
65 #define YYSTYPE yystype | 65 #define YYSTYPE yystype |
66 | 66 |
67 typedef struct gas_rept_line { | |
68 STAILQ_ENTRY(gas_rept_line) link; | |
69 YYCTYPE *data; /* line characters */ | |
70 size_t len; /* length of data */ | |
71 } gas_rept_line; | |
72 | |
73 typedef struct gas_rept { | |
74 STAILQ_HEAD(reptlinelist, gas_rept_line) lines; /* repeated lines */ | |
75 unsigned long startline; /* line number of rept directive */ | |
76 unsigned long numrept; /* number of repititions to generate */ | |
77 unsigned long numdone; /* number of repititions executed so far */ | |
78 /*@null@*/ gas_rept_line *line; /* next line to repeat */ | |
79 size_t linepos; /* position to start pulling chars from line */ | |
80 int ended; /* seen endr directive yet? */ | |
81 | |
82 YYCTYPE *oldbuf; /* saved previous fill buffer */ | |
83 size_t oldbuflen; /* previous fill buffer length */ | |
84 size_t oldbufpos; /* position in previous fill buffer */ | |
85 } gas_rept; | |
86 | |
87 enum gas_parser_state { | 67 enum gas_parser_state { |
88 INITIAL, | 68 INITIAL, |
89 COMMENT, | 69 COMMENT, |
90 SECTION_DIRECTIVE, | 70 SECTION_DIRECTIVE, |
91 NASM_FILENAME | 71 NASM_FILENAME |
92 }; | 72 }; |
93 | 73 |
94 typedef struct yasm_parser_gas { | 74 typedef struct yasm_parser_gas { |
95 /*@only@*/ yasm_object *object; | 75 /*@only@*/ yasm_object *object; |
96 | 76 |
(...skipping 30 matching lines...) Expand all Loading... |
127 | 107 |
128 int token; /* enum tokentype or any character */ | 108 int token; /* enum tokentype or any character */ |
129 yystype tokval; | 109 yystype tokval; |
130 char tokch; /* first character of token */ | 110 char tokch; /* first character of token */ |
131 | 111 |
132 /* one token of lookahead; used sparingly */ | 112 /* one token of lookahead; used sparingly */ |
133 int peek_token; /* NONE if none */ | 113 int peek_token; /* NONE if none */ |
134 yystype peek_tokval; | 114 yystype peek_tokval; |
135 char peek_tokch; | 115 char peek_tokch; |
136 | 116 |
137 /*@null@*/ gas_rept *rept; | |
138 | |
139 /* Index of local labels; what's stored here is the /next/ index, | 117 /* Index of local labels; what's stored here is the /next/ index, |
140 * so these are all 0 at start. | 118 * so these are all 0 at start. |
141 */ | 119 */ |
142 unsigned long local[10]; | 120 unsigned long local[10]; |
143 | 121 |
144 /* Parser-handled directives HAMT lookup */ | 122 /* Parser-handled directives HAMT lookup */ |
145 HAMT *dirs; | 123 HAMT *dirs; |
146 | 124 |
| 125 int intel_syntax; |
| 126 |
147 int is_nasm_preproc; | 127 int is_nasm_preproc; |
148 int is_cpp_preproc; | 128 int is_cpp_preproc; |
149 } yasm_parser_gas; | 129 } yasm_parser_gas; |
150 | 130 |
151 /* shorter access names to commonly used parser_gas fields */ | 131 /* shorter access names to commonly used parser_gas fields */ |
152 #define p_object (parser_gas->object) | 132 #define p_object (parser_gas->object) |
153 #define p_symtab (parser_gas->object->symtab) | 133 #define p_symtab (parser_gas->object->symtab) |
154 #define cursect (parser_gas->object->cur_section) | 134 #define cursect (parser_gas->object->cur_section) |
155 #define curtok (parser_gas->token) | 135 #define curtok (parser_gas->token) |
156 #define curval (parser_gas->tokval) | 136 #define curval (parser_gas->tokval) |
(...skipping 10 matching lines...) Expand all Loading... |
167 #define LABEL_val (curval.str.contents) | 147 #define LABEL_val (curval.str.contents) |
168 #define LABEL_len (curval.str.len) | 148 #define LABEL_len (curval.str.len) |
169 | 149 |
170 #define cur_line (yasm_linemap_get_current(parser_gas->linemap)) | 150 #define cur_line (yasm_linemap_get_current(parser_gas->linemap)) |
171 | 151 |
172 #define p_expr_new(l,o,r) yasm_expr_create(o,l,r,cur_line) | 152 #define p_expr_new(l,o,r) yasm_expr_create(o,l,r,cur_line) |
173 #define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) | 153 #define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) |
174 #define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) | 154 #define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) |
175 #define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) | 155 #define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) |
176 | 156 |
| 157 yasm_bytecode *parse_instr_intel(yasm_parser_gas *parser_gas); |
| 158 |
177 void gas_parser_parse(yasm_parser_gas *parser_gas); | 159 void gas_parser_parse(yasm_parser_gas *parser_gas); |
178 void gas_parser_cleanup(yasm_parser_gas *parser_gas); | 160 void gas_parser_cleanup(yasm_parser_gas *parser_gas); |
179 int gas_parser_lex(YYSTYPE *lvalp, yasm_parser_gas *parser_gas); | 161 int gas_parser_lex(YYSTYPE *lvalp, yasm_parser_gas *parser_gas); |
180 | 162 |
181 #endif | 163 #endif |
OLD | NEW |