2
* GAS-compatible parser header file
4
* Copyright (C) 2005-2007 Peter Johnson
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* 3. Neither the name of the author nor the names of other contributors
15
* may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
22
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
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
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
28
* POSSIBILITY OF SUCH DAMAGE.
30
#ifndef YASM_GAS_PARSER_H
31
#define YASM_GAS_PARSER_H
33
#define YYCTYPE unsigned char
35
#define MAX_SAVED_LINE_LEN 80
55
unsigned int int_info;
65
#define YYSTYPE yystype
67
enum gas_parser_state {
74
typedef struct yasm_parser_gas {
75
/*@only@*/ yasm_object *object;
77
/* last "base" label for local (.) labels */
78
/*@null@*/ char *locallabel_base;
79
size_t locallabel_base_len;
81
/* .line/.file: we have to see both to start setting linemap versions */
83
/*@null@*/ char *dir_file;
84
unsigned long dir_line;
86
/* Have we seen a line marker? */
89
/*@dependent@*/ yasm_preproc *preproc;
90
/*@dependent@*/ yasm_errwarns *errwarns;
92
/*@dependent@*/ yasm_linemap *linemap;
94
/*@null@*/ yasm_bytecode *prev_bc;
95
yasm_bytecode *temp_bc;
98
YYCTYPE save_line[2][MAX_SAVED_LINE_LEN];
101
/* Line data storage used in preproc_input(). */
102
char *line, *linepos;
106
enum gas_parser_state state;
108
int token; /* enum tokentype or any character */
110
char tokch; /* first character of token */
112
/* one token of lookahead; used sparingly */
113
int peek_token; /* NONE if none */
117
/* Index of local labels; what's stored here is the /next/ index,
118
* so these are all 0 at start.
120
unsigned long local[10];
122
/* Parser-handled directives HAMT lookup */
131
/* shorter access names to commonly used parser_gas fields */
132
#define p_object (parser_gas->object)
133
#define p_symtab (parser_gas->object->symtab)
134
#define cursect (parser_gas->object->cur_section)
135
#define curtok (parser_gas->token)
136
#define curval (parser_gas->tokval)
138
#define INTNUM_val (curval.intn)
139
#define FLTNUM_val (curval.flt)
140
#define STRING_val (curval.str)
141
#define REG_val (curval.arch_data)
142
#define REGGROUP_val (curval.arch_data)
143
#define SEGREG_val (curval.arch_data)
144
#define TARGETMOD_val (curval.arch_data)
145
#define ID_val (curval.str.contents)
146
#define ID_len (curval.str.len)
147
#define LABEL_val (curval.str.contents)
148
#define LABEL_len (curval.str.len)
150
#define cur_line (yasm_linemap_get_current(parser_gas->linemap))
152
#define p_expr_new(l,o,r) yasm_expr_create(o,l,r,cur_line)
153
#define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line)
154
#define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line)
155
#define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line)
157
yasm_bytecode *parse_instr_intel(yasm_parser_gas *parser_gas);
159
void gas_parser_parse(yasm_parser_gas *parser_gas);
160
void gas_parser_cleanup(yasm_parser_gas *parser_gas);
161
int gas_parser_lex(YYSTYPE *lvalp, yasm_parser_gas *parser_gas);