scriptreader.cxx

changeset 67
0a202714eea4
parent 63
0557babc8675
equal deleted inserted replaced
66:4fc1ec88aa41 67:0a202714eea4
329 MustThis (c); 329 MustThis (c);
330 } 330 }
331 331
332 // ============================================================================ 332 // ============================================================================
333 void ScriptReader::MustThis (const char* c) { 333 void ScriptReader::MustThis (const char* c) {
334 if (token.compare (c) != 0) 334 if (token != c)
335 ParserError ("expected `%s`, got `%s` instead", c, token.chars()); 335 ParserError ("expected `%s`, got `%s` instead", c, token.chars());
336 } 336 }
337 337
338 // ============================================================================ 338 // ============================================================================
339 void ScriptReader::ParserError (const char* message, ...) { 339 void ScriptReader::ParserError (const char* message, ...) {
386 void ScriptReader::MustNumber (bool fromthis) { 386 void ScriptReader::MustNumber (bool fromthis) {
387 if (!fromthis) 387 if (!fromthis)
388 MustNext (); 388 MustNext ();
389 389
390 str num = token; 390 str num = token;
391 if (!num.compare ("-")) { 391 if (num == "-") {
392 MustNext (); 392 MustNext ();
393 num += token; 393 num += token;
394 } 394 }
395 395
396 // "true" and "false" are valid numbers 396 // "true" and "false" are valid numbers
402 if (!token.isnumber()) 402 if (!token.isnumber())
403 ParserError ("expected a number, got `%s`", num.chars()); 403 ParserError ("expected a number, got `%s`", num.chars());
404 404
405 str check; 405 str check;
406 check.appendformat ("%d", atoi (num)); 406 check.appendformat ("%d", atoi (num));
407 if (token.compare (check) != 0) 407 if (token != check)
408 ParserWarning ("integer too large: %s -> %s", num.chars(), check.chars()); 408 ParserWarning ("integer too large: %s -> %s", num.chars(), check.chars());
409 409
410 token = num; 410 token = num;
411 } 411 }
412 } 412 }

mercurial