2 * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
5 /* This file is part of Ragel.
7 * Ragel is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Ragel is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Ragel; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #define PROGNAME "rlcodegen"
34 /* Target language. */
41 /* Target output style. */
54 /* Filter on the output stream that keeps track of the number of lines
56 class output_filter : public std::filebuf
59 output_filter() : line(1) { }
62 virtual std::streamsize xsputn(const char* s, std::streamsize n);
67 extern OutputFormat outputFormat;
68 extern CodeStyleEnum codeStyle;
70 /* IO filenames and stream. */
71 extern char *outputFileName;
72 extern std::ostream *outStream;
73 extern output_filter *outFilter;
75 extern bool printPrintables;
76 extern bool graphvizDone;
78 int xml_parse( std::istream &input, char *fileName );
80 extern int gblErrorCount;
81 extern char machineMain[];
83 extern int numSplitPartitions;
89 /* Location in an input file. */
110 typedef Vector<AttrMarker> AttrMkList;
111 typedef Vector<Attribute> AttrList;
112 struct XMLTagHashPair;
116 enum TagType { Open, Close };
118 XMLTag( XMLTagHashPair *tagId, TagType type ) :
119 tagId(tagId), type(type),
120 content(0), attrList(0) {}
122 Attribute *findAttr( char *id )
124 if ( attrList != 0 ) {
125 for ( AttrList::Iter attr = *attrList; attr.lte(); attr++ ) {
126 if ( strcmp( id, attr->id ) == 0 )
133 XMLTagHashPair *tagId;
136 /* Content is associtated with closing tags. */
139 /* Attribute lists are associated with opening tags. */
144 std::ostream &error();
145 //std::ostream &error( const YYLTYPE &loc );
146 std::ostream &error( const InputLoc &loc );
147 std::ostream &error( int first_line, int first_column );
148 std::ostream &warning( );
149 std::ostream &warning( const InputLoc &loc );
150 std::ostream &warning( int first_line, int first_column );
151 std::ostream &xml_error( const InputLoc &loc );
152 //std::ostream &xml_error( const YYLTYPE &loc );
156 void openOutput( char *inputFile );
157 char *fileNameFromStem( char *stemFile, char *suffix );
159 /* Size of the include stack. */
160 #define INCLUDE_STACK_SIZE 32
162 #endif /* _RLCODEGEN_H */