parser.cxx

changeset 35
3d3f6ed40171
parent 34
0a9a5902beaa
child 36
a8838b5f1213
equal deleted inserted replaced
34:0a9a5902beaa 35:3d3f6ed40171
435 switch (reqtype) { 435 switch (reqtype) {
436 case TYPE_VOID: 436 case TYPE_VOID:
437 ParserError ("bad syntax"); 437 ParserError ("bad syntax");
438 break; 438 break;
439 case TYPE_INT: { 439 case TYPE_INT: {
440 if (!token.isnumber ()) 440 printf ("value is an integer literal\n");
441 /* if (!token.isnumber ())
441 ParserError ("expected an integer, got `%s`", token.chars()); 442 ParserError ("expected an integer, got `%s`", token.chars());
443 */
444 MustNumber (true);
445 printf ("literal is `%s` = %d\n", token.chars(), atoi (token.chars()));
442 446
443 // All values are written unsigned - thus we need to write the value's 447 // All values are written unsigned - thus we need to write the value's
444 // absolute value, followed by an unary minus if it was negative. 448 // absolute value, followed by an unary minus if it was negative.
445 b->Write<byte> (DH_PUSHNUMBER); 449 b->Write<byte> (DH_PUSHNUMBER);
446 long v = atoi (token.chars ()); 450 long v = atoi (token.chars ());
447 b->Write<byte> (static_cast<byte> (abs (v))); 451 b->Write<byte> (static_cast<byte> (abs (v)));
448 if (v < 0) 452 if (v < 0) {
453 printf ("%ld is negative, write abs value %d and unary minus\n", v, abs(v));
449 b->Write<byte> (DH_UNARYMINUS); 454 b->Write<byte> (DH_UNARYMINUS);
455 }
450 break; 456 break;
451 } 457 }
452 case TYPE_STRING: 458 case TYPE_STRING:
453 // PushToStringTable either returns the string index of the 459 // PushToStringTable either returns the string index of the
454 // string if it finds it in the table, or writes it to the 460 // string if it finds it in the table, or writes it to the

mercurial