thread-protect egg loader

This commit is contained in:
David Rose 2006-08-30 23:15:32 +00:00
parent 0592e39b81
commit 03900c447c
7 changed files with 376 additions and 230 deletions

View File

@ -28,6 +28,7 @@
#include "string_utils.h"
#include "dSearchPath.h"
#include "virtualFileSystem.h"
#include "mutexHolder.h"
#include "zStream.h"
extern int eggyyparse();
@ -122,16 +123,22 @@ read(istream &in) {
// it with a copy of ourselves, so that it will get our _coordsys
// value, if the user set it.
PT(EggData) data = new EggData(*this);
egg_init_parser(in, get_egg_filename(), data, data);
eggyyparse();
egg_cleanup_parser();
int error_count;
{
MutexHolder holder(egg_lock);
egg_init_parser(in, get_egg_filename(), data, data);
eggyyparse();
egg_cleanup_parser();
error_count = egg_error_count();
}
data->post_read();
steal_children(*data);
(*this) = *data;
return (egg_error_count() == 0);
return (error_count == 0);
}
////////////////////////////////////////////////////////////////////

View File

@ -257,6 +257,9 @@ parse_egg(const string &egg_syntax) {
}
istringstream in(egg_syntax);
MutexHolder holder(egg_lock);
egg_init_parser(in, "", this, group);
if (!egg_start_parse_body()) {

View File

@ -727,16 +727,16 @@ char *yytext;
////////////////////////////////////////////////////////////////////
*/
#line 9 "lexer.lxx"
#include "pandabase.h"
#include "lexerDefs.h"
#include "parserDefs.h"
#include "config_egg.h"
#include "parser.h"
#include "indent.h"
#include "pnotify.h"
#include "pmutex.h"
#include <math.h>
#include "pandabase.h"
extern "C" int eggyywrap(void); // declared below.
@ -747,6 +747,9 @@ static int yyinput(void); // declared by flex.
// Static variables
////////////////////////////////////////////////////////////////////
// This mutex protects all of these global variables.
Mutex egg_lock;
// We'll increment line_number and col_number as we parse the file, so
// that we can report the position of an error.
static int line_number = 0;
@ -771,7 +774,6 @@ static string egg_filename;
// the yacc grammar to start from initial points.
static int initial_token;
////////////////////////////////////////////////////////////////////
// Defining the interface to the lexer.
////////////////////////////////////////////////////////////////////
@ -1002,7 +1004,7 @@ INLINE void accept() {
col_number += yyleng;
}
#line 1007 "lex.yy.c"
#line 1009 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -1164,7 +1166,7 @@ YY_DECL
register char *yy_cp, *yy_bp;
register int yy_act;
#line 290 "lexer.lxx"
#line 292 "lexer.lxx"
@ -1175,7 +1177,7 @@ YY_DECL
}
#line 1180 "lex.yy.c"
#line 1182 "lex.yy.c"
if ( yy_init )
{
@ -1260,7 +1262,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 300 "lexer.lxx"
#line 302 "lexer.lxx"
{
// New line. Save a copy of the line so we can print it out for the
// benefit of the user in case we get an error.
@ -1277,7 +1279,7 @@ YY_RULE_SETUP
YY_BREAK
case 2:
YY_RULE_SETUP
#line 314 "lexer.lxx"
#line 316 "lexer.lxx"
{
// Eat whitespace.
accept();
@ -1285,7 +1287,7 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
#line 319 "lexer.lxx"
#line 321 "lexer.lxx"
{
// Eat C++-style comments.
accept();
@ -1293,7 +1295,7 @@ YY_RULE_SETUP
YY_BREAK
case 4:
YY_RULE_SETUP
#line 324 "lexer.lxx"
#line 326 "lexer.lxx"
{
// Eat C-style comments.
accept();
@ -1302,7 +1304,7 @@ YY_RULE_SETUP
YY_BREAK
case 5:
YY_RULE_SETUP
#line 330 "lexer.lxx"
#line 332 "lexer.lxx"
{
// Send curly braces as themselves.
accept();
@ -1311,7 +1313,7 @@ YY_RULE_SETUP
YY_BREAK
case 6:
YY_RULE_SETUP
#line 338 "lexer.lxx"
#line 340 "lexer.lxx"
{
accept();
return BEZIERCURVE;
@ -1319,7 +1321,7 @@ YY_RULE_SETUP
YY_BREAK
case 7:
YY_RULE_SETUP
#line 342 "lexer.lxx"
#line 344 "lexer.lxx"
{
accept();
return BFACE;
@ -1327,7 +1329,7 @@ YY_RULE_SETUP
YY_BREAK
case 8:
YY_RULE_SETUP
#line 346 "lexer.lxx"
#line 348 "lexer.lxx"
{
accept();
return BILLBOARD;
@ -1335,7 +1337,7 @@ YY_RULE_SETUP
YY_BREAK
case 9:
YY_RULE_SETUP
#line 350 "lexer.lxx"
#line 352 "lexer.lxx"
{
accept();
return BILLBOARDCENTER;
@ -1343,7 +1345,7 @@ YY_RULE_SETUP
YY_BREAK
case 10:
YY_RULE_SETUP
#line 354 "lexer.lxx"
#line 356 "lexer.lxx"
{
accept();
return BINORMAL;
@ -1351,7 +1353,7 @@ YY_RULE_SETUP
YY_BREAK
case 11:
YY_RULE_SETUP
#line 358 "lexer.lxx"
#line 360 "lexer.lxx"
{
accept();
return BUNDLE;
@ -1359,7 +1361,7 @@ YY_RULE_SETUP
YY_BREAK
case 12:
YY_RULE_SETUP
#line 362 "lexer.lxx"
#line 364 "lexer.lxx"
{
accept();
return SCALAR;
@ -1367,7 +1369,7 @@ YY_RULE_SETUP
YY_BREAK
case 13:
YY_RULE_SETUP
#line 366 "lexer.lxx"
#line 368 "lexer.lxx"
{
accept();
return CLOSED;
@ -1375,7 +1377,7 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
#line 370 "lexer.lxx"
#line 372 "lexer.lxx"
{
accept();
return COLLIDE;
@ -1383,7 +1385,7 @@ YY_RULE_SETUP
YY_BREAK
case 15:
YY_RULE_SETUP
#line 374 "lexer.lxx"
#line 376 "lexer.lxx"
{
accept();
return COMMENT;
@ -1391,7 +1393,7 @@ YY_RULE_SETUP
YY_BREAK
case 16:
YY_RULE_SETUP
#line 378 "lexer.lxx"
#line 380 "lexer.lxx"
{
accept();
return COMPONENT;
@ -1399,7 +1401,7 @@ YY_RULE_SETUP
YY_BREAK
case 17:
YY_RULE_SETUP
#line 382 "lexer.lxx"
#line 384 "lexer.lxx"
{
accept();
return COORDSYSTEM;
@ -1407,7 +1409,7 @@ YY_RULE_SETUP
YY_BREAK
case 18:
YY_RULE_SETUP
#line 386 "lexer.lxx"
#line 388 "lexer.lxx"
{
accept();
return CV;
@ -1415,7 +1417,7 @@ YY_RULE_SETUP
YY_BREAK
case 19:
YY_RULE_SETUP
#line 390 "lexer.lxx"
#line 392 "lexer.lxx"
{
accept();
return DART;
@ -1423,7 +1425,7 @@ YY_RULE_SETUP
YY_BREAK
case 20:
YY_RULE_SETUP
#line 394 "lexer.lxx"
#line 396 "lexer.lxx"
{
accept();
return DNORMAL;
@ -1431,7 +1433,7 @@ YY_RULE_SETUP
YY_BREAK
case 21:
YY_RULE_SETUP
#line 398 "lexer.lxx"
#line 400 "lexer.lxx"
{
accept();
return DRGBA;
@ -1439,7 +1441,7 @@ YY_RULE_SETUP
YY_BREAK
case 22:
YY_RULE_SETUP
#line 402 "lexer.lxx"
#line 404 "lexer.lxx"
{
accept();
return DUV;
@ -1447,7 +1449,7 @@ YY_RULE_SETUP
YY_BREAK
case 23:
YY_RULE_SETUP
#line 406 "lexer.lxx"
#line 408 "lexer.lxx"
{
accept();
return DXYZ;
@ -1455,7 +1457,7 @@ YY_RULE_SETUP
YY_BREAK
case 24:
YY_RULE_SETUP
#line 410 "lexer.lxx"
#line 412 "lexer.lxx"
{
accept();
return DCS;
@ -1463,7 +1465,7 @@ YY_RULE_SETUP
YY_BREAK
case 25:
YY_RULE_SETUP
#line 414 "lexer.lxx"
#line 416 "lexer.lxx"
{
accept();
return DISTANCE;
@ -1471,7 +1473,7 @@ YY_RULE_SETUP
YY_BREAK
case 26:
YY_RULE_SETUP
#line 418 "lexer.lxx"
#line 420 "lexer.lxx"
{
accept();
return DTREF;
@ -1479,7 +1481,7 @@ YY_RULE_SETUP
YY_BREAK
case 27:
YY_RULE_SETUP
#line 422 "lexer.lxx"
#line 424 "lexer.lxx"
{
accept();
return DYNAMICVERTEXPOOL;
@ -1487,7 +1489,7 @@ YY_RULE_SETUP
YY_BREAK
case 28:
YY_RULE_SETUP
#line 426 "lexer.lxx"
#line 428 "lexer.lxx"
{
accept();
return EXTERNAL_FILE;
@ -1495,7 +1497,7 @@ YY_RULE_SETUP
YY_BREAK
case 29:
YY_RULE_SETUP
#line 430 "lexer.lxx"
#line 432 "lexer.lxx"
{
accept();
return FLIGHT;
@ -1503,7 +1505,7 @@ YY_RULE_SETUP
YY_BREAK
case 30:
YY_RULE_SETUP
#line 434 "lexer.lxx"
#line 436 "lexer.lxx"
{
accept();
return GROUP;
@ -1511,7 +1513,7 @@ YY_RULE_SETUP
YY_BREAK
case 31:
YY_RULE_SETUP
#line 438 "lexer.lxx"
#line 440 "lexer.lxx"
{
accept();
return HIP;
@ -1519,7 +1521,7 @@ YY_RULE_SETUP
YY_BREAK
case 32:
YY_RULE_SETUP
#line 442 "lexer.lxx"
#line 444 "lexer.lxx"
{
accept();
return INTANGENT;
@ -1527,7 +1529,7 @@ YY_RULE_SETUP
YY_BREAK
case 33:
YY_RULE_SETUP
#line 446 "lexer.lxx"
#line 448 "lexer.lxx"
{
accept();
return JOINT;
@ -1535,7 +1537,7 @@ YY_RULE_SETUP
YY_BREAK
case 34:
YY_RULE_SETUP
#line 450 "lexer.lxx"
#line 452 "lexer.lxx"
{
accept();
return KNOTS;
@ -1543,7 +1545,7 @@ YY_RULE_SETUP
YY_BREAK
case 35:
YY_RULE_SETUP
#line 454 "lexer.lxx"
#line 456 "lexer.lxx"
{
accept();
return INCLUDE;
@ -1551,7 +1553,7 @@ YY_RULE_SETUP
YY_BREAK
case 36:
YY_RULE_SETUP
#line 458 "lexer.lxx"
#line 460 "lexer.lxx"
{
accept();
return INSTANCE;
@ -1559,7 +1561,7 @@ YY_RULE_SETUP
YY_BREAK
case 37:
YY_RULE_SETUP
#line 462 "lexer.lxx"
#line 464 "lexer.lxx"
{
accept();
return LINE;
@ -1567,7 +1569,7 @@ YY_RULE_SETUP
YY_BREAK
case 38:
YY_RULE_SETUP
#line 466 "lexer.lxx"
#line 468 "lexer.lxx"
{
accept();
return LOOP;
@ -1575,7 +1577,7 @@ YY_RULE_SETUP
YY_BREAK
case 39:
YY_RULE_SETUP
#line 470 "lexer.lxx"
#line 472 "lexer.lxx"
{
accept();
return MATERIAL;
@ -1583,7 +1585,7 @@ YY_RULE_SETUP
YY_BREAK
case 40:
YY_RULE_SETUP
#line 474 "lexer.lxx"
#line 476 "lexer.lxx"
{
accept();
return MATRIX3;
@ -1591,7 +1593,7 @@ YY_RULE_SETUP
YY_BREAK
case 41:
YY_RULE_SETUP
#line 478 "lexer.lxx"
#line 480 "lexer.lxx"
{
accept();
return MATRIX4;
@ -1599,7 +1601,7 @@ YY_RULE_SETUP
YY_BREAK
case 42:
YY_RULE_SETUP
#line 482 "lexer.lxx"
#line 484 "lexer.lxx"
{
accept();
return MODEL;
@ -1607,7 +1609,7 @@ YY_RULE_SETUP
YY_BREAK
case 43:
YY_RULE_SETUP
#line 486 "lexer.lxx"
#line 488 "lexer.lxx"
{
accept();
return MREF;
@ -1615,7 +1617,7 @@ YY_RULE_SETUP
YY_BREAK
case 44:
YY_RULE_SETUP
#line 490 "lexer.lxx"
#line 492 "lexer.lxx"
{
accept();
return NORMAL;
@ -1623,7 +1625,7 @@ YY_RULE_SETUP
YY_BREAK
case 45:
YY_RULE_SETUP
#line 494 "lexer.lxx"
#line 496 "lexer.lxx"
{
accept();
return NURBSCURVE;
@ -1631,7 +1633,7 @@ YY_RULE_SETUP
YY_BREAK
case 46:
YY_RULE_SETUP
#line 498 "lexer.lxx"
#line 500 "lexer.lxx"
{
accept();
return NURBSSURFACE;
@ -1639,7 +1641,7 @@ YY_RULE_SETUP
YY_BREAK
case 47:
YY_RULE_SETUP
#line 502 "lexer.lxx"
#line 504 "lexer.lxx"
{
accept();
return OBJECTTYPE;
@ -1647,7 +1649,7 @@ YY_RULE_SETUP
YY_BREAK
case 48:
YY_RULE_SETUP
#line 506 "lexer.lxx"
#line 508 "lexer.lxx"
{
accept();
return ORDER;
@ -1655,7 +1657,7 @@ YY_RULE_SETUP
YY_BREAK
case 49:
YY_RULE_SETUP
#line 510 "lexer.lxx"
#line 512 "lexer.lxx"
{
accept();
return OUTTANGENT;
@ -1663,7 +1665,7 @@ YY_RULE_SETUP
YY_BREAK
case 50:
YY_RULE_SETUP
#line 514 "lexer.lxx"
#line 516 "lexer.lxx"
{
accept();
return POINTLIGHT;
@ -1671,7 +1673,7 @@ YY_RULE_SETUP
YY_BREAK
case 51:
YY_RULE_SETUP
#line 518 "lexer.lxx"
#line 520 "lexer.lxx"
{
accept();
return POLYGON;
@ -1679,7 +1681,7 @@ YY_RULE_SETUP
YY_BREAK
case 52:
YY_RULE_SETUP
#line 522 "lexer.lxx"
#line 524 "lexer.lxx"
{
accept();
return REF;
@ -1687,7 +1689,7 @@ YY_RULE_SETUP
YY_BREAK
case 53:
YY_RULE_SETUP
#line 526 "lexer.lxx"
#line 528 "lexer.lxx"
{
accept();
return RGBA;
@ -1695,7 +1697,7 @@ YY_RULE_SETUP
YY_BREAK
case 54:
YY_RULE_SETUP
#line 530 "lexer.lxx"
#line 532 "lexer.lxx"
{
accept();
return ROTATE;
@ -1703,7 +1705,7 @@ YY_RULE_SETUP
YY_BREAK
case 55:
YY_RULE_SETUP
#line 534 "lexer.lxx"
#line 536 "lexer.lxx"
{
accept();
return ROTX;
@ -1711,7 +1713,7 @@ YY_RULE_SETUP
YY_BREAK
case 56:
YY_RULE_SETUP
#line 538 "lexer.lxx"
#line 540 "lexer.lxx"
{
accept();
return ROTY;
@ -1719,7 +1721,7 @@ YY_RULE_SETUP
YY_BREAK
case 57:
YY_RULE_SETUP
#line 542 "lexer.lxx"
#line 544 "lexer.lxx"
{
accept();
return ROTZ;
@ -1727,7 +1729,7 @@ YY_RULE_SETUP
YY_BREAK
case 58:
YY_RULE_SETUP
#line 546 "lexer.lxx"
#line 548 "lexer.lxx"
{
accept();
return SANIM;
@ -1735,7 +1737,7 @@ YY_RULE_SETUP
YY_BREAK
case 59:
YY_RULE_SETUP
#line 550 "lexer.lxx"
#line 552 "lexer.lxx"
{
accept();
return SCALAR;
@ -1743,7 +1745,7 @@ YY_RULE_SETUP
YY_BREAK
case 60:
YY_RULE_SETUP
#line 554 "lexer.lxx"
#line 556 "lexer.lxx"
{
accept();
return SCALE;
@ -1751,7 +1753,7 @@ YY_RULE_SETUP
YY_BREAK
case 61:
YY_RULE_SETUP
#line 558 "lexer.lxx"
#line 560 "lexer.lxx"
{
accept();
return SEQUENCE;
@ -1759,7 +1761,7 @@ YY_RULE_SETUP
YY_BREAK
case 62:
YY_RULE_SETUP
#line 562 "lexer.lxx"
#line 564 "lexer.lxx"
{
accept();
return SHADING;
@ -1767,7 +1769,7 @@ YY_RULE_SETUP
YY_BREAK
case 63:
YY_RULE_SETUP
#line 566 "lexer.lxx"
#line 568 "lexer.lxx"
{
accept();
return SWITCH;
@ -1775,7 +1777,7 @@ YY_RULE_SETUP
YY_BREAK
case 64:
YY_RULE_SETUP
#line 570 "lexer.lxx"
#line 572 "lexer.lxx"
{
accept();
return SWITCHCONDITION;
@ -1783,7 +1785,7 @@ YY_RULE_SETUP
YY_BREAK
case 65:
YY_RULE_SETUP
#line 574 "lexer.lxx"
#line 576 "lexer.lxx"
{
accept();
return TABLE;
@ -1791,7 +1793,7 @@ YY_RULE_SETUP
YY_BREAK
case 66:
YY_RULE_SETUP
#line 578 "lexer.lxx"
#line 580 "lexer.lxx"
{
accept();
return TABLE_V;
@ -1799,7 +1801,7 @@ YY_RULE_SETUP
YY_BREAK
case 67:
YY_RULE_SETUP
#line 582 "lexer.lxx"
#line 584 "lexer.lxx"
{
accept();
return TAG;
@ -1807,7 +1809,7 @@ YY_RULE_SETUP
YY_BREAK
case 68:
YY_RULE_SETUP
#line 586 "lexer.lxx"
#line 588 "lexer.lxx"
{
accept();
return TANGENT;
@ -1815,7 +1817,7 @@ YY_RULE_SETUP
YY_BREAK
case 69:
YY_RULE_SETUP
#line 590 "lexer.lxx"
#line 592 "lexer.lxx"
{
accept();
return TEXLIST;
@ -1823,7 +1825,7 @@ YY_RULE_SETUP
YY_BREAK
case 70:
YY_RULE_SETUP
#line 594 "lexer.lxx"
#line 596 "lexer.lxx"
{
accept();
return TEXTURE;
@ -1831,7 +1833,7 @@ YY_RULE_SETUP
YY_BREAK
case 71:
YY_RULE_SETUP
#line 598 "lexer.lxx"
#line 600 "lexer.lxx"
{
accept();
return TLENGTHS;
@ -1839,7 +1841,7 @@ YY_RULE_SETUP
YY_BREAK
case 72:
YY_RULE_SETUP
#line 602 "lexer.lxx"
#line 604 "lexer.lxx"
{
accept();
return TRANSFORM;
@ -1847,7 +1849,7 @@ YY_RULE_SETUP
YY_BREAK
case 73:
YY_RULE_SETUP
#line 606 "lexer.lxx"
#line 608 "lexer.lxx"
{
accept();
return TRANSLATE;
@ -1855,7 +1857,7 @@ YY_RULE_SETUP
YY_BREAK
case 74:
YY_RULE_SETUP
#line 610 "lexer.lxx"
#line 612 "lexer.lxx"
{
accept();
return TREF;
@ -1863,7 +1865,7 @@ YY_RULE_SETUP
YY_BREAK
case 75:
YY_RULE_SETUP
#line 614 "lexer.lxx"
#line 616 "lexer.lxx"
{
accept();
return TRIANGLEFAN;
@ -1871,7 +1873,7 @@ YY_RULE_SETUP
YY_BREAK
case 76:
YY_RULE_SETUP
#line 618 "lexer.lxx"
#line 620 "lexer.lxx"
{
accept();
return TRIANGLESTRIP;
@ -1879,7 +1881,7 @@ YY_RULE_SETUP
YY_BREAK
case 77:
YY_RULE_SETUP
#line 622 "lexer.lxx"
#line 624 "lexer.lxx"
{
accept();
return TRIM;
@ -1887,7 +1889,7 @@ YY_RULE_SETUP
YY_BREAK
case 78:
YY_RULE_SETUP
#line 626 "lexer.lxx"
#line 628 "lexer.lxx"
{
accept();
return TXT;
@ -1895,7 +1897,7 @@ YY_RULE_SETUP
YY_BREAK
case 79:
YY_RULE_SETUP
#line 630 "lexer.lxx"
#line 632 "lexer.lxx"
{
accept();
return UKNOTS;
@ -1903,7 +1905,7 @@ YY_RULE_SETUP
YY_BREAK
case 80:
YY_RULE_SETUP
#line 634 "lexer.lxx"
#line 636 "lexer.lxx"
{
accept();
return UKNOTS;
@ -1911,7 +1913,7 @@ YY_RULE_SETUP
YY_BREAK
case 81:
YY_RULE_SETUP
#line 638 "lexer.lxx"
#line 640 "lexer.lxx"
{
accept();
return UV;
@ -1919,7 +1921,7 @@ YY_RULE_SETUP
YY_BREAK
case 82:
YY_RULE_SETUP
#line 642 "lexer.lxx"
#line 644 "lexer.lxx"
{
accept();
return VKNOTS;
@ -1927,7 +1929,7 @@ YY_RULE_SETUP
YY_BREAK
case 83:
YY_RULE_SETUP
#line 646 "lexer.lxx"
#line 648 "lexer.lxx"
{
accept();
return VKNOTS;
@ -1935,7 +1937,7 @@ YY_RULE_SETUP
YY_BREAK
case 84:
YY_RULE_SETUP
#line 650 "lexer.lxx"
#line 652 "lexer.lxx"
{
accept();
return VERTEX;
@ -1943,7 +1945,7 @@ YY_RULE_SETUP
YY_BREAK
case 85:
YY_RULE_SETUP
#line 654 "lexer.lxx"
#line 656 "lexer.lxx"
{
accept();
return VERTEXANIM;
@ -1951,7 +1953,7 @@ YY_RULE_SETUP
YY_BREAK
case 86:
YY_RULE_SETUP
#line 658 "lexer.lxx"
#line 660 "lexer.lxx"
{
accept();
return VERTEXPOOL;
@ -1959,7 +1961,7 @@ YY_RULE_SETUP
YY_BREAK
case 87:
YY_RULE_SETUP
#line 662 "lexer.lxx"
#line 664 "lexer.lxx"
{
accept();
return VERTEXREF;
@ -1967,7 +1969,7 @@ YY_RULE_SETUP
YY_BREAK
case 88:
YY_RULE_SETUP
#line 666 "lexer.lxx"
#line 668 "lexer.lxx"
{
accept();
return XFMANIM;
@ -1975,7 +1977,7 @@ YY_RULE_SETUP
YY_BREAK
case 89:
YY_RULE_SETUP
#line 670 "lexer.lxx"
#line 672 "lexer.lxx"
{
accept();
return XFMSANIM;
@ -1983,7 +1985,7 @@ YY_RULE_SETUP
YY_BREAK
case 90:
YY_RULE_SETUP
#line 677 "lexer.lxx"
#line 679 "lexer.lxx"
{
// An integer or floating-point number.
accept();
@ -1994,7 +1996,7 @@ YY_RULE_SETUP
YY_BREAK
case 91:
YY_RULE_SETUP
#line 685 "lexer.lxx"
#line 687 "lexer.lxx"
{
// A hexadecimal integer number.
accept();
@ -2005,7 +2007,7 @@ YY_RULE_SETUP
YY_BREAK
case 92:
YY_RULE_SETUP
#line 693 "lexer.lxx"
#line 695 "lexer.lxx"
{
// A binary integer number.
accept();
@ -2016,7 +2018,7 @@ YY_RULE_SETUP
YY_BREAK
case 93:
YY_RULE_SETUP
#line 701 "lexer.lxx"
#line 703 "lexer.lxx"
{
// not-a-number. These sometimes show up in egg files accidentally.
accept();
@ -2028,7 +2030,7 @@ YY_RULE_SETUP
YY_BREAK
case 94:
YY_RULE_SETUP
#line 710 "lexer.lxx"
#line 712 "lexer.lxx"
{
// infinity. As above.
accept();
@ -2039,7 +2041,7 @@ YY_RULE_SETUP
YY_BREAK
case 95:
YY_RULE_SETUP
#line 718 "lexer.lxx"
#line 720 "lexer.lxx"
{
// minus infinity. As above.
accept();
@ -2050,7 +2052,7 @@ YY_RULE_SETUP
YY_BREAK
case 96:
YY_RULE_SETUP
#line 727 "lexer.lxx"
#line 729 "lexer.lxx"
{
// Quoted string.
accept();
@ -2060,7 +2062,7 @@ YY_RULE_SETUP
YY_BREAK
case 97:
YY_RULE_SETUP
#line 734 "lexer.lxx"
#line 736 "lexer.lxx"
{
// Unquoted string.
accept();
@ -2070,10 +2072,10 @@ YY_RULE_SETUP
YY_BREAK
case 98:
YY_RULE_SETUP
#line 740 "lexer.lxx"
#line 742 "lexer.lxx"
ECHO;
YY_BREAK
#line 2078 "lex.yy.c"
#line 2080 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -2962,4 +2964,4 @@ int main()
return 0;
}
#endif
#line 740 "lexer.lxx"
#line 742 "lexer.lxx"

View File

@ -6,16 +6,16 @@
*/
%{
#include "pandabase.h"
#include "lexerDefs.h"
#include "parserDefs.h"
#include "config_egg.h"
#include "parser.h"
#include "indent.h"
#include "pnotify.h"
#include "pmutex.h"
#include <math.h>
#include "pandabase.h"
extern "C" int eggyywrap(void); // declared below.
@ -26,6 +26,9 @@ static int yyinput(void); // declared by flex.
// Static variables
////////////////////////////////////////////////////////////////////
// This mutex protects all of these global variables.
Mutex egg_lock;
// We'll increment line_number and col_number as we parse the file, so
// that we can report the position of an error.
static int line_number = 0;
@ -50,7 +53,6 @@ static string egg_filename;
// the yacc grammar to start from initial points.
static int initial_token;
////////////////////////////////////////////////////////////////////
// Defining the interface to the lexer.
////////////////////////////////////////////////////////////////////

View File

@ -1,7 +1,7 @@
/* A Bison parser, made by GNU Bison 2.0. */
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@ -36,6 +36,9 @@
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@ -151,6 +154,7 @@
START_PRIMITIVE_BODY = 345
};
#endif
/* Tokens. */
#define EGG_NUMBER 258
#define EGG_ULONG 259
#define EGG_STRING 260
@ -397,6 +401,11 @@ egg_cleanup_parser() {
# define YYERROR_VERBOSE 0
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
typedef int YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@ -409,18 +418,37 @@ typedef int YYSTYPE;
/* Copy the second part of user declarations. */
/* Line 213 of yacc.c. */
#line 414 "y.tab.c"
/* Line 219 of yacc.c. */
#line 423 "y.tab.c"
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#ifndef YY_
# if YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# endif
#endif
#if ! defined (yyoverflow) || YYERROR_VERBOSE
# ifndef YYFREE
# define YYFREE free
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# endif
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
@ -429,6 +457,10 @@ typedef int YYSTYPE;
# define YYSTACK_ALLOC __builtin_alloca
# else
# define YYSTACK_ALLOC alloca
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYINCLUDED_STDLIB_H
# endif
# endif
# endif
# endif
@ -436,13 +468,39 @@ typedef int YYSTYPE;
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
# endif
# ifdef __cplusplus
extern "C" {
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifdef __cplusplus
}
# endif
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
@ -477,7 +535,7 @@ union yyalloc
# define YYCOPY(To, From, Count) \
do \
{ \
register YYSIZE_T yyi; \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
@ -527,7 +585,7 @@ union yyalloc
#define YYUNDEFTOK 2
#define YYMAXUTOK 345
#define YYTRANSLATE(YYX) \
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
@ -756,8 +814,8 @@ static const unsigned short int yyrline[] =
};
#endif
#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
@ -1444,22 +1502,6 @@ static const unsigned char yystos[] =
206, 206
};
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
@ -1489,8 +1531,8 @@ do \
goto yybackup; \
} \
else \
{ \
yyerror ("syntax error: cannot back up");\
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
@ -1569,7 +1611,7 @@ do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yysymprint (stderr, \
yysymprint (stderr, \
Type, Value); \
YYFPRINTF (stderr, "\n"); \
} \
@ -1617,13 +1659,13 @@ yy_reduce_print (yyrule)
#endif
{
int yyi;
unsigned int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
yyrule - 1, yylno);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
}
# define YY_REDUCE_PRINT(Rule) \
@ -1652,7 +1694,7 @@ int yydebug;
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
@ -1676,7 +1718,7 @@ yystrlen (yystr)
const char *yystr;
# endif
{
register const char *yys = yystr;
const char *yys = yystr;
while (*yys++ != '\0')
continue;
@ -1701,8 +1743,8 @@ yystpcpy (yydest, yysrc)
const char *yysrc;
# endif
{
register char *yyd = yydest;
register const char *yys = yysrc;
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
@ -1712,7 +1754,55 @@ yystpcpy (yydest, yysrc)
# endif
# endif
#endif /* !YYERROR_VERBOSE */
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
size_t yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
#endif /* YYERROR_VERBOSE */
@ -1832,13 +1922,13 @@ yyparse (void)
#else
int
yyparse ()
;
#endif
#endif
{
register int yystate;
register int yyn;
int yystate;
int yyn;
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
@ -1856,12 +1946,12 @@ yyparse ()
/* The state stack. */
short int yyssa[YYINITDEPTH];
short int *yyss = yyssa;
register short int *yyssp;
short int *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
register YYSTYPE *yyvsp;
YYSTYPE *yyvsp;
@ -1893,9 +1983,6 @@ yyparse ()
yyssp = yyss;
yyvsp = yyvs;
yyvsp[0] = yylval;
goto yysetstate;
/*------------------------------------------------------------.
@ -1928,7 +2015,7 @@ yyparse ()
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow ("parser stack overflow",
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
@ -1939,11 +2026,11 @@ yyparse ()
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyoverflowlab;
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyoverflowlab;
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
@ -1953,7 +2040,7 @@ yyparse ()
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyoverflowlab;
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
@ -4356,10 +4443,11 @@ yyreduce:
break;
default: break;
}
/* Line 1037 of yacc.c. */
#line 4363 "y.tab.c"
/* Line 1126 of yacc.c. */
#line 4451 "y.tab.c"
yyvsp -= yylen;
yyssp -= yylen;
@ -4398,12 +4486,36 @@ yyerrlab:
if (YYPACT_NINF < yyn && yyn < YYLAST)
{
YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
const char* yyprefix;
char *yymsg;
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
char *yymsg = 0;
# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx;
#if 0
/* This is so xgettext sees the translatable formats that are
constructed on the fly. */
YY_("syntax error, unexpected %s");
YY_("syntax error, unexpected %s, expecting %s");
YY_("syntax error, unexpected %s, expecting %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
#endif
char *yyfmt;
char const *yyf;
static char const yyunexpected[] = "syntax error, unexpected %s";
static char const yyexpecting[] = ", expecting %s";
static char const yyor[] = " or %s";
char yyformat[sizeof yyunexpected
+ sizeof yyexpecting - 1
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
* (sizeof yyor - 1))];
char const *yyprefix = yyexpecting;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
int yyxbegin = yyn < 0 ? -yyn : 0;
@ -4411,48 +4523,68 @@ yyerrlab:
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 0;
int yycount = 1;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
yyprefix = ", expecting ";
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
yycount += 1;
if (yycount == 5)
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yysize = 0;
yycount = 1;
yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
yyfmt = yystpcpy (yyfmt, yyprefix);
yyprefix = yyor;
}
yysize += (sizeof ("syntax error, unexpected ")
+ yystrlen (yytname[yytype]));
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg != 0)
{
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
yyp = yystpcpy (yyp, yytname[yytype]);
if (yycount < 5)
yyf = YY_(yyformat);
yysize1 = yysize + yystrlen (yyf);
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg)
{
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
char *yyp = yymsg;
int yyi = 0;
while ((*yyp = *yyf))
{
yyprefix = ", expecting ";
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
yyp = yystpcpy (yyp, yyprefix);
yyp = yystpcpy (yyp, yytname[yyx]);
yyprefix = " or ";
}
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyf += 2;
}
else
{
yyp++;
yyf++;
}
}
yyerror (yymsg);
YYSTACK_FREE (yymsg);
}
else
yyerror ("syntax error; also virtual memory exhausted");
{
yyerror (YY_("syntax error"));
goto yyexhaustedlab;
}
}
else
#endif /* YYERROR_VERBOSE */
yyerror ("syntax error");
yyerror (YY_("syntax error"));
}
@ -4464,18 +4596,9 @@ yyerrlab:
if (yychar <= YYEOF)
{
/* If at end of input, pop the error token,
then the rest of the stack, then return failure. */
/* Return failure if at end of input. */
if (yychar == YYEOF)
for (;;)
{
YYPOPSTACK;
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[*yyssp], yyvsp);
}
YYABORT;
}
else
{
@ -4494,12 +4617,11 @@ yyerrlab:
`---------------------------------------------------*/
yyerrorlab:
#ifdef __GNUC__
/* Pacify GCC when the user code never invokes YYERROR and the label
yyerrorlab therefore never appears in user code. */
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (0)
goto yyerrorlab;
#endif
yyvsp -= yylen;
yyssp -= yylen;
@ -4562,23 +4684,29 @@ yyacceptlab:
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yydestruct ("Error: discarding lookahead",
yytoken, &yylval);
yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here. |
`----------------------------------------------*/
yyoverflowlab:
yyerror ("parser stack overflow");
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEOF && yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp);
YYPOPSTACK;
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);

View File

@ -1,7 +1,7 @@
/* A Bison parser, made by GNU Bison 2.0. */
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
@ -119,6 +119,7 @@
START_PRIMITIVE_BODY = 345
};
#endif
/* Tokens. */
#define EGG_NUMBER 258
#define EGG_ULONG 259
#define EGG_STRING 260

View File

@ -30,6 +30,9 @@
#include <string>
class EggGroupNode;
class Mutex;
extern Mutex egg_lock;
void egg_init_parser(istream &in, const string &filename,
EggObject *tos, EggGroupNode *egg_top_node);