~ubuntu-branches/ubuntu/wily/octave-miscellaneous/wily

« back to all changes in this revision

Viewing changes to src/xmltree_read.l

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2012-10-17 13:40:55 UTC
  • mfrom: (1.1.6)
  • mto: (5.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20121017134055-e8lrxjd3qgcd3kmt
Tags: upstream-1.2.0
Import upstream version 1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Validating XML processor for octave.dtd.
2
 
 * Generated 2004/02/13 14:47:24.
3
 
 *
4
 
 * This program was generated with the FleXML XML processor generator,
5
 
 * (Id: flexml.pl,v 1.28 2003/02/12 02:55:41 krisrose Exp).
6
 
 * Copyright � 1999 Kristoffer Rose.  All rights reserved.
7
 
 *
8
 
 * You can redistribute and/or modify this program provided the following
9
 
 * two conditions hold:
10
 
 *
11
 
 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
12
 
 *    FleXML; without even the implied warranty of MERCHANTABILITY or
13
 
 *    FITNESS FOR A PARTICULAR PURPOSE.
14
 
 *
15
 
 * 2. The program distribution conditions do not in any way affect the
16
 
 *    distribution conditions of the FleXML system used to generate this
17
 
 *    file or any version of FleXML derived from that system.
18
 
 *
19
 
 * Notice that these are explicit rights granted to you for files
20
 
 * generated by the FleXML system.  For your rights in connection with
21
 
 * the FleXML system itself please consult the GNU General Public License.
22
 
 */
23
 
 
24
 
%{
25
 
 
26
 
/* Version strings. */
27
 
const char rcs_flexml_skeleton[] =
28
 
 "$" "Id: skel,v 1.16 1999/12/09 04:01:51 krisrose Exp $";
29
 
const char rcs_flexml[] =
30
 
 "$" "Id: flexml.pl,v 1.28 2003/02/12 02:55:41 krisrose Exp $";
31
 
 
32
 
/* ANSI headers. */
33
 
#include <unistd.h>
34
 
#include <stdio.h>
35
 
#include <string.h>
36
 
#include <assert.h>
37
 
#include <stdarg.h>
38
 
#include <ctype.h>
39
 
 
40
 
/* Generated definitions. */
41
 
#define FLEXML_BUFFERSTACKSIZE 100000
42
 
 
43
 
/* XML application entry points. */
44
 
static void STag_octave(void);
45
 
static void ETag_octave(void);
46
 
static void STag_scalar(void);
47
 
static void ETag_scalar(void);
48
 
static void STag_complex(void);
49
 
static void ETag_complex(void);
50
 
static void STag_string(void);
51
 
static void ETag_string(void);
52
 
static void STag_array(void);
53
 
static void ETag_array(void);
54
 
static void STag_matrix(void);
55
 
static void ETag_matrix(void);
56
 
static void STag_structure(void);
57
 
static void ETag_structure(void);
58
 
static void STag_list(void);
59
 
static void ETag_list(void);
60
 
static void STag_cell(void);
61
 
static void ETag_cell(void);
62
 
 
63
 
/* XML application data. */
64
 
typedef char* AT_list_length;
65
 
#define AU_list_length NULL
66
 
typedef char* AT_matrix_rows;
67
 
#define AU_matrix_rows NULL
68
 
typedef char* AT_matrix_name;
69
 
#define AU_matrix_name NULL
70
 
typedef char* AT_cell_columns;
71
 
#define AU_cell_columns NULL
72
 
typedef char* AT_scalar_name;
73
 
#define AU_scalar_name NULL
74
 
typedef char* AT_array_name;
75
 
#define AU_array_name NULL
76
 
typedef char* AT_complex_name;
77
 
#define AU_complex_name NULL
78
 
typedef char* AT_matrix_columns;
79
 
#define AU_matrix_columns NULL
80
 
typedef char* AT_cell_name;
81
 
#define AU_cell_name NULL
82
 
typedef char* AT_string_length;
83
 
#define AU_string_length NULL
84
 
typedef char* AT_list_name;
85
 
#define AU_list_name NULL
86
 
typedef enum { AU_scalar_value, A_scalar_value_undefined,A_scalar_value_true,A_scalar_value_false,A_scalar_value_inf,A_scalar_value_neginf,A_scalar_value_na,A_scalar_value_nan } AT_scalar_value;
87
 
typedef char* AT_structure_name;
88
 
#define AU_structure_name NULL
89
 
typedef char* AT_cell_rows;
90
 
#define AU_cell_rows NULL
91
 
typedef char* AT_array_rows;
92
 
#define AU_array_rows NULL
93
 
typedef char* AT_string_name;
94
 
#define AU_string_name NULL
95
 
 
96
 
/* FleXML-provided data. */
97
 
static char* pcdata;
98
 
static AT_list_length A_list_length;
99
 
static AT_matrix_rows A_matrix_rows;
100
 
static AT_matrix_name A_matrix_name;
101
 
static AT_cell_columns A_cell_columns;
102
 
static AT_scalar_name A_scalar_name;
103
 
static AT_array_name A_array_name;
104
 
static AT_complex_name A_complex_name;
105
 
static AT_matrix_columns A_matrix_columns;
106
 
static AT_cell_name A_cell_name;
107
 
static AT_string_length A_string_length;
108
 
static AT_list_name A_list_name;
109
 
static AT_scalar_value A_scalar_value;
110
 
static AT_structure_name A_structure_name;
111
 
static AT_cell_rows A_cell_rows;
112
 
static AT_array_rows A_array_rows;
113
 
static AT_string_name A_string_name;
114
 
 
115
 
/* XML state. */
116
 
#ifdef FLEX_DEBUG
117
 
# define ENTER(state)   debug_enter(state,#state)
118
 
# define LEAVE          debug_leave()
119
 
# define SET(state)     debug_set(state,#state)
120
 
  static void debug_enter(int, char*);
121
 
  static void debug_leave(void);
122
 
  static void debug_set(int, char*);
123
 
#else
124
 
# define ENTER(state)   (yy_push_state(state))
125
 
# define LEAVE          (yy_pop_state())
126
 
# define SET(state)     BEGIN(state)
127
 
#endif
128
 
 
129
 
/* Generic actions. */
130
 
#define SKIP    /*skip*/
131
 
#define SUCCEED return 0
132
 
 
133
 
#define FAIL    return fail
134
 
static int fail(const char*, ...);
135
 
 
136
 
/* Text buffer stack handling. */
137
 
char bufferstack[FLEXML_BUFFERSTACKSIZE];
138
 
char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
139
 
typedef struct BufferLast_s {
140
 
  struct BufferLast_s *old; char* saved; char new[1];
141
 
} BufferLast;
142
 
BufferLast* last = (BufferLast*)0;
143
 
char* next = bufferstack;
144
 
 
145
 
#define BUFFERSET(P)  (P = next)
146
 
#define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
147
 
#define BUFFERDONE    (BUFFERPUTC('\0'))
148
 
 
149
 
#define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
150
 
static void bufferliteral(char c, char** pp, char* text)
151
 
{
152
 
  char *s = strchr(text,c), *e = strrchr(text,c);
153
 
  assert(s <= e); BUFFERSET(*pp);
154
 
  while (++s<e) {
155
 
    if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
156
 
    else BUFFERPUTC(*s);
157
 
  } 
158
 
  BUFFERDONE;
159
 
}
160
 
 
161
 
#ifdef FLEXML_HasMixed
162
 
static void pushbuffer(char* p)
163
 
{
164
 
  BufferLast* l = (BufferLast*)next;
165
 
  assert(next < limit);
166
 
  l->old = last;
167
 
  l->saved = p;
168
 
  next = l->new;
169
 
  last = l;
170
 
}
171
 
 
172
 
static char* popbuffer(void)
173
 
{
174
 
  BufferLast* l = last;
175
 
  assert(last != (BufferLast*)0);
176
 
  last = l->old;
177
 
  next = (char*)l;
178
 
  return l->saved;
179
 
}
180
 
#endif
181
 
 
182
 
/* General internal entities are `unput' back onto the input stream... */
183
 
#define ENTITYTEXT(T) \
184
 
  { char *s = (T), *e = s+strlen(s);\
185
 
    while (--e >= s) { unput(*e); }}
186
 
%}
187
 
 
188
 
/* Flex standard options. */
189
 
%option stack
190
 
%option noyy_top_state
191
 
%option noinput
192
 
%option noreject
193
 
%option noyymore
194
 
%option noyywrap
195
 
 
196
 
/* Flex user-requested options. */
197
 
%option nounput
198
 
 
199
 
/* XML character classes (currently restricted to ASCII). */
200
 
 
201
 
/* "Common syntactic structures." */
202
 
S               [ \t\n\r\f]+
203
 
s               [ \t\n\r\f]*
204
 
 
205
 
/* "Names and Tokens." */
206
 
NameChar        [A-Za-z0-9.:_-]
207
 
Name            [A-Za-z_:]{NameChar}*
208
 
Names           {Name}({S}{Name})*
209
 
Nmtoken         ({NameChar})+
210
 
Nmtokens        {Nmtoken}({S}{Nmtoken})*
211
 
 
212
 
/* Miscellaneous. */
213
 
VersionNum      [a-zA-Z0-9_.:-]+
214
 
Eq              {s}"="{s}
215
 
Literal         \'[^'']*\'|\"[^""]*\"
216
 
 
217
 
/* Parser states (flex `exclusive start conditions'):
218
 
 *
219
 
 * PROLOG       the XML prolog of the document before <?xml...>
220
 
 * DOCTYPE      the XML prolog of the document after <?xml...>
221
 
 * EPILOG       after the root element
222
 
 * INCOMMENT    inside an XML comment <!--....-->
223
 
 * INPI         inside an XML PI <?...?>
224
 
 * VALUE1       inside a '...'-delimited literal
225
 
 * VALUE2       inside a "..."-delimited literal
226
 
 * CDATA        inside a <![CDATA[...]]> section.
227
 
 * ROOT_<tag>   expect root element <tag>
228
 
 * AL_<tag>     inside the attribute list for <tag>
229
 
 * IN_<tag>     inside a <tag> with element contents (ready for end tag)
230
 
 * IMPOSSIBLE   dummy to permit disabling rules; must be last
231
 
 */
232
 
%x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
233
 
%x ROOT_octave AL_octave S_octave E_octave
234
 
%x ROOT_scalar AL_scalar IN_scalar
235
 
%x ROOT_complex AL_complex S_complex S_complex_1 E_complex
236
 
%x ROOT_string AL_string IN_string
237
 
%x ROOT_array AL_array S_array S_array_1 S_array_2 S_array_3 E_array
238
 
%x ROOT_matrix AL_matrix S_matrix S_matrix_1 S_matrix_2 E_matrix
239
 
%x ROOT_structure AL_structure IN_structure
240
 
%x ROOT_list AL_list IN_list
241
 
%x ROOT_cell AL_cell IN_cell
242
 
%x IMPOSSIBLE
243
 
 
244
 
%{
245
 
/* State names. */
246
 
char* statenames[IMPOSSIBLE];
247
 
 
248
 
void FleXML_init(void)
249
 
{
250
 
  statenames[PROLOG] = NULL;
251
 
  statenames[DOCTYPE] = NULL;
252
 
  statenames[EPILOG] = NULL;
253
 
  statenames[INCOMMENT] = NULL;
254
 
  statenames[INPI] = NULL;
255
 
  statenames[VALUE1] = NULL;
256
 
  statenames[VALUE2] = NULL;
257
 
  statenames[CDATA] = NULL;
258
 
  statenames[ROOT_octave] = NULL;
259
 
  statenames[AL_octave] = NULL;
260
 
  statenames[S_octave] = "octave";
261
 
  statenames[E_octave] = "octave";
262
 
  statenames[ROOT_scalar] = NULL;
263
 
  statenames[AL_scalar] = NULL;
264
 
  statenames[IN_scalar] = "scalar";
265
 
  statenames[ROOT_complex] = NULL;
266
 
  statenames[AL_complex] = NULL;
267
 
  statenames[S_complex] = "complex";
268
 
  statenames[S_complex_1] = "complex";
269
 
  statenames[E_complex] = "complex";
270
 
  statenames[ROOT_string] = NULL;
271
 
  statenames[AL_string] = NULL;
272
 
  statenames[IN_string] = "string";
273
 
  statenames[ROOT_array] = NULL;
274
 
  statenames[AL_array] = NULL;
275
 
  statenames[S_array] = "array";
276
 
  statenames[S_array_1] = "array";
277
 
  statenames[S_array_2] = "array";
278
 
  statenames[S_array_3] = "array";
279
 
  statenames[E_array] = "array";
280
 
  statenames[ROOT_matrix] = NULL;
281
 
  statenames[AL_matrix] = NULL;
282
 
  statenames[S_matrix] = "matrix";
283
 
  statenames[S_matrix_1] = "matrix";
284
 
  statenames[S_matrix_2] = "matrix";
285
 
  statenames[E_matrix] = "matrix";
286
 
  statenames[ROOT_structure] = NULL;
287
 
  statenames[AL_structure] = NULL;
288
 
  statenames[IN_structure] = "structure";
289
 
  statenames[ROOT_list] = NULL;
290
 
  statenames[AL_list] = NULL;
291
 
  statenames[IN_list] = "list";
292
 
  statenames[ROOT_cell] = NULL;
293
 
  statenames[AL_cell] = NULL;
294
 
  statenames[IN_cell] = "cell";
295
 
}
296
 
%}
297
 
 
298
 
%%
299
 
 
300
 
 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
301
 
 SET(PROLOG); FleXML_init();
302
 
 
303
 
 /* COMMENTS and PIs: handled uniformly for efficiency. */
304
 
 
305
 
<ROOT_octave,AL_octave,S_octave,E_octave,ROOT_scalar,AL_scalar,IN_scalar,ROOT_complex,AL_complex,S_complex,S_complex_1,E_complex,ROOT_string,AL_string,IN_string,ROOT_array,AL_array,S_array,S_array_1,S_array_2,S_array_3,E_array,ROOT_matrix,AL_matrix,S_matrix,S_matrix_1,S_matrix_2,E_matrix,ROOT_structure,AL_structure,IN_structure,ROOT_list,AL_list,IN_list,ROOT_cell,AL_cell,IN_cell,PROLOG,DOCTYPE,EPILOG>{
306
 
 "<!--" ENTER(INCOMMENT);
307
 
 "<?" ENTER(INPI);
308
 
}
309
 
<INCOMMENT>{
310
 
 "-->"          LEAVE;
311
 
 "--"           |
312
 
 .              |
313
 
 \n             SKIP;
314
 
 <<EOF>>        FAIL("EOF in comment.");
315
 
}
316
 
<INPI>{
317
 
 "?>"           LEAVE;
318
 
 .              |
319
 
 \n             SKIP;
320
 
 <<EOF>>        FAIL("EOF in PI (processing instruction).");
321
 
}
322
 
 
323
 
 /* SPACES: skipped uniformly */
324
 
 
325
 
<ROOT_octave,AL_octave,S_octave,E_octave,ROOT_scalar,AL_scalar,ROOT_complex,AL_complex,S_complex,S_complex_1,E_complex,ROOT_string,AL_string,ROOT_array,AL_array,S_array,S_array_1,S_array_2,S_array_3,E_array,ROOT_matrix,AL_matrix,S_matrix,S_matrix_1,S_matrix_2,E_matrix,ROOT_structure,AL_structure,ROOT_list,AL_list,ROOT_cell,AL_cell,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
326
 
 
327
 
 /* PROLOG: determine root element and process it. */
328
 
 
329
 
<PROLOG>{
330
 
 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?"?>" SET(DOCTYPE);
331
 
 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
332
 
}
333
 
 
334
 
<PROLOG,DOCTYPE>{
335
 
 "<!DOCTYPE"{S}"scalar"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_scalar);
336
 
 "<!DOCTYPE"{S}"octave"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_octave);
