srecord: input/file/mif.h Source File

srecord 1.65.0

Loading...
Searching...
No Matches
mif.h
Go to the documentation of this file.
1//
2// srecord - Manipulate EPROM load files
3// Copyright (C) 2009-2011, 2013 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or (at
8// 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 GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef SRECORD_INPUT_FILE_MIF_H
20#define SRECORD_INPUT_FILE_MIF_H
21
22#include <srecord/input/file.h>
23
24namespace srecord {
25
26/**
27 * The srecord::input_file_mif class is used to represent the parse state
28 * when reading a Memory Initialization File (MIF) formatted file.
29 */
30 class input_file_mif:
31 public input_file
32{
33public:
34 /**
35 * The destructor.
36 */
37 virtual ~input_file_mif();
38
39 /**
40 * The create class method is used to create new dynamically
41 * allocated instances of this class.
42 *
43 * @param file_name
44 * The name of the file to be read.
45 * @returns
46 * smart pointer to new instance
47 */
48 static pointer create(const std::string &file_name);
49
50protected:
51 // See base class for documentation.
52 bool read(record &record);
53
54 // See base class for documentation.
55 const char *get_file_format_name(void) const;
56
57 // See base class for documentation.
58 int format_option_number(void) const;
59
60private:
61 /**
62 * The constructor.
63 * It is private on putpose, use the #create class method instead.
64 *
65 * @param file_name
66 * The name of the file to be read.
67 */
68 input_file_mif(const std::string &file_name);
69
70 enum state_t
71 {
72 state_header,
73 state_eof,
74 state_address,
75 state_data
76 };
77
78 /**
79 * The state instance variable is used to remember the parse state
80 * as we progress through the file.
81 */
82 state_t state;
83
84 /**
85 * The address instance variable is used to remember where we are
86 * up to in the input file, so it may be associated with data bytes.
87 */
88 unsigned long address;
89
90 /**
91 * The lex_radix instance variable is used to remember the numeric
92 * radix to be used when parsing numbers.
93 */
94 unsigned lex_radix;
95
96 /**
97 * The lex_addr_radix instance variable is used to remember the
98 * numeric radix to be used when parsing address values.
99 */
100 unsigned lex_addr_radix;
101
102 /**
103 * The lex_data_radix instance variable is used to remember the
104 * numeric radix to be used when parsing data values.
105 */
106 unsigned lex_data_radix;
107
108 enum token_t
109 {
110 token_address_radix,
111 token_begin,
112 token_bin,
113 token_bracket_left,
114 token_bracket_right,
115 token_colon,
116 token_content,
117 token_data_radix,
118 token_dec,
119 token_depth,
120 token_dot,
121 token_dotdot,
122 token_end,
123 token_eof,
124 token_equals,
125 token_hex,
126 token_junk,
127 token_minus,
128 token_number,
129 token_oct,
130 token_semicolon,
131 token_width
132 };
133
134 /**
135 * The lex method is used to obtain the next lexical token from the
136 * input stream.
137 */
138 token_t lex(void);
139
140 /**
141 * The token_value instance variable is used to remember the
142 * numeric value of token_number returns from #lex.
143 */
144 long token_value;
145
146 /**
147 * The lex_addr method is used to obtain the next lexical token
148 * from the input stream, using the address radix.
149 */
150 token_t lex_addr(void);
151
152 /**
153 * The lex_data method is used to obtain the next lexical token
154 * from the input stream, using the data radix.
155 */
156 token_t lex_data(void);
157
158 /**
159 * The syntax_error method is used to report parse errors when
160 * reading the file.
161 *
162 * @param text
163 * The text of the error message.
164 */
165 void syntax_error(const char *text);
166
167 void get_equals(void);
168 long get_number(void);
169 void get_semicolon(void);
170 int get_radix(void);
171 void get_colon(void);
172
173 unsigned width;
174 unsigned width_in_bytes;
175
176 /**
177 * The default constructor. Do not use.
178 */
179 input_file_mif();
180
181 /**
182 * The copy constructor. Do not use.
183 */
184 input_file_mif(const input_file_mif &);
185
186 /**
187 * The assignment operator. Do not use.
188 */
189 input_file_mif &operator=(const input_file_mif &);
190};
191
192};
193
194// vim: set ts=8 sw=4 et :
195#endif // SRECORD_INPUT_FILE_MIF_H
srecord::input_file_mif::~input_file_mif
virtual ~input_file_mif()
The destructor.
srecord::input_file_mif::format_option_number
int format_option_number(void) const
The format_option_number method is used to obtain the option number, which can then be turned into te...
srecord::input_file_mif::create
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
srecord::input_file_mif::read
bool read(record &record)
The read method is used to read one record from the input.
srecord::input_file_mif::get_file_format_name
const char * get_file_format_name(void) const
The get_file_format_name method is used to find out the name of the file format being read.
srecord::input_file::input_file
input_file(const std::string &file_name)
The constructor.
srecord::input_file::pointer
std::shared_ptr< input_file > pointer
Definition file.h:39
srecord::record
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35
file.h
srecord
Definition adler16.h:25