]>
Commit | Line | Data |
---|---|---|
feaee4bd AC |
1 | /* The IGEN simulator generator for GDB, the GNU Debugger. |
2 | ||
1d506c26 | 3 | Copyright 2002-2024 Free Software Foundation, Inc. |
feaee4bd AC |
4 | |
5 | Contributed by Andrew Cagney. | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
4744ac1b | 11 | the Free Software Foundation; either version 3 of the License, or |
feaee4bd AC |
12 | (at your option) any later version. |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
4744ac1b | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 21 | |
339e44f8 MF |
22 | #ifndef IGEN_TABLE_H |
23 | #define IGEN_TABLE_H | |
c906108c SS |
24 | |
25 | /* Read a table, line by line, from a file. | |
26 | ||
27 | A table line has several forms: | |
28 | ||
29 | Field line: | |
30 | ||
31 | <text> { ":" <text> } | |
32 | type == table_colon_entry | |
33 | ||
34 | Fields points to a NULL terminated list of pointers. | |
35 | ||
36 | Tab indented block: | |
37 | ||
38 | <tab> <text> <nl> { <tab> <text> <nl> } | |
39 | type == table_code_entry | |
40 | ||
41 | The leading tab at the start of each line is discarded. | |
42 | fields[i] is the i'th line with the <nl> discarded. | |
43 | ||
44 | ||
45 | Code block: | |
46 | ||
47 | "{" <ignore-text> <nl> { <text> <nl> } "}" <ignore-text> <nl> | |
48 | type == table_code_entry | |
49 | ||
50 | The leading/trailing {/} lines are discarded. | |
51 | Lines containing two leading spaces have those spaces striped. | |
52 | fields[i] is the i'th line with the <nl> discarded. | |
53 | ||
54 | In addition, the table parser reconises and handles internally the | |
55 | following (when not in a code block): | |
56 | ||
57 | "#" <line-nr> '"' <file> '"' | |
58 | ||
59 | As per CPP/CC, treat following lines as if they were taken from | |
60 | <file> starting at <line-nr> | |
61 | ||
62 | No support for CPP's "#if/#else/#endif" style conditions are | |
63 | planned. */ | |
64 | ||
65 | typedef struct _table table; | |
66 | ||
4e0bf4c4 AC |
67 | typedef enum |
68 | { | |
c906108c SS |
69 | table_colon_entry, |
70 | table_code_entry, | |
4e0bf4c4 AC |
71 | } |
72 | table_entry_type; | |
c906108c SS |
73 | |
74 | ||
75 | typedef struct _table_entry table_entry; | |
4e0bf4c4 AC |
76 | struct _table_entry |
77 | { | |
c906108c SS |
78 | table *file; |
79 | line_ref *line; | |
80 | table_entry_type type; | |
81 | int nr_fields; | |
82 | char **field; | |
83 | }; | |
84 | ||
85 | /* List of directories to search when opening a pushed file. Current | |
86 | directory is always searched first */ | |
87 | typedef struct _table_include table_include; | |
4e0bf4c4 AC |
88 | struct _table_include |
89 | { | |
c906108c SS |
90 | char *dir; |
91 | table_include *next; | |
92 | }; | |
93 | ||
94 | ||
95 | /* Open/read a table file. Since the file is read once during open | |
8eec6289 | 96 | (and then closed immediately) there is no close method. */ |
c906108c | 97 | |
4e0bf4c4 | 98 | extern table *table_open (const char *file_name); |
c906108c | 99 | |
4e0bf4c4 | 100 | extern table_entry *table_read (table *file); |
c906108c SS |
101 | |
102 | ||
103 | /* Push the the state of the current file and open FILE_NAME. When | |
104 | the end of FILE_NAME is reached, return to the pushed file */ | |
105 | ||
106 | extern void table_push | |
fa654e74 MF |
107 | (table *file, const line_ref *line, table_include *search, |
108 | const char *file_name); | |
c906108c SS |
109 | |
110 | ||
111 | /* Expand the specified field_nr using the internal expansion table. | |
112 | A field is only expanded when explicitly specified. */ | |
113 | ||
4e0bf4c4 | 114 | extern void table_expand_field (table_entry *entry, int field_nr); |
c906108c SS |
115 | |
116 | ||
117 | /* Given a code entry, write the code to FILE. Since any | |
118 | leading/trailing braces were striped as part of the read, they are | |
119 | not written. */ | |
120 | ||
fa654e74 | 121 | extern void table_print_code (lf *file, const table_entry *entry); |
c906108c SS |
122 | |
123 | ||
124 | /* Debugging */ | |
125 | ||
126 | extern void dump_line_ref | |
fa654e74 | 127 | (lf *file, const char *prefix, const line_ref *line, const char *suffix); |
c906108c SS |
128 | |
129 | extern void dump_table_entry | |
fa654e74 | 130 | (lf *file, const char *prefix, const table_entry *entry, const char *suffix); |
c906108c SS |
131 | |
132 | ||
133 | ||
134 | /* Utilities for skipping around text */ | |
135 | ||
4e0bf4c4 | 136 | extern char *skip_digits (char *chp); |
c906108c | 137 | |
4e0bf4c4 | 138 | extern char *skip_spaces (char *chp); |
c906108c | 139 | |
4e0bf4c4 | 140 | extern char *skip_to_separator (char *chp, char *separators); |
c906108c | 141 | |
4e0bf4c4 | 142 | extern char *back_spaces (char *start, char *chp); |
339e44f8 MF |
143 | |
144 | #endif /* IGEN_TABLE_H */ |