337
 
 "<!DOCTYPE"{S}"complex"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_complex);
338
 
 "<!DOCTYPE"{S}"string"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_string);
339
 
 "<!DOCTYPE"{S}"matrix"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_matrix);
340
 
 "<!DOCTYPE"{S}"array"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_array);
341
 
 "<!DOCTYPE"{S}"structure"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_structure);
342
 
 "<!DOCTYPE"{S}"cell"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_cell);
343
 
 "<!DOCTYPE"{S}"list"{S}SYSTEM{S}("'octave.dtd'"|"\"octave.dtd\""){s}">" SET(ROOT_list);
344
 
 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
345
 
 .              FAIL("Unexpected character `%c' in prolog.", yytext[0]);
346
 
 <<EOF>>        FAIL("EOF in prolog.");
347
 
}
348
 
 
349
 
 /* RULES DERIVED FROM DTD. */
350
 
 
351
 
<ROOT_octave,IN_list,IN_structure,IN_cell>"<octave"{s} {
352
 
  ENTER(AL_octave);
353
 
  }
354
 
 
355
 
<AL_octave>{
356
 
 ">" {
357
 
  LEAVE; STag_octave(); pcdata = NULL; ENTER(S_octave);
358
 
 }
359
 
 "/>" FAIL("`octave' element cannot be empty.");
360
 
 .       FAIL("Unexpected character `%c' in attribute list of octave element.", yytext[0]);
361
 
 {Name} FAIL("Bad attribute `%s' in `octave' element start tag.",yytext);
362
 
 <<EOF>> FAIL("EOF in attribute list of `octave' element.");
363
 
}
364
 
 
365
 
