1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002, 2007 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney.
7 This file is part of GDB.
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
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
25 /* Read a table, line by line, from a file.
27 A table line has several forms:
32 type == table_colon_entry
34 Fields points to a NULL terminated list of pointers.
38 <tab> <text> <nl> { <tab> <text> <nl> }
39 type == table_code_entry
41 The leading tab at the start of each line is discarded.
42 fields[i] is the i'th line with the <nl> discarded.
47 "{" <ignore-text> <nl> { <text> <nl> } "}" <ignore-text> <nl>
48 type == table_code_entry
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.
54 In addition, the table parser reconises and handles internally the
55 following (when not in a code block):
57 "#" <line-nr> '"' <file> '"'
59 As per CPP/CC, treat following lines as if they were taken from
60 <file> starting at <line-nr>
62 No support for CPP's "#if/#else/#endif" style conditions are
65 typedef struct _table table
;
75 typedef struct _table_entry table_entry
;
80 table_entry_type type
;
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
;
95 /* Open/read a table file. Since the file is read once during open
96 (and then closed immediatly) there is no close method. */
98 extern table
*table_open (const char *file_name
);
100 extern table_entry
*table_read (table
*file
);
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 */
106 extern void table_push
107 (table
*file
, line_ref
*line
, table_include
*search
, const char *file_name
);
110 /* Expand the specified field_nr using the internal expansion table.
111 A field is only expanded when explicitly specified. */
113 extern void table_expand_field (table_entry
*entry
, int field_nr
);
116 /* Given a code entry, write the code to FILE. Since any
117 leading/trailing braces were striped as part of the read, they are
120 extern void table_print_code (lf
*file
, table_entry
*entry
);
125 extern void dump_line_ref
126 (lf
*file
, char *prefix
, const line_ref
*line
, char *suffix
);
128 extern void dump_table_entry
129 (lf
*file
, char *prefix
, const table_entry
*entry
, char *suffix
);
133 /* Utilities for skipping around text */
135 extern char *skip_digits (char *chp
);
137 extern char *skip_spaces (char *chp
);
139 extern char *skip_to_separator (char *chp
, char *separators
);
141 extern char *back_spaces (char *start
, char *chp
);