# HG changeset patch # User Teemu Piippo # Date 1342271579 -10800 # Node ID 1bdbfcca2fc60df59de525949c6ded82e88c5629 # Parent f08abacb46c9f1e98013ed1d2204974f7e91de1a MustString now behaves more like its siblings - sets token to result rather than returning it diff -r f08abacb46c9 -r 1bdbfcca2fc6 commands.cxx --- a/commands.cxx Sat Jul 14 15:58:50 2012 +0300 +++ b/commands.cxx Sat Jul 14 16:12:59 2012 +0300 @@ -121,7 +121,7 @@ r->MustNext ("="); switch (type) { case RETURNVAL_INT: r->MustNumber(); break; - case RETURNVAL_STRING: r->token = r->MustGetString(); break; + case RETURNVAL_STRING: r->MustString(); break; case RETURNVAL_BOOLEAN: r->MustBool(); break; } diff -r f08abacb46c9 -r 1bdbfcca2fc6 parser.cxx --- a/parser.cxx Sat Jul 14 15:58:50 2012 +0300 +++ b/parser.cxx Sat Jul 14 16:12:59 2012 +0300 @@ -61,44 +61,44 @@ while (Next()) { // printf ("got token %s\n", token.chars()); if (!token.compare ("#include")) { - str filepath = MustGetString (); + MustString (); // First ensure that the file can be opened - FILE* newfile = fopen (filepath.chars(), "r"); + FILE* newfile = fopen (token.chars(), "r"); if (!newfile) - ParserError ("couldn't open included file `%s`!", filepath.chars()); + ParserError ("couldn't open included file `%s`!", token.chars()); fclose (newfile); - ScriptReader* newreader = new ScriptReader (filepath.chars()); + ScriptReader* newreader = new ScriptReader (token.chars()); newreader->BeginParse (w); } else if (!token.compare ("state")) { MUST_TOPLEVEL - str statename = MustGetString (); + MustString (); // State name must be a word. - if (statename.first (" ") != statename.len()) - ParserError ("state name must be a single word! got `%s`", (char*)statename); + if (token.first (" ") != token.len()) + ParserError ("state name must be a single word! got `%s`", token.chars()); // Must end in a colon MustNext (":"); w->Write (DH_STATENAME); - w->Write (statename.len()); - w->WriteString (statename); + w->Write (token.len()); + w->WriteString (token); w->Write (DH_STATEIDX); w->Write (g_NumStates); g_NumStates++; - g_CurState = statename; + g_CurState = token; } else if (!token.compare ("event")) { MUST_TOPLEVEL // Event definition - str evname = MustGetString (); + MustString (); - EventDef* e = FindEventByName (evname); + EventDef* e = FindEventByName (token); if (!e) - ParserError ("bad event! got `%s`\n", evname.chars()); + ParserError ("bad event! got `%s`\n", token.chars()); MustNext ("{"); diff -r f08abacb46c9 -r 1bdbfcca2fc6 scriptreader.cxx --- a/scriptreader.cxx Sat Jul 14 15:58:50 2012 +0300 +++ b/scriptreader.cxx Sat Jul 14 16:12:59 2012 +0300 @@ -195,8 +195,7 @@ header, filepath.chars(), curline, curchar, message); } -// I guess this should be a void function putting the return value into token? -str ScriptReader::MustGetString () { +void ScriptReader::MustString () { MustNext ("\""); str string; @@ -213,7 +212,7 @@ string += c; } - return string; + token = string; } void ScriptReader::MustNumber () { diff -r f08abacb46c9 -r 1bdbfcca2fc6 scriptreader.h --- a/scriptreader.h Sat Jul 14 15:58:50 2012 +0300 +++ b/scriptreader.h Sat Jul 14 16:12:59 2012 +0300 @@ -72,7 +72,7 @@ str PeekNext (); void Seek (unsigned int n, int origin); void MustNext (const char* c = ""); - str MustGetString (); + void MustString (); void MustNumber (); void MustBool ();