<E_octave>{
366
 
 "</octave"{s}">" {
367
 
  LEAVE;
368
 
  ETag_octave();
369
 
  switch (YY_START) {
370
 
   case ROOT_octave: SET(EPILOG); break;
371
 
  }
372
 
 }
373
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</octave>' expected.",yytext);
374
 
 .       FAIL("Unexpected character `%c': `</octave>' expected.",yytext[0]);
375
 
 <<EOF>> FAIL("Premature EOF: `</octave>' expected.");
376
 
}
377
 
 
378
 
 /*     value (undefined | true | false | inf | neginf | na | nan) "undefined"
379
 
  *     name CDATA #IMPLIED>  */
380
 
 
381
 
<ROOT_scalar,IN_list,S_matrix_2,IN_cell,S_octave,S_complex,S_matrix_1,S_complex_1,S_matrix,IN_structure>"<scalar"{s} {
382
 
  A_scalar_value = A_scalar_value_undefined;
383
 
  A_scalar_name = NULL;
384
 
  ENTER(AL_scalar);
385
 
  }
386
 
 
387
 
<AL_scalar>{
388
 
 "value"{Eq}"'undefined'" |
389
 
 "value"{Eq}"\"undefined\"" A_scalar_value = A_scalar_value_undefined;
390
 
 "value"{Eq}"'true'" |
391
 
 "value"{Eq}"\"true\"" A_scalar_value = A_scalar_value_true;
392
 
 "value"{Eq}"'false'" |
393
 
 "value"{Eq}"\"false\"" A_scalar_value = A_scalar_value_false;
394
 
 "value"{Eq}"'inf'" |
395
 
 "value"{Eq}"\"inf\"" A_scalar_value = A_scalar_value_inf;
396
 
 "value"{Eq}"'neginf'" |
397
 
 "value"{Eq}"\"neginf\"" A_scalar_value = A_scalar_value_neginf;
398
 
 "value"{Eq}"'na'" |
399
 
 "value"{Eq}"\"na\"" A_scalar_value = A_scalar_value_na;
400
 
 "value"{Eq}"'nan'" |
401
 
 "value"{Eq}"\"nan\"" A_scalar_value = A_scalar_value_nan;
402
 
 
403
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_scalar_name);
404
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_scalar_name);
405
 
 
406
 
 ">" {
407
 
  LEAVE; STag_scalar(); pcdata = BUFFERSET(pcdata); ENTER(IN_scalar);
408
 
 }
409
 
 "/>" {
410
 
  LEAVE; STag_scalar(); pcdata = ""; ETag_scalar();
411
 
  switch (YY_START) {
412
 
   case S_complex_1: SET(E_complex); break;
413
 
   case S_octave: SET(E_octave); break;
414
 
   case S_complex: SET(S_complex_1); break;
415
 
   case S_matrix_1: case S_matrix: case S_matrix_2: SET(S_matrix_2); break;
416
 
   case ROOT_scalar: SET(EPILOG); break;
417
 
  }
418
 
 }
419
 
 .       FAIL("Unexpected character `%c' in attribute list of scalar element.", yytext[0]);
