2002-11-21 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / sim / igen / table.h
CommitLineData
feaee4bd
AC
1/* The IGEN simulator generator for GDB, the GNU Debugger.
2
3 Copyright 2002 Free Software Foundation, Inc.
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
11 the Free Software Foundation; either version 2 of the License, or
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
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. */
c906108c
SS
23
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
65typedef struct _table table;
66
67typedef enum {
68 table_colon_entry,
69 table_code_entry,
70} table_entry_type;
71
72
73typedef struct _table_entry table_entry;
74struct _table_entry {
75 table *file;
76 line_ref *line;
77 table_entry_type type;
78 int nr_fields;
79 char **field;
80};
81
82/* List of directories to search when opening a pushed file. Current
83 directory is always searched first */
84typedef struct _table_include table_include;
85struct _table_include {
86 char *dir;
87 table_include *next;
88};
89
90
91/* Open/read a table file. Since the file is read once during open
92 (and then closed immediatly) there is no close method. */
93
94extern table *table_open
95(const char *file_name);
96
97extern table_entry *table_read
98(table *file);
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
105(table *file,
106 line_ref *line,
107 table_include *search,
108 const char *file_name);
109
110
111/* Expand the specified field_nr using the internal expansion table.
112 A field is only expanded when explicitly specified. */
113
114extern void table_expand_field
115(table_entry *entry,
116 int field_nr);
117
118
119/* Given a code entry, write the code to FILE. Since any
120 leading/trailing braces were striped as part of the read, they are
121 not written. */
122
123extern void table_print_code
124(lf *file,
125 table_entry *entry);
126
127
128/* Debugging */
129
130extern void dump_line_ref
131(lf *file,
132 char *prefix,
133 const line_ref *line,
134 char *suffix);
135
136extern void dump_table_entry
137(lf *file,
138 char *prefix,
139 const table_entry *entry,
140 char *suffix);
141
142
143
144/* Utilities for skipping around text */
145
146extern char *skip_digits
147(char *chp);
148
149extern char *skip_spaces
150(char *chp);
151
152extern char *skip_to_separator
153(char *chp,
154 char *separators);
155
156extern char *back_spaces
157(char *start,
158 char *chp);
This page took 0.154754 seconds and 4 git commands to generate.