/*
- * Copyright 2006-2007 Adrian Thurston <thurston@cs.queensu.ca>
+ * Copyright 2006-2007 Adrian Thurston <thurston@complang.org>
*/
/* This file is part of Ragel.
#include "ragel.h"
#include "rlscan.h"
+#include "inputdata.h"
//#define LOG_TOKENS
/* If no errors and we are at the bottom of the include stack (the
* source file listed on the command line) then write out the data. */
if ( includeDepth == 0 && machineSpec == 0 && machineName == 0 )
- xmlEscapeHost( output, ts, te-ts );
+ id.inputItems.tail->data.write( ts, te-ts );
}
/*
if ( !importMachines && inclSectionTarg == 0 ) {
ignoreSection = false;
- ParserDictEl *pdEl = parserDict.find( machine );
+ ParserDictEl *pdEl = id.parserDict.find( machine );
if ( pdEl == 0 ) {
pdEl = new ParserDictEl( machine );
pdEl->value = new Parser( fileName, machine, sectionLoc );
pdEl->value->init();
- parserDict.insert( pdEl );
+ id.parserDict.insert( pdEl );
+ id.parserList.append( pdEl->value );
}
parser = pdEl->value;
parser->includeHistory.append( IncludeHistoryItem(
includeChecks[found], inclSectionName ) );
- Scanner scanner( includeChecks[found], *inFile, output, parser,
+ Scanner scanner( id, includeChecks[found], *inFile, parser,
inclSectionName, includeDepth+1, false );
scanner.do_scan( );
delete inFile;
scan_error() << "import: attempted: \"" << *tried++ << '\"' << endl;
}
- Scanner scanner( importChecks[found], *inFile, output, parser,
+ Scanner scanner( id, importChecks[found], *inFile, parser,
0, includeDepth+1, true );
scanner.do_scan( );
scanner.importToken( 0, 0, 0 );
action write_command
{
if ( active() && machineSpec == 0 && machineName == 0 ) {
- output << "<write"
- " def_name=\"" << parser->sectionName << "\""
- " line=\"" << line << "\""
- " col=\"" << column << "\""
- ">";
+ InputItem *inputItem = new InputItem;
+ inputItem->type = InputItem::Write;
+ inputItem->loc.line = line;
+ inputItem->loc.col = column;
+ inputItem->name = parser->sectionName;
+ inputItem->pd = parser->pd;
+ id.inputItems.append( inputItem );
}
}
action write_arg
{
if ( active() && machineSpec == 0 && machineName == 0 )
- output << "<arg>" << tokdata << "</arg>";
+ id.inputItems.tail->writeArgs.append( strdup(tokdata) );
}
action write_close
{
if ( active() && machineSpec == 0 && machineName == 0 )
- output << "</write>\n";
+ id.inputItems.tail->writeArgs.append( 0 );
}
write_stmt =
void Scanner::processToken( int type, char *tokdata, int toklen )
{
int *p, *pe, *eof;
-
if ( type < 0 )
p = pe = eof = 0;
{
parserExistsError = false;
- if ( includeDepth == 0 ) {
- if ( machineSpec == 0 && machineName == 0 )
- output << "</host>\n";
- }
-
sectionLoc.fileName = fileName;
sectionLoc.line = line;
- sectionLoc.col = 0;
+ sectionLoc.col = column;
}
void Scanner::endSection( )
InputLoc loc;
loc.fileName = fileName;
loc.line = line;
- loc.col = 0;
+ loc.col = column;
parser->token( loc, TK_EndSection, 0, 0 );
}
if ( machineSpec == 0 && machineName == 0 ) {
/* The end section may include a newline on the end, so
* we use the last line, which will count the newline. */
- output << "<host line=\"" << line << "\">";
+ InputItem *inputItem = new InputItem;
+ inputItem->type = InputItem::HostData;
+ inputItem->loc.line = line;
+ inputItem->loc.col = column;
+ id.inputItems.append( inputItem );
}
}
}
}
/* Search from the include paths given on the command line. */
- for ( ArgsVector::Iter incp = includePaths; incp.lte(); incp++ ) {
+ for ( ArgsVector::Iter incp = id.includePaths; incp.lte(); incp++ ) {
long pathLen = strlen( *incp );
long checkLen = pathLen + 1 + length;
char *check = new char[checkLen+1];
# Parser definitions.
parser_def := |*
+ 'length_cond' => { token( KW_Length ); };
'machine' => { token( KW_Machine ); };
'include' => { token( KW_Include ); };
'import' => { token( KW_Import ); };