420
 
 {Name} FAIL("Bad attribute `%s' in `scalar' element start tag.",yytext);
421
 
 <<EOF>> FAIL("EOF in attribute list of `scalar' element.");
422
 
}
423
 
 
424
 
<IN_scalar>{
425
 
 "</scalar"{s}">" {
426
 
  LEAVE;
427
 
  BUFFERDONE;
428
 
  ETag_scalar();
429
 
  switch (YY_START) {
430
 
   case S_complex_1: SET(E_complex); break;
431
 
   case S_octave: SET(E_octave); break;
432
 
   case S_complex: SET(S_complex_1); break;
433
 
   case S_matrix_1: case S_matrix: case S_matrix_2: SET(S_matrix_2); break;
434
 
   case ROOT_scalar: SET(EPILOG); break;
435
 
  }
436
 
 }
437
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</scalar>' expected.",yytext);
438
 
 <<EOF>> FAIL("Premature EOF: `</scalar>' expected.");
439
 
}
440
 
 
441
 
<ROOT_complex,IN_list,S_matrix_2,IN_cell,S_octave,S_matrix_1,S_matrix,IN_structure>"<complex"{s} {
442
 
  A_complex_name = NULL;
443
 
  ENTER(AL_complex);
444
 
  }
445
 
 
446
 
<AL_complex>{
447
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_complex_name);
448
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_complex_name);
449
 
 
450
 
 ">" {
451
 
  LEAVE; STag_complex(); pcdata = NULL; ENTER(S_complex);
452
 
 }
453
 
 "/>" FAIL("`complex' element cannot be empty.");
454
 
 .       FAIL("Unexpected character `%c' in attribute list of complex element.", yytext[0]);
455
 
 {Name} FAIL("Bad attribute `%s' in `complex' element start tag.",yytext);
456
 
 <<EOF>> FAIL("EOF in attribute list of `complex' element.");
457
 
}
458
 
 
459
 
<E_complex>{
460
 
 "</complex"{s}">" {
461
 
  LEAVE;
462
 
  ETag_complex();
463
 
  switch (YY_START) {
464
 
   case S_octave: SET(E_octave); break;
465
 
   case S_matrix_1: case S_matrix: case S_matrix_2: SET(S_matrix_2); break;
466
 
   case ROOT_complex: SET(EPILOG); break;
467
 
  }
468
 
 }
469
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</complex>' expected.",yytext);
470
 
 .       FAIL("Unexpected character `%c': `</complex>' expected.",yytext[0]);
471
 
 <<EOF>> FAIL("Premature EOF: `</complex>' expected.");
472
 
}
473
 
 
474
 
 /*     length CDATA #REQUIRED
475
 
  *     name CDATA #IMPLIED>  */
476
 
 
477
 
<ROOT_string,S_array,IN_list,S_array_1,IN_cell,S_octave,S_array_2,S_array_3,IN_structure>"<string"{s} {
478
 
  A_string_length = NULL;
479
 
  A_string_name = NULL;
480
 
  ENTER(AL_string);
481
 
  }
482
 
 
483
 
<AL_string>{
484
 
 "length"{Eq}\' ENTER(VALUE1); BUFFERSET(A_string_length);
485
 
 "length"{Eq}\" ENTER(VALUE2); BUFFERSET(A_string_length);
486
 
 
487
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_string_name);
488
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_string_name);
489
 
 
490
 
 ">" {
491
 
  if (!A_string_length) FAIL("Required attribute `length' not set for `string' element.");
492
 
  LEAVE; STag_string(); pcdata = BUFFERSET(pcdata); ENTER(IN_string);
493
 
 }
494
 
 "/>" {
495
 
  if (!A_string_length) FAIL("Required attribute `length' not set for `string' element.");
496
 
  LEAVE; STag_string(); pcdata = ""; ETag_string();
497
 
  switch (YY_START) {
498
 
   case S_octave: SET(E_octave); break;
499
 
   case S_array_2: case S_array_3: case S_array_1: SET(S_array_3); break;
500
 
   case ROOT_string: SET(EPILOG); break;
501
 
   case S_array: SET(S_array_1); break;
502
 
  }
503
 
 }
504
 
 .       FAIL("Unexpected character `%c' in attribute list of string element.", yytext[0]);
505
 
 {Name} FAIL("Bad attribute `%s' in `string' element start tag.",yytext);
506
 
 <<EOF>> FAIL("EOF in attribute list of `string' element.");
507
 
}
508
 
 
509
 
<IN_string>{
510
 
 "</string"{s}">" {
511
 
  LEAVE;
512
 
  BUFFERDONE;
513
 
  ETag_string();
514
 
  switch (YY_START) {
515
 
   case S_octave: SET(E_octave); break;
516
 
   case S_array_2: case S_array_3: case S_array_1: SET(S_array_3); break;
517
 
   case ROOT_string: SET(EPILOG); break;
518
 
   case S_array: SET(S_array_1); break;
519
 
  }
520
 
 }
521
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</string>' expected.",yytext);
522
 
 <<EOF>> FAIL("Premature EOF: `</string>' expected.");
523
 
}
524
 
 
525
 
 /*     rows CDATA #REQUIRED
526
 
  *     name CDATA #IMPLIED>  */
527
 
 
528
 
<ROOT_array,IN_list,IN_cell,S_octave,IN_structure>"<array"{s} {
529
 
  A_array_rows = NULL;
530
 
  A_array_name = NULL;
531
 
  ENTER(AL_array);
532
 
  }
533
 
 
534
 
<AL_array>{
535
 
 "rows"{Eq}\' ENTER(VALUE1); BUFFERSET(A_array_rows);
536
 
 "rows"{Eq}\" ENTER(VALUE2); BUFFERSET(A_array_rows);
537
 
 
538
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_array_name);
539
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_array_name);
540
 
 
541
 
 ">" {
542
 
  if (!A_array_rows) FAIL("Required attribute `rows' not set for `array' element.");
543
 
  LEAVE; STag_array(); pcdata = NULL; ENTER(S_array);
544
 
 }
545
 
 "/>" FAIL("`array' element cannot be empty.");
546
 
 .       FAIL("Unexpected character `%c' in attribute list of array element.", yytext[0]);
547
 
 {Name} FAIL("Bad attribute `%s' in `array' element start tag.",yytext);
548
 
 <<EOF>> FAIL("EOF in attribute list of `array' element.");
549
 
}
550
 
 
551
 
<S_array_3,E_array>{
552
 
 "</array"{s}">" {
553
 
  LEAVE;
554
 
  ETag_array();
555
 
  switch (YY_START) {
556
 
   case S_octave: SET(E_octave); break;
557
 
   case ROOT_array: SET(EPILOG); break;
558
 
  }
559
 
 }
560
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</array>' expected.",yytext);
561
 
 .       FAIL("Unexpected character `%c': `</array>' expected.",yytext[0]);
562
 
 <<EOF>> FAIL("Premature EOF: `</array>' expected.");
563
 
}
564
 
 
565
 
 /*     rows CDATA #REQUIRED
566
 
  *     columns  CDATA #REQUIRED
567
 
  *     name CDATA #IMPLIED>  */
