]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/igen/table.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / sim / igen / table.h
CommitLineData
feaee4bd
AC
1/* The IGEN simulator generator for GDB, the GNU Debugger.
2
213516ef 3 Copyright 2002-2023 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
SS
21
22
23/* Read a table, line by line, from a file.
24
25 A table line has several forms:
26
27 Field line:
28
29 <text> { ":" <text> }
30 type == table_colon_entry
31
32 Fields points to a NULL terminated list of pointers.
33
34 Tab indented block:
35
36 <tab> <text> <nl> { <tab> <text> <nl> }
37 type == table_code_entry
38
39 The leading tab at the start of each line is discarded.
40 fields[i] is the i'th line with the <nl> discarded.
41
42
43 Code block:
44
45 "{" <ignore-text> <nl> { <text> <nl> } "}" <ignore-text> <nl>
46 type == table_code_entry
47
48 The leading/trailing {/} lines are discarded.
49 Lines containing two leading spaces have those spaces striped.
50 fields[i] is the i'th line with the <nl> discarded.
51
52 In addition, the table parser reconises and handles internally the
53 following (when not in a code block):
54
55 "#" <line-nr> '"' <file> '"'
56
57 As per CPP/CC, treat following lines as if they were taken from
58 <file> starting at <line-nr>
59
60 No support for CPP's "#if/#else/#endif" style conditions are
61 planned. */
62
63typedef struct _table table;
64
4e0bf4c4
AC
65typedef enum
66{
c906108c
SS
67 table_colon_entry,
68 table_code_entry,
4e0bf4c4
AC
69}
70table_entry_type;
c906108c
SS
71
72
73typedef struct _table_entry table_entry;
4e0bf4c4
AC
74struct _table_entry
75{
c906108c
SS
76 table *file;
77 line_ref *line;
78 table_entry_type type;
79 int nr_fields;
80 char **field;
81};
82
83/* List of directories to search when opening a pushed file. Current
84 directory is always searched first */
85typedef struct _table_include table_include;
4e0bf4c4
AC
86struct _table_include
87{
c906108c
SS
88 char *dir;
89 table_include *next;
90};
91
92
93/* Open/read a table file. Since the file is read once during open
8eec6289 94 (and then closed immediately) there is no close method. */
c906108c 95
4e0bf4c4 96extern table *table_open (const char *file_name);
c906108c 97
4e0bf4c4 98extern table_entry *table_read (table *file);
c906108c
SS
99
100
101/* Push the the state of the current file and open FILE_NAME. When
102 the end of FILE_NAME is reached, return to the pushed file */
103
104extern void table_push
fa654e74
MF
105 (table *file, const line_ref *line, table_include *search,
106 const char *file_name);
c906108c
SS
107
108
109/* Expand the specified field_nr using the internal expansion table.
110 A field is only expanded when explicitly specified. */
111
4e0bf4c4 112extern void table_expand_field (table_entry *entry, int field_nr);
c906108c
SS
113
114
115/* Given a code entry, write the code to FILE. Since any
116 leading/trailing braces were striped as part of the read, they are
117 not written. */
118
fa654e74 119extern void table_print_code (lf *file, const table_entry *entry);
c906108c
SS
120
121
122/* Debugging */
123
124extern void dump_line_ref
fa654e74 125 (lf *file, const char *prefix, const line_ref *line, const char *suffix);
c906108c
SS
126
127extern void dump_table_entry
fa654e74 128 (lf *file, const char *prefix, const table_entry *entry, const char *suffix);
c906108c
SS
129
130
131
132/* Utilities for skipping around text */
133
4e0bf4c4 134extern char *skip_digits (char *chp);
c906108c 135
4e0bf4c4 136extern char *skip_spaces (char *chp);
c906108c 137
4e0bf4c4 138extern char *skip_to_separator (char *chp, char *separators);
c906108c 139
4e0bf4c4 140extern char *back_spaces (char *start, char *chp);