File: rlcodegen.h

package info (click to toggle)
ragel 5.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,628 kB
  • ctags: 4,619
  • sloc: cpp: 15,187; ansic: 3,490; yacc: 1,921; makefile: 411; sh: 146; awk: 6
file content (126 lines) | stat: -rw-r--r-- 2,793 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
/*
 *  Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
 */

/*  This file is part of Ragel.
 *
 *  Ragel 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.
 * 
 *  Ragel 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 Ragel; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */

#ifndef _RLCODEGEN_H
#define _RLCODEGEN_H

#include <stdio.h>
#include <iostream>
#include <fstream>
#include "avltree.h"
#include "vector.h"
#include "config.h"

#define PROGNAME "rlcodegen"

/* Target language. */
enum OutputFormat
{
	OutCode,
	OutGraphvizDot
};

/* Target output style. */
enum CodeStyleEnum
{
	GenTables,
	GenFTables,
	GenFlat,
	GenFFlat,
	GenGoto,
	GenFGoto,
	GenIpGoto,
	GenSplit
};

/* Filter on the output stream that keeps track of the number of lines
 * output. */
class output_filter : public std::filebuf
{
public:
	output_filter() : line(1) { }

	virtual int sync();
	virtual std::streamsize xsputn(const char* s, std::streamsize n);

	int line;
};
	
extern OutputFormat outputFormat;
extern CodeStyleEnum codeStyle;

extern FILE *yyin;

/* IO filenames and stream. */
extern char *outputFile;
extern std::ostream *outStream;
extern output_filter *outFilter;

extern bool printPrintables;
extern bool graphvizDone;

void yyerror( char *error );
int yyparse();

extern int gblErrorCount;
extern char machineMain[];

extern int numSplitPartitions;

/* 
 * Error reporting. 
 */

struct YYLTYPE;

#ifndef INPUT_LOC
#define INPUT_LOC
/* Location in an input file. */
struct InputLoc
{
	InputLoc( ) 
		: line(0), col(0) { }
	InputLoc( int line, int col ) 
		: line(line), col(col) { }
	InputLoc( const YYLTYPE &loc );

	int line;
	int col;
};
#endif /* INPUT_LOC */

std::ostream &error();
std::ostream &error( const YYLTYPE &loc ); 
std::ostream &error( const InputLoc &loc ); 
std::ostream &error( int first_line, int first_column );
std::ostream &warning( ); 
std::ostream &warning( const InputLoc &loc ); 
std::ostream &warning( int first_line, int first_column );
std::ostream &xml_error( const InputLoc &loc );
std::ostream &xml_error( const YYLTYPE &loc ); 

void openOutput( char *inputFile );
char *fileNameFromStem( char *stemFile, char *suffix );

/* Size of the include stack. */
#define INCLUDE_STACK_SIZE 32

#endif /* _RLCODEGEN_H */