568
 
 
569
 
<ROOT_matrix,IN_list,IN_cell,IN_structure>"<matrix"{s} {
570
 
  A_matrix_rows = NULL;
571
 
  A_matrix_columns = NULL;
572
 
  A_matrix_name = NULL;
573
 
  ENTER(AL_matrix);
574
 
  }
575
 
 
576
 
<AL_matrix>{
577
 
 "rows"{Eq}\' ENTER(VALUE1); BUFFERSET(A_matrix_rows);
578
 
 "rows"{Eq}\" ENTER(VALUE2); BUFFERSET(A_matrix_rows);
579
 
 
580
 
 "columns"{Eq}\' ENTER(VALUE1); BUFFERSET(A_matrix_columns);
581
 
 "columns"{Eq}\" ENTER(VALUE2); BUFFERSET(A_matrix_columns);
582
 
 
583
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_matrix_name);
584
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_matrix_name);
585
 
 
586
 
 ">" {
587
 
  if (!A_matrix_rows) FAIL("Required attribute `rows' not set for `matrix' element.");
588
 
  if (!A_matrix_columns) FAIL("Required attribute `columns' not set for `matrix' element.");
589
 
  LEAVE; STag_matrix(); pcdata = NULL; ENTER(S_matrix);
590
 
 }
591
 
 "/>" {
592
 
  if (!A_matrix_rows) FAIL("Required attribute `rows' not set for `matrix' element.");
593
 
  if (!A_matrix_columns) FAIL("Required attribute `columns' not set for `matrix' element.");
594
 
  LEAVE; STag_matrix(); pcdata = NULL; ETag_matrix();
595
 
  switch (YY_START) {
596
 
   case ROOT_matrix: SET(EPILOG); break;
597
 
  }
598
 
 }
599
 
 .       FAIL("Unexpected character `%c' in attribute list of matrix element.", yytext[0]);
600
 
 {Name} FAIL("Bad attribute `%s' in `matrix' element start tag.",yytext);
601
 
 <<EOF>> FAIL("EOF in attribute list of `matrix' element.");
602
 
}
603
 
 
604
 
<S_matrix,S_matrix_2,E_matrix>{
605
 
 "</matrix"{s}">" {
606
 
  LEAVE;
607
 
  ETag_matrix();
608
 
  switch (YY_START) {
609
 
   case ROOT_matrix: SET(EPILOG); break;
610
 
  }
611
 
 }
612
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</matrix>' expected.",yytext);
613
 
 .       FAIL("Unexpected character `%c': `</matrix>' expected.",yytext[0]);
614
 
 <<EOF>> FAIL("Premature EOF: `</matrix>' expected.");
615
 
}
616
 
 
617
 
<ROOT_structure,IN_list,IN_cell,S_octave,IN_structure>"<structure"{s} {
618
 
  A_structure_name = NULL;
619
 
  ENTER(AL_structure);
620
 
  }
621
 
 
622
 
<AL_structure>{
623
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_structure_name);
624
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_structure_name);
625
 
 
626
 
 ">" {
627
 
  LEAVE; STag_structure(); pcdata = BUFFERSET(pcdata); ENTER(IN_structure);
628
 
 }
629
 
 "/>" {
630
 
  LEAVE; STag_structure(); pcdata = ""; ETag_structure();
631
 
  switch (YY_START) {
632
 
   case S_octave: SET(E_octave); break;
633
 
   case ROOT_structure: SET(EPILOG); break;
634
 
  }
635
 
 }
636
 
 .       FAIL("Unexpected character `%c' in attribute list of structure element.", yytext[0]);
637
 
 {Name} FAIL("Bad attribute `%s' in `structure' element start tag.",yytext);
638
 
 <<EOF>> FAIL("EOF in attribute list of `structure' element.");
639
 
}
640
 
 
641
 
<IN_structure>{
642
 
 "</structure"{s}">" {
643
 
  LEAVE;
644
 
  BUFFERDONE;
645
 
  ETag_structure();
646
 
  switch (YY_START) {
647
 
   case S_octave: SET(E_octave); break;
648
 
   case ROOT_structure: SET(EPILOG); break;
649
 
  }
650
 
 }
651
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</structure>' expected.",yytext);
652
 
 <<EOF>> FAIL("Premature EOF: `</structure>' expected.");
653
 
}
654
 
 
655
 
 /*     length CDATA #REQUIRED
656
 
  *     name CDATA #IMPLIED>  */
657
 
 
658
 
<ROOT_list,IN_list,IN_cell,S_octave,IN_structure>"<list"{s} {
659
 
  A_list_length = NULL;
660
 
  A_list_name = NULL;
661
 
  ENTER(AL_list);
662
 
  }
663
 
 
664
 
<AL_list>{
665
 
 "length"{Eq}\' ENTER(VALUE1); BUFFERSET(A_list_length);
666
 
 "length"{Eq}\" ENTER(VALUE2); BUFFERSET(A_list_length);
667
 
 
668
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_list_name);
669
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_list_name);
670
 
 
671
 
 ">" {
672
 
  if (!A_list_length) FAIL("Required attribute `length' not set for `list' element.");
673
 
  LEAVE; STag_list(); pcdata = BUFFERSET(pcdata); ENTER(IN_list);
674
 
 }
675
 
 "/>" {
676
 
  if (!A_list_length) FAIL("Required attribute `length' not set for `list' element.");
677
 
  LEAVE; STag_list(); pcdata = ""; ETag_list();
678
 
  switch (YY_START) {
679
 
   case S_octave: SET(E_octave); break;
680
 
   case ROOT_list: SET(EPILOG); break;
681
 
  }
682
 
 }
683
 
 .       FAIL("Unexpected character `%c' in attribute list of list element.", yytext[0]);
684
 
 {Name} FAIL("Bad attribute `%s' in `list' element start tag.",yytext);
685
 
 <<EOF>> FAIL("EOF in attribute list of `list' element.");
686
 
}
687
 
 
688
 
<IN_list>{
689
 
 "</list"{s}">" {
690
 
  LEAVE;
691
 
  BUFFERDONE;
692
 
  ETag_list();
693
 
  switch (YY_START) {
694
 
   case S_octave: SET(E_octave); break;
695
 
   case ROOT_list: SET(EPILOG); break;
696
 
  }
697
 
 }
698
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</list>' expected.",yytext);
699
 
 <<EOF>> FAIL("Premature EOF: `</list>' expected.");
700
 
}
701
 
 
702
 
 /*     rows CDATA #REQUIRED
703
 
  *     columns CDATA #REQUIRED
704
 
  *     name CDATA #IMPLIED>  */
705
 
 
706
 
