#include "parsetree.h"
#include "mergesort.h"
#include "xmlcodegen.h"
+#include "version.h"
using namespace std;
fileName(fileName),
sectionName(sectionName),
sectionLoc(sectionLoc),
- errorCount(0),
curActionOrd(0),
curPriorOrd(0),
rootName(0),
/* Set the alphabet type. If the types are not valid returns false. */
bool ParseData::setAlphType( char *s1, char *s2 )
{
- bool valid = false;
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
- hostLang->hostTypes[i].data2 != 0 &&
- strcmp( s2, hostLang->hostTypes[i].data2 ) == 0 )
- {
- valid = true;
- userAlphType = hostLang->hostTypes + i;
- break;
- }
- }
-
+ userAlphType = findAlphType( s1, s2 );
alphTypeSet = true;
- return valid;
+ return userAlphType != 0;
}
/* Set the alphabet type. If the types are not valid returns false. */
bool ParseData::setAlphType( char *s1 )
{
- bool valid = false;
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
- hostLang->hostTypes[i].data2 == 0 )
- {
- valid = true;
- userAlphType = hostLang->hostTypes + i;
- break;
- }
- }
-
+ userAlphType = findAlphType( s1 );
alphTypeSet = true;
- return valid;
+ return userAlphType != 0;
}
bool ParseData::setVariable( char *var, InlineList *inlineList )
void writeLanguage( std::ostream &out )
{
out << " lang=\"";
- switch ( hostLangType ) {
- case CCode: out << "C"; break;
- case DCode: out << "D"; break;
- case JavaCode: out << "Java"; break;
- case RubyCode: out << "Ruby"; break;
+ switch ( hostLang->lang ) {
+ case HostLang::C: out << "C"; break;
+ case HostLang::D: out << "D"; break;
+ case HostLang::Java: out << "Java"; break;
+ case HostLang::Ruby: out << "Ruby"; break;
}
out << "\"";
}
if ( gblErrorCount == 0 ) {
- out << "<ragel filename=\"" << inputFileName << "\"";
+ out << "<ragel version=\"" VERSION "\" filename=\"" << inputFileName << "\"";
writeLanguage( out );
out << ">\n";
for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) {
/* Section/Machine to emit was found. Prepare and emit it. */
parseData->prepareMachineGen( graphDictEl );
if ( gblErrorCount == 0 ) {
- out << "<ragel filename=\"" << inputFileName << "\"";
+ out << "<ragel version=\"" VERSION "\" filename=\"" << inputFileName << "\"";
writeLanguage( out );
out << ">\n";
parseData->generateXML( out );