OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [sim/] [igen/] [table.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.