Sat, 14 Jul 2012 16:12:59 +0300
MustString now behaves more like its siblings - sets token to result rather than returning it
commands.cxx | file | annotate | diff | comparison | revisions | |
parser.cxx | file | annotate | diff | comparison | revisions | |
scriptreader.cxx | file | annotate | diff | comparison | revisions | |
scriptreader.h | file | annotate | diff | comparison | revisions |
--- 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; }
--- 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 ("{");
--- 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 () {