<ROOT_cell,IN_list,IN_cell,S_octave,IN_structure>"<cell"{s} {
707
 
  A_cell_rows = NULL;
708
 
  A_cell_columns = NULL;
709
 
  A_cell_name = NULL;
710
 
  ENTER(AL_cell);
711
 
  }
712
 
 
713
 
<AL_cell>{
714
 
 "rows"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cell_rows);
715
 
 "rows"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cell_rows);
716
 
 
717
 
 "columns"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cell_columns);
718
 
 "columns"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cell_columns);
719
 
 
720
 
 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cell_name);
721
 
 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cell_name);
722
 
 
723
 
 ">" {
724
 
  if (!A_cell_rows) FAIL("Required attribute `rows' not set for `cell' element.");
725
 
  if (!A_cell_columns) FAIL("Required attribute `columns' not set for `cell' element.");
726
 
  LEAVE; STag_cell(); pcdata = BUFFERSET(pcdata); ENTER(IN_cell);
727
 
 }
728
 
 "/>" {
729
 
  if (!A_cell_rows) FAIL("Required attribute `rows' not set for `cell' element.");
730
 
  if (!A_cell_columns) FAIL("Required attribute `columns' not set for `cell' element.");
731
 
  LEAVE; STag_cell(); pcdata = ""; ETag_cell();
732
 
  switch (YY_START) {
733
 
   case S_octave: SET(E_octave); break;
734
 
   case ROOT_cell: SET(EPILOG); break;
735
 
  }
736
 
 }
737
 
 .       FAIL("Unexpected character `%c' in attribute list of cell element.", yytext[0]);
738
 
 {Name} FAIL("Bad attribute `%s' in `cell' element start tag.",yytext);
739
 
 <<EOF>> FAIL("EOF in attribute list of `cell' element.");
740
 
}
741
 
 
742
 
<IN_cell>{
743
 
 "</cell"{s}">" {
744
 
  LEAVE;
745
 
  BUFFERDONE;
746
 
  ETag_cell();
747
 
  switch (YY_START) {
748
 
   case S_octave: SET(E_octave); break;
749
 
   case ROOT_cell: SET(EPILOG); break;
750
 
  }
751
 
 }
752
 
 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cell>' expected.",yytext);
753
 
 <<EOF>> FAIL("Premature EOF: `</cell>' expected.");
754
 
}
755
 
 
756
 
 /* EPILOG: after the root element. */
757
 
 
758
 
<EPILOG>{
759
 
 .              FAIL("Unexpected character `%c' after document.", yytext[0]);
760
 
 <<EOF>>        SUCCEED;
761
 
}
762
 
 
763
 
 /* CHARACTER DATA. */
764
 
 
765
 
<IN_scalar,IN_structure,IN_string,IN_cell,IN_list,VALUE1,VALUE2>{
766
 
 /* Non-defined standard entities... */
767
 
"&amp;"  BUFFERPUTC('&');
768
 
"&lt;"   BUFFERPUTC('<');
769
 
"&gt;"   BUFFERPUTC('>');
770
 
"&apos;" BUFFERPUTC('\'');
771
 
"&quot;" BUFFERPUTC('"');
772
 
 
773
 
 /* Character entities. */
774
 
 "&#"[[:digit:]]+";"    BUFFERPUTC((unsigned char)atoi(yytext+2));
775
 
 "&#x"[[:xdigit:]]+";"  BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
776
 
}
777
 
 
778
 
<IN_scalar,IN_structure,IN_string,IN_cell,IN_list,VALUE1,VALUE2,CDATA>{
779
 
 "\n"           |
780
 
 "\r"           |
781
 
 "\r\n"         |
782
 
 "\n\r"         BUFFERPUTC('\n');
783
 
}
784
 
 
785
 
<IN_scalar,IN_structure,IN_string,IN_cell,IN_list>{
786
 
 "<![CDATA["    ENTER(CDATA);
787
 
 "]]>"          FAIL("Unexpected `]]>' in character data.");
788
 
}
789
 
 
790
 
<VALUE1>{
791
 
 \'             BUFFERDONE; LEAVE;
792
 
 <<EOF>>        FAIL("EOF in literal (\"'\" expected).");
793
 
}
794
 
 
795
 
<VALUE2>{
796
 
 \"             BUFFERDONE; LEAVE;
797
 
 <<EOF>>        FAIL("EOF in literal (`\"' expected).");
798
 
}
799
 
 
800
 
<IN_scalar,IN_structure,IN_string,IN_cell,IN_list,VALUE1,VALUE2>{
801
 
 [^<&]          BUFFERPUTC(yytext[0]);
802
 
 [<&]           FAIL("Spurious `%c' in character data.",yytext[0]);
803
 
}
804
 
 
805
 
<CDATA>{
806
 
 "]]>"          LEAVE;
807
 
 "]]"           BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]);
808
 
 .              BUFFERPUTC(yytext[0]);
809
 
 <<EOF>>        FAIL("EOF in CDATA section.");
810
 
}
811
 
 
812
 
 /* Impossible rules to avoid warnings from flex(1). */
813
 
 
814
 
<INITIAL,IMPOSSIBLE>{
815
 
 .|[\n] FAIL("The Impossible Happened: INITIAL or IMPOSSIBLE state entered?");
816
 
}
817
 
 
818
 
%%
819
 
 
820
 
/* Element context stack lookup. */
821
 
int element_context(int i)
822
 
{
823
 
  return (0<i && i<yy_start_stack_depth
824
 
          ? yy_start_stack[yy_start_stack_ptr - i]
825
 
          : 0);
826
 
}
827
 
 
828
 
#ifdef FLEX_DEBUG
829
 
void print_yy_stack(char* fmt, ...)
830
 
{
831
 
  int i = 0; va_list ap; va_start(ap, fmt);
832
 
  vfprintf(stderr, fmt, ap);
833
 
  for (i=1; i<yy_start_stack_ptr; i++)
834
 
    fprintf(stderr, "%s/", statenames[yy_start_stack[i]]);
835
 
  fprintf(stderr,"%s\n", statenames[YY_START]);
836
 
  va_end(ap);
837
 
}
838
 
 
839
 
static void debug_enter(int state, char* statename) {
840
 
  yy_push_state(state);
841
 
  if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
842
 
}
843
 
 
844
 
static void debug_leave(void) {
845
 
  if (yy_flex_debug) print_yy_stack("--LEAVE : ");
846
 
  yy_pop_state();
847
 
}
848
 
 
849
 
static void debug_set(int state, char* statename) {
850
 
  BEGIN(state);
851
 
  if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
852
 
}
853
 
#endif
854
 
 
855
 
 
856
 
static int fail(const char* fmt, ...)
857
 
{
858
 
  va_list ap; va_start(ap, fmt);
859
 
#ifdef FLEXML_yylineno
860
 
  fprintf(stderr, "Invalid XML (XML input line %d, state %d): ", yylineno, YY_START);
861
 
#else
862
 
  fprintf(stderr, "Invalid XML (state %d): ",YY_START);
863
 
#endif
864
 
  vfprintf(stderr, fmt, ap);
865
 
  fprintf(stderr, "\n");
866
 
  va_end(ap);
867
 
  return 1;
868
 
}
869
 
 
870
 
