added unistring::operator+=(), working on parser more

This commit is contained in:
Josh Holtrop 2010-04-01 22:33:30 -04:00
parent ed03f19a6d
commit 68a4bf6240
3 changed files with 74 additions and 1 deletions

View File

@ -14,7 +14,8 @@ using namespace std;
void parse_input(refptr< vector<unichar_t> > ucs) void parse_input(refptr< vector<unichar_t> > ucs)
{ {
enum State { INITIAL, SECTION_NAME, RULES }; enum State { INITIAL, SECTION_NAME, RULES, RULE_NAME, RULE_COLON,
RULE_EQUALS, RULE_RHS };
State state = INITIAL; State state = INITIAL;
int lineno = 1; int lineno = 1;
int colno = 1; int colno = 1;
@ -69,6 +70,71 @@ void parse_input(refptr< vector<unichar_t> > ucs)
break; break;
} }
break; break;
case RULES:
if (isspace(c))
{
}
else if ( ('a' <= c && c <= 'z')
|| ('A' <= c && c <= 'Z')
|| (c == '_') )
{
build_str = "";
build_str += c;
state = RULE_NAME;
}
else
{
SET_ERROR("Unexpected character");
}
break;
case RULE_NAME:
if ( ('a' <= c && c <= 'z')
|| ('A' <= c && c <= 'Z')
|| ('0' <= c && c <= '9')
|| (c == '_') )
{
build_str += c;
}
else if (isspace(c))
{
state = RULE_COLON;
}
else
{
SET_ERROR("Expected ':='");
}
break;
case RULE_COLON:
if (isspace(c))
{
}
else if (c == ':')
{
state = RULE_EQUALS;
}
else
{
SET_ERROR("Expected ':='");
}
break;
case RULE_EQUALS:
if (c == '=')
{
state = RULE_RHS;
}
else
{
SET_ERROR("Expected '='");
}
break;
case RULE_RHS:
break;
}
if (error)
{
cerr << errstr << endl;
break;
} }
} }
} }

View File

@ -13,6 +13,12 @@ unistring & unistring::operator=(const char * ascii_str)
return *this; return *this;
} }
unistring & unistring::operator+=(const unichar_t c)
{
chars.push_back(c);
return *this;
}
bool unistring::operator==(const char * ascii_str) bool unistring::operator==(const char * ascii_str)
{ {
int len = chars.size(); int len = chars.size();

View File

@ -10,6 +10,7 @@ class unistring
{ {
public: public:
unistring & operator=(const char * ascii_str); unistring & operator=(const char * ascii_str);
unistring & operator+=(const unichar_t c);
bool operator==(const char * ascii_str); bool operator==(const char * ascii_str);
protected: protected: