A fix to the documentation makefile from John D. Mitchell.
[ragel.git] / ragel / rlscan.h
blob430bef6b1d53a86fa94e15285b2321767b4991fe
1 /*
2 * Copyright 2007 Adrian Thurston <thurston@cs.queensu.ca>
3 */
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
22 #ifndef _RLSCAN_H
23 #define _RLSCAN_H
25 #include <iostream>
26 #include "rlscan.h"
27 #include "vector.h"
28 #include "rlparse.h"
29 #include "parsedata.h"
30 #include "avltree.h"
31 #include "vector.h"
33 using std::istream;
34 using std::ostream;
36 extern char *Parser_lelNames[];
38 struct Scanner
40 Scanner( const char *fileName, istream &input, ostream &output,
41 Parser *inclToParser, char *inclSectionTarg,
42 int includeDepth, bool importMachines )
44 fileName(fileName), input(input), output(output),
45 inclToParser(inclToParser),
46 inclSectionTarg(inclSectionTarg),
47 includeDepth(includeDepth),
48 importMachines(importMachines),
49 cur_token(0),
50 line(1), column(1), lastnl(0),
51 parser(0), ignoreSection(false),
52 parserExistsError(false),
53 whitespaceOn(true),
54 lastToken(0)
57 bool duplicateInclude( char *inclFileName, char *inclSectionName );
59 /* Make a list of places to look for an included file. */
60 char **makeIncludePathChecks( const char *curFileName, const char *fileName, int len );
61 std::ifstream *tryOpenInclude( char **pathChecks, long &found );
63 void handleMachine();
64 void handleInclude();
65 void handleImport();
67 void init();
68 void token( int type, char *start, char *end );
69 void token( int type, char c );
70 void token( int type );
71 void processToken( int type, char *tokdata, int toklen );
72 void directToParser( Parser *toParser, const char *tokFileName, int tokLine,
73 int tokColumn, int type, char *tokdata, int toklen );
74 void flushImport( );
75 void importToken( int type, char *start, char *end );
76 void pass( int token, char *start, char *end );
77 void pass();
78 void updateCol();
79 void startSection();
80 void endSection();
81 void do_scan();
82 bool active();
83 ostream &scan_error();
85 const char *fileName;
86 istream &input;
87 ostream &output;
88 Parser *inclToParser;
89 char *inclSectionTarg;
90 int includeDepth;
91 bool importMachines;
93 /* For import parsing. */
94 int tok_cs, tok_act;
95 int *tok_ts, *tok_te;
96 int cur_token;
97 static const int max_tokens = 32;
98 int token_data[max_tokens];
99 char *token_strings[max_tokens];
100 int token_lens[max_tokens];
102 /* For section processing. */
103 int cs;
104 char *word, *lit;
105 int word_len, lit_len;
107 /* For character scanning. */
108 int line;
109 InputLoc sectionLoc;
110 char *ts, *te;
111 int column;
112 char *lastnl;
114 /* Set by machine statements, these persist from section to section
115 * allowing for unnamed sections. */
116 Parser *parser;
117 bool ignoreSection;
119 /* This is set if ragel has already emitted an error stating that
120 * no section name has been seen and thus no parser exists. */
121 bool parserExistsError;
123 /* This is for inline code. By default it is on. It goes off for
124 * statements and values in inline blocks which are parsed. */
125 bool whitespaceOn;
127 /* Keeps a record of the previous token sent to the section parser. */
128 int lastToken;
131 #endif /* _RLSCAN_H */