2 * Copyright 2007 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
29 #include "parsedata.h"
36 extern char *Parser_lelNames[];
38 /* This is used for tracking the current stack of include file/machine pairs. It is
39 * is used to detect and recursive include structure. */
40 struct IncludeStackItem
42 IncludeStackItem( char *fileName, char *sectionName )
43 : fileName(fileName), sectionName(sectionName) {}
49 typedef Vector<IncludeStackItem> IncludeStack;
53 Scanner( char *fileName, istream &input, ostream &output,
54 Parser *inclToParser, char *inclSectionTarg,
57 fileName(fileName), input(input), output(output),
58 inclToParser(inclToParser),
59 inclSectionTarg(inclSectionTarg),
60 includeDepth(includeDepth),
61 line(1), column(1), lastnl(0),
62 parser(0), ignoreSection(false),
63 parserExistsError(false),
68 bool recursiveInclude( char *inclFileName, char *inclSectionName );
70 char *prepareFileName( char *fileName, int len )
73 Token tokenFnStr, tokenRes;
74 tokenFnStr.data = fileName;
75 tokenFnStr.length = len;
76 tokenFnStr.prepareLitString( tokenRes, caseInsensitive );
81 void token( int type, char *start, char *end );
82 void token( int type, char c );
83 void token( int type );
89 ostream &scan_error();
95 char *inclSectionTarg;
101 int word_len, lit_len;
103 char *tokstart, *tokend;
107 /* Set by machine statements, these persist from section to section
108 * allowing for unnamed sections. */
111 IncludeStack includeStack;
113 /* This is set if ragel has already emitted an error stating that
114 * no section name has been seen and thus no parser exists. */
115 bool parserExistsError;
117 /* This is for inline code. By default it is on. It goes off for
118 * statements and values in inline blocks which are parsed. */
121 /* Keeps a record of the previous token sent to the section parser. */
125 #endif /* _RLSCAN_H */