File: flexml-act-bootstrap.c

package info (click to toggle)
flexml 1.8-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 592 kB
  • ctags: 225
  • sloc: perl: 1,304; makefile: 294; xml: 188; ansic: 117
file content (97 lines) | stat: -rw-r--r-- 2,364 bytes parent folder | download | duplicates (5)
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
/* Flex(1) XML processor action language application.
 * Copyright (c) 1999 Kristoffer Rose.  All rights reserved.
 * 
 * This file is part of the FleXML XML processor generator system.
 * Copyright (c) 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>

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
#  ifndef __STRICT_ANSI__
#    include <io.h>
#    include <process.h>
#  endif
#else
#  include <unistd.h>
#endif

#include "flexml-act.h"

extern char *bufferstack;
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);
}

const 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();
}