#line 30 "xmltree_read.act"
871
 
 
872
 
#ifndef _MSC_VER
873
 
#include <stdlib.h>
874
 
#endif
875
 
#include "xmltree.h"
876
 
 
877
 
#define warning perror
878
 
 
879
 
element **current;
880
 
element *root;
881
 
list *lastlist;
882
 
 
883
 
void STag_octave(void)
884
 
{
885
 
#line 43 "xmltree_read.act"
886
 
 
887
 
root = new_element();
888
 
root->def_value = value_data;
889
 
current = &(root->child);
890
 
 
891
 
lastlist = new_list(lastlist);
892
 
lastlist->root = current;
893
 
 
894
 
} /* STag_octave */
895
 
 
896
 
void ETag_octave(void)
897
 
{
898
 
#line 52 "xmltree_read.act"
899
 
 
900
 
current = lastlist->root;
901
 
lastlist = pop_list(lastlist);
902
 
current = &((*current)->next);
903
 
 
904
 
} /* ETag_octave */
905
 
 
906
 
void STag_scalar(void)
907
 
{
908
 
#line 60 "xmltree_read.act"
909
 
 
910
 
*current = new_element();
911
 
 
912
 
if (A_scalar_name) {
913
 
  (*current)->name = (char *) malloc(strlen(A_scalar_name)+1);
914
 
  strcpy ((*current)->name, A_scalar_name);
915
 
}
916
 
 
917
 
(*current)->def_value = value_scalar;
918
 
switch (A_scalar_value) {
919
 
  case A_scalar_value_true: (*current)->const_value = const_true; break;
920
 
  case A_scalar_value_false: (*current)->const_value = const_false; break;
921
 
  case A_scalar_value_inf: (*current)->const_value = const_inf; break;
922
 
  case A_scalar_value_neginf: (*current)->const_value = const_neginf; break;
923
 
  case A_scalar_value_nan: (*current)->const_value = const_nan; break;
924
 
  case A_scalar_value_na: (*current)->const_value = const_na; break;
925
 
  default: (*current)->const_value = const_undef;
926
 
}
927
 
 
928
 
} /* STag_scalar */
929
 
 
930
 
void ETag_scalar(void)
931
 
{
932
 
#line 80 "xmltree_read.act"
933
 
 
934
 
if (((*current)->const_value == const_undef) && (pcdata))
935
 
  (*current)->scalar_value = strtod (pcdata, NULL);
936
 
 
937
 
(*(lastlist->root))->nb_elements++;
938
 
 
939
 
current = &((*current)->next);
940
 
 
941
 
} /* ETag_scalar */
942
 
 
943
 
void STag_string(void)
944
 
{
945
 
#line 91 "xmltree_read.act"
946
 
 
947
 
*current = new_element();
948
 
 
949
 
if (A_string_name) {
950
 
  (*current)->name = (char *) malloc(strlen(A_string_name)+1);
951
 
  strcpy ((*current)->name, A_string_name);
952
 
}
953
 
 
954
 
if (A_string_length)
955
 
  (*current)->length = strtol (A_string_length, NULL, 10);
956
 
 
957
 
(*current)->def_value = value_string;
958
 
 
959
 
} /* STag_string */
960
 
 
961
 
void ETag_string(void)
962
 
{
963
 
#line 105 "xmltree_read.act"
964
 
 
965
 
if (pcdata) {
966
 
 
967
 
  int len = strlen(pcdata);
968
 
  /* check length parameter */
969
 
  if ((*current)->length != len) {
970
 
    warning("incorrect length parameter for string\n");
971
 
    (*current)->length = len;
972
 
  }
973
 
 
974
 
  (*current)->string_value = (char *) malloc ((len+1) * sizeof(char));
975
 
  strcpy((*current)->string_value, pcdata);
976
 
}
977
 
 
978
 
(*(lastlist->root))->nb_elements++;
979
 
 
980
 
current = &((*current)->next);
981
 
 
982
 
} /* ETag_string */
983
 
 
984
 
void STag_complex(void)
985
 
{
986
 
#line 126 "xmltree_read.act"
987
 
 
988
 
*current = new_element();
989
 
 
990
 
if (A_complex_name) {
991
 
  (*current)->name = (char *) malloc(strlen(A_complex_name)+1);
992
 
  strcpy ((*current)->name, A_complex_name);
993
 
}
994
 
 
995
 
(*current)->def_value = value_complex;
996
 
 
997
 
lastlist = new_list(lastlist);
998
 
lastlist->root = current;
999
 
current = &((*current)->child);
1000
 
 
1001
 
} /* STag_complex */
1002
 
 
1003
 
void ETag_complex(void)
1004
 
{
1005
 
#line 141 "xmltree_read.act"
1006
 
 
1007
 
current = lastlist->root;
1008
 
lastlist = pop_list(lastlist);
1009
 
 
1010
 
(*(lastlist->root))->nb_elements++;
1011
 
 
1012
 
current = &((*current)->next);
1013
 
 
1014
 
} /* ETag_complex */
1015
 
 
1016
 
void STag_array(void)
1017
 
{
1018
 
#line 152 "xmltree_read.act"
1019
 
 
1020
 
*current = new_element();
1021
 
 
1022
 
if (A_array_name) {
1023
 
  (*current)->name = (char *) malloc(strlen(A_array_name)+1);
1024
 
  strcpy ((*current)->name, A_array_name);
1025
 
}
1026
 
 
1027
 
if (A_array_rows)
1028
 
  (*current)->rows = strtol (A_array_rows, NULL, 10);
1029
 
 
1030
 
(*current)->def_value = value_array;
1031
 
 
1032
 
lastlist = new_list(lastlist);
1033
 
lastlist->root = current;
1034
 
current = &((*current)->child);
1035
 
 
1036
 
} /* STag_array */
1037
 
 
1038
 
void ETag_array(void)
1039
 
{
1040
 
#line 170 "xmltree_read.act"
1041
 
 
1042
 
/* check rows parameter */
1043
 
if ((*(lastlist->root))->rows != (*(lastlist->root))->nb_elements) {
1044
 
  warning("incorrect length parameter for array\n");
1045
 
  (*(lastlist->root))->rows = (*(lastlist->root))->nb_elements;
1046
 
}
1047
 
 
1048
 
current = lastlist->root;
1049
 
lastlist = pop_list(lastlist);
1050
 
 
1051
 
(*(lastlist->root))->nb_elements++;
1052
 
 
1053
 
current = &((*current)->next);
1054
 
 
1055
 
} /* ETag_array */
1056
 
 
1057
 
void STag_matrix(void)
1058
 
