using std::istream;
using std::ostream;
-struct ImportScanner
-{
- ImportScanner( char *fileName, istream &input, ostream &output, Parser *parser )
- :
- fileName(fileName), input(input), output(output),
- parser(parser),
- cur_token(0),
- line(1), column(1)
- {}
-
- void token( int type, char *start, char *end );
- void updateCol();
- void startSection();
- void endSection();
- void do_scan();
- ostream &scan_error();
-
- char *fileName;
- istream &input;
- ostream &output;
- Parser *parser;
-
- /* For scanning the tokens. */
- int tok_cs, tok_act;
- int *tok_tokstart, *tok_tokend;
- int cur_token;
- static const int max_tokens = 8;
- int token_data[max_tokens];
-
- /* For scanning the characters. */
- int line;
- char *chr_tokstart, *chr_tokend;
- int column;
-};
-
-
extern char *Parser_lelNames[];
-/* This is used for tracking the current stack of include file/machine pairs. It is
- * is used to detect and recursive include structure. */
-struct IncludeStackItem
-{
- IncludeStackItem( char *fileName, char *sectionName )
- : fileName(fileName), sectionName(sectionName) {}
-
- char *fileName;
- char *sectionName;
-};
-
-typedef Vector<IncludeStackItem> IncludeStack;
-
struct Scanner
{
- Scanner( char *fileName, istream &input, ostream &output,
+ Scanner( const char *fileName, istream &input, ostream &output,
Parser *inclToParser, char *inclSectionTarg,
- int includeDepth )
+ int includeDepth, bool importMachines )
:
fileName(fileName), input(input), output(output),
inclToParser(inclToParser),
inclSectionTarg(inclSectionTarg),
includeDepth(includeDepth),
+ importMachines(importMachines),
+ cur_token(0),
line(1), column(1), lastnl(0),
parser(0), ignoreSection(false),
parserExistsError(false),
lastToken(0)
{}
- bool recursiveInclude( char *inclFileName, char *inclSectionName );
+ bool duplicateInclude( char *inclFileName, char *inclSectionName );
+
+ /* Make a list of places to look for an included file. */
+ char **makeIncludePathChecks( const char *curFileName, const char *fileName, int len );
+ std::ifstream *tryOpenInclude( char **pathChecks, long &found );
- char *prepareFileName( char *fileName, int len )
- {
- bool caseInsensitive;
- Token tokenFnStr, tokenRes;
- tokenFnStr.data = fileName;
- tokenFnStr.length = len;
- tokenFnStr.prepareLitString( tokenRes, caseInsensitive );
- return tokenRes.data;
- }
+ void handleMachine();
+ void handleInclude();
+ void handleImport();
void init();
void token( int type, char *start, char *end );
void token( int type, char c );
void token( int type );
+ void processToken( int type, char *tokdata, int toklen );
+ void directToParser( Parser *toParser, const char *tokFileName, int tokLine,
+ int tokColumn, int type, char *tokdata, int toklen );
+ void flushImport( );
+ void importToken( int type, char *start, char *end );
+ void pass( int token, char *start, char *end );
+ void pass();
void updateCol();
void startSection();
void endSection();
bool active();
ostream &scan_error();
- char *fileName;
+ const char *fileName;
istream &input;
ostream &output;
Parser *inclToParser;
char *inclSectionTarg;
int includeDepth;
+ bool importMachines;
+
+ /* For import parsing. */
+ int tok_cs, tok_act;
+ int *tok_ts, *tok_te;
+ int cur_token;
+ static const int max_tokens = 32;
+ int token_data[max_tokens];
+ char *token_strings[max_tokens];
+ int token_lens[max_tokens];
/* For section processing. */
int cs;
/* For character scanning. */
int line;
InputLoc sectionLoc;
- char *tokstart, *tokend;
+ char *ts, *te;
int column;
char *lastnl;
* allowing for unnamed sections. */
Parser *parser;
bool ignoreSection;
- IncludeStack includeStack;
/* This is set if ragel has already emitted an error stating that
* no section name has been seen and thus no parser exists. */