fixed bug in SECTION_NAME rule

This commit is contained in:
Josh Holtrop 2010-04-01 22:36:22 -04:00
parent 68a4bf6240
commit 2f06a95257
4 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,7 @@
#include "refptr/refptr.h" #include "refptr/refptr.h"
#include "serialize.h" #include "serialize.h"
#include "unicode.h" #include "unicode.h"
#include "parse-input.h"
using namespace std; using namespace std;
int main(int argc, char * argv[]) int main(int argc, char * argv[])
@ -37,12 +38,14 @@ int main(int argc, char * argv[])
cerr << "Error opening input file: '" << argv[optind] << "'"; cerr << "Error opening input file: '" << argv[optind] << "'";
return 2; return 2;
} }
refptr< vector<unichar_t> > ucs_str = deserialize(encoding, ifs); refptr< vector<unichar_t> > ucs = deserialize(encoding, ifs);
if (ucs_str.isNull()) if (ucs.isNull())
{ {
cerr << "Error deserializing input file." << endl; cerr << "Error deserializing input file." << endl;
return 1; return 1;
} }
parse_input(ucs);
return 0; return 0;
} }

View File

@ -68,6 +68,9 @@ void parse_input(refptr< vector<unichar_t> > ucs)
case '\n': case '\n':
SET_ERROR("Unterminated section header"); SET_ERROR("Unterminated section header");
break; break;
default:
build_str += c;
break;
} }
break; break;
case RULES: case RULES:

11
testinput.i Normal file
View File

@ -0,0 +1,11 @@
[rules]
ASSIGN := ":="
DASSIGN := ":=="
IDENTIFIER := "[a-zA-Z_][a-zA-Z_0-9]*"
Assignment := IDENTIFIER ASSIGN Expression
Expression := IDENTIFIER
| Assignment

View File

@ -1,5 +1,6 @@
#ifndef UNICODE_H #ifndef UNICODE_H
#define UNICODE_H
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>