{
1059
 
#line 187 "xmltree_read.act"
1060
 
 
1061
 
*current = new_element();
1062
 
 
1063
 
if (A_matrix_name) {
1064
 
  (*current)->name = (char *) malloc(strlen(A_matrix_name)+1);
1065
 
  strcpy ((*current)->name, A_matrix_name);
1066
 
}
1067
 
 
1068
 
if (A_matrix_rows)
1069
 
  (*current)->rows = strtol (A_matrix_rows, NULL, 10);
1070
 
 
1071
 
if (A_matrix_columns)
1072
 
  (*current)->columns = strtol (A_matrix_columns, NULL, 10);
1073
 
 
1074
 
(*current)->def_value = value_matrix;
1075
 
 
1076
 
lastlist = new_list(lastlist);
1077
 
lastlist->root = current;
1078
 
current = &((*current)->child);
1079
 
 
1080
 
} /* STag_matrix */
1081
 
 
1082
 
void ETag_matrix(void)
1083
 
{
1084
 
#line 208 "xmltree_read.act"
1085
 
 
1086
 
/* check (rows, columns) parameters */
1087
 
if ((*(lastlist->root))->rows * (*(lastlist->root))->columns != 
1088
 
    (*(lastlist->root))->nb_elements) {
1089
 
  warning("incorrect (rows, columns) parameters for matrix: reshaping matrix into vector\n");
1090
 
  (*(lastlist->root))->rows = 1;
1091
 
  (*(lastlist->root))->columns = (*(lastlist->root))->nb_elements;  
1092
 
}
1093
 
 
1094
 
current = lastlist->root;
1095
 
lastlist = pop_list(lastlist);
1096
 
 
1097
 
(*(lastlist->root))->nb_elements++;
1098
 
 
1099
 
current = &((*current)->next);
1100
 
 
1101
 
} /* ETag_matrix */
1102
 
 
1103
 
void STag_structure(void)
1104
 
{
1105
 
#line 227 "xmltree_read.act"
1106
 
 
1107
 
*current = new_element();
1108
 
 
1109
 
if (A_structure_name) {
1110
 
  (*current)->name = (char *) malloc(strlen(A_structure_name)+1);
1111
 
  strcpy ((*current)->name, A_structure_name);
1112
 
}
1113
 
 
1114
 
(*current)->def_value = value_structure;
1115
 
 
1116
 
lastlist = new_list(lastlist);
1117
 
lastlist->root = current;
1118
 
current = &((*current)->child);
1119
 
 
1120
 
} /* STag_structure */
1121
 
 
1122
 
void ETag_structure(void)
1123
 
{
1124
 
#line 242 "xmltree_read.act"
1125
 
 
1126
 
/* no check possible (sic) */
1127
 
 
1128
 
current = lastlist->root;
1129
 
lastlist = pop_list(lastlist);
1130
 
 
1131
 
(*(lastlist->root))->nb_elements++;
1132
 
 
1133
 
current = &((*current)->next);
1134
 
 
1135
 
} /* ETag_structure */
1136
 
 
1137
 
void STag_list(void)
1138
 
{
1139
 
#line 255 "xmltree_read.act"
1140
 
 
1141
 
*current = new_element();
1142
 
 
1143
 
if (A_list_name) {
1144
 
  (*current)->name = (char *) malloc(strlen(A_list_name)+1);
1145
 
  strcpy ((*current)->name, A_list_name);
1146
 
}
1147
 
 
1148
 
if (A_list_length)
1149
 
  (*current)->length = strtol (A_list_length, NULL, 10);
1150
 
 
1151
 
(*current)->def_value = value_list;
1152
 
 
1153
 
lastlist = new_list(lastlist);
1154
 
lastlist->root = current;
1155
 
current = &((*current)->child);
1156
 
 
1157
 
} /* STag_list */
1158
 
 
1159
 
void ETag_list(void)
1160
 
{
1161
 
#line 273 "xmltree_read.act"
1162
 
 
1163
 
/* check length parameter */
1164
 
if ((*(lastlist->root))->length != (*(lastlist->root))->nb_elements) {
1165
 
  warning("incorrect length parameter for list\n");
1166
 
  (*(lastlist->root))->length = (*(lastlist->root))->nb_elements;
1167
 
}
1168
 
 
1169
 
current = lastlist->root;
1170
 
lastlist = pop_list(lastlist);
1171
 
 
1172
 
(*(lastlist->root))->nb_elements++;
1173
 
 
1174
 
current = &((*current)->next);
1175
 
 
1176
 
} /* ETag_list */
1177
 
 
1178
 
void STag_cell(void)
1179
 
{
1180
 
#line 290 "xmltree_read.act"
1181
 
 
1182
 
*current = new_element();
1183
 
 
1184
 
if (A_cell_name) {
1185
 
  (*current)->name = (char *) malloc(strlen(A_cell_name)+1);
1186
 
  strcpy ((*current)->name, A_cell_name);
1187
 
}
1188
 
 
1189
 
if (A_cell_rows)
1190
 
  (*current)->rows = strtol (A_cell_rows, NULL, 10);
1191
 
 
1192
 
if (A_cell_columns)
1193
 
  (*current)->columns = strtol (A_cell_columns, NULL, 10);
1194
 
 
1195
 
(*current)->def_value = value_cell;
1196
 
 
1197
 
lastlist = new_list(lastlist);
1198
 
lastlist->root = current;
1199
 
current = &((*current)->child);
1200
 
 
1201
 
} /* STag_cell */
1202
 
 
1203
 
void ETag_cell(void)
1204
 
{
1205
 
#line 311 "xmltree_read.act"
1206
 
 
1207
 
/* check (rows, columns) parameters */
1208
 
if ((*(lastlist->root))->rows * (*(lastlist->root))->columns != 
1209
 
    (*(lastlist->root))->nb_elements) {
1210
 
  warning("incorrect (rows, columns) parameters for cell: reshaping cell into list\n");
1211
 
  (*(lastlist->root))->def_value = value_list;
1212
 
  (*(lastlist->root))->length = (*(lastlist->root))->nb_elements;  
1213
 
}
1214
 
 
1215
 
current = lastlist->root;
1216
 
lastlist = pop_list(lastlist);
1217
 
 
1218
 
(*(lastlist->root))->nb_elements++;
1219
 
 
1220
 
current = &((*current)->next);
1221
 
 
1222
 
} /* ETag_cell */
1223
 
 
1224
 
 
1225
 
#line 346 "xmltree_read.act"
1226
 
 
1227
 
element *read_xmltree (const char *file) {
1228
 
 
1229
 
  current = NULL;
1230
 
  root = NULL;
1231
 
  lastlist = NULL;
1232
 
 
1233
 
  xml_in = fopen(file, "r");
1234
 
  if (!xml_in)
1235
 
    perror("can't open file\n");
1236
 
 
1237
 
  xml_lex();
1238
 
  fclose(xml_in);
1239
 
  
1240
 
  return root;
1241
 
}
1242
 
 
1243
 
 
1244
 
/* XML application entry points. */