File: flexml-act-bootstrap.c%2Cv

package info (click to toggle)
flexml 1-5
  • links: PTS
  • area: main
  • in suites: potato, woody
  • size: 884 kB
  • ctags: 203
  • sloc: perl: 2,016; makefile: 160; ansic: 56; xml: 28
file content (210 lines) | stat: -rw-r--r-- 3,616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
head	1.6;
access;
symbols;
locks; strict;
comment	@ * @;


1.6
date	99.11.25.18.42.03;	author krisrose;	state Exp;
branches;
next	1.5;

1.5
date	99.11.25.03.01.47;	author krisrose;	state Exp;
branches;
next	1.4;

1.4
date	99.11.23.17.28.07;	author krisrose;	state Exp;
branches;
next	1.3;

1.3
date	99.11.23.10.10.36;	author krisrose;	state Exp;
branches;
next	1.2;

1.2
date	99.11.23.09.32.31;	author krisrose;	state Exp;
branches;
next	1.1;

1.1
date	99.11.23.04.03.05;	author krisrose;	state Exp;
branches;
next	;


desc
@New.
@


1.6
log
@Stand-alone mode added and documented; still technical section to write.
@
text
@/* Flex(1) XML processor action language application.
 * Copyright  1999 Kristoffer Rose.  All rights reserved.
 * 
 * This file is part of the FleXML XML processor generator system.
 * Copyright  1999 Kristoffer Rose.  All rights reserved.
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "flexml-act.h"

extern FILE* yyin;
extern int yylineno;
extern int yylex(void);

char* filename;

void STag_top(void)
{
  printf("\n#line %d \"%s\"\n", yylineno, filename);
}
void ETag_top(void)
{
  printf("%s\n", pcdata);
}

char* tag;

void STag_start(void)
{
  printf("void STag_%s(void)\n{", tag = A_start_tag);
  printf("\n#line %d \"%s\"\n", yylineno, filename);
}
void ETag_start(void)
{
  printf("%s\n} /* STag_%s */\n\n", pcdata, tag);
}

void STag_end(void)
{
  printf("void ETag_%s(void)\n{", tag = A_end_tag);
  printf("\n#line %d \"%s\"\n", yylineno, filename);
}
void ETag_end(void)
{
  printf("%s\n} /* ETag_%s */\n\n", pcdata, tag);
}

char mainmissing = 1;

void STag_main(void) {}
void ETag_main(void)
{
  printf("\n#line %d \"%s\"\n", yylineno, filename);
  printf("%s\n", pcdata);
  mainmissing = 0;
}

void STag_actions(void) {}
void ETag_actions(void) {
  if (mainmissing) {
    printf("/* Dummy main: filter XML from stdin. */\n");
    printf("int main() { exit(yylex()); }\n");
  }
}

int main(int argc, char** argv)
{
  filename = argv[1];
  yyin = fopen(filename,"r");
  return yylex();
}
@


1.5
log
@Almost ready...
@
text
@d76 4
a79 2
  if (mainmissing)
    printf("\nint main() { extern int yylex(void); exit(yylex()); }\n");
@


1.4
log
@Works but manual/paper still in flux...
@
text
@d27 10
a36 1
void STag_top(void) {}
d47 1
d51 1
a51 1
  printf("%s} /* STag_%s */\n\n", pcdata, tag);
d57 1
d69 1
a79 3
extern FILE* yyin;
extern int yylex(void);

d82 2
a83 4
  if (argc != 2)
    fprintf(stderr, "Usage: %s action-file.\n", argv[0]), exit(2);
  
  yyin = fopen(argv[1],"r");
@


1.3
log
@Spellling mistakes fixed...
@
text
@d27 1
d51 15
@


1.2
log
@Documentation updated.
@
text
@d4 1
a4 1
 * This file is part of the FleXML XML processer generator system.
@


1.1
log
@Works for simple examples
@
text
@a4 1
 * See the companion README and INSTALL files for further information.
d29 1
a29 1
  printf("%s", pcdata);
d50 12
@