/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
+ * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
*/
/* This file is part of Ragel.
machine_name:
TK_Word final {
- //cerr << "parser: machine name" << endl;
-
/* Make/get the priority key. The name may have already been referenced
* and therefore exist. */
PriorDictEl *priorDictEl;
$$->expression = new Expression( $1->expression,
$3->term, Expression::IntersectType );
};
+# This priority specification overrides the innermost parsing strategy which
+# results ordered choice interpretation of the grammar.
expression:
expression pri(1) '-' term final {
$$->expression = new Expression( $1->expression,
term:
term factor_with_label final {
- /* FIXME: Need to reject this if of the form (term . -num). */
$$->term = new Term( $1->term, $2->factorWithAug );
};
term:
{
/* Assign a name to the machine. */
char *machine = word;
- //cerr << "scanner: machine statement: " << machine << endl;
if ( inclSectionTarg == 0 ) {
active = true;
ParserDictEl *pdEl = parserDict.find( machine );
- if ( pdEl != 0 ) {
- //cerr << "scanner: using existing parser" << endl;
- }
- else {
- //cerr << "scanner: creating a new parser" << endl;
+ if ( pdEl == 0 ) {
pdEl = new ParserDictEl( machine );
pdEl->value = new Parser( fileName, machine, sectionLoc );
pdEl->value->init();
parser = pdEl->value;
}
else if ( strcmp( inclSectionTarg, machine ) == 0 ) {
- //cerr << "scanner: found include target" << endl;
+ /* found include target */
active = true;
parser = inclToParser;
}
else {
- //cerr << "scanner: ignoring section" << endl;
+ /* ignoring section */
active = false;
parser = 0;
}
else
inclFileName = fileName;
- /* Open the file and process it. */
- //cerr << "scanner: include: " << inclSectionName << " " << inclFileName << endl;
-
/* Check for a recursive include structure. Add the current file/section
* name then check if what we are including is already in the stack. */
includeStack.append( IncludeStackItem( fileName, parser->sectionName ) );
/* We filled up the buffer trying to scan a token. Grow it. */
bufsize = bufsize * 2;
char *newbuf = new char[bufsize];
- //cerr << "FULL BUFFER, NEW SIZE: " << bufsize << endl;
/* Recompute p and space. */
p = newbuf + have;
/* Check if we failed. */
if ( cs == rlscan_error ) {
- /* Machine failed before finding a token. */
- //cerr << "PARSE ERROR" << endl;
+ /* Machine failed before finding a token. I'm not yet sure if this
+ * is reachable. */
+ error() << "scanner error" << endl;
exit(1);
}