/* A Bison parser, made from parser.y by GNU bison 1.35. */ #define YYBISON 1 /* Identify Bison output. */ # define BRACKET_ON 257 # define BRACKET_OFF 258 # define WING_BRACKET_ON 259 # define WING_BRACKET_OFF 260 # define VRML1 261 # define ID 262 # define STRING 263 # define INT 264 # define FLOAT 265 # define SCRIPT 266 # define DEF 267 # define EXTERNPROTO 268 # define FALSE_TOK 269 # define IS 270 # define NULL_TOK 271 # define PROTO 272 # define ROUTE 273 # define TO 274 # define TRUE_TOK 275 # define USE 276 # define EVENT_IN 277 # define EVENT_OUT 278 # define EXPOSED_FIELD 279 # define FIELD 280 #line 21 "parser.y" #include #include #include "config.h" #ifdef _WIN32 /* Ugly hack: FLOAT and INT are typedef'ed in gl/gl.h for _WIN32. We preserve the parser's value and hope the best for GL. */ #define SAVED_FLOAT FLOAT #define SAVED_INT INT #undef FLOAT #undef INT /* yet another ugly hack: redefine alloca to malloc */ #define alloca malloc #endif #include "stdafx.h" #ifdef _WIN32 #define FLOAT SAVED_FLOAT #undef SAVED_FLOAT #define INT SAVED_INT #undef SAVED_INT #endif #include "parser.h" #include "Scene.h" #include "Element.h" #include "EventIn.h" #include "EventOut.h" #include "ExposedField.h" #include "Field.h" #include "FieldValue.h" #include "SFMFTypes.h" #include "Node.h" #include "NodeScript.h" #include "NodeComment.h" #include "Proto.h" #include "Stack.h" extern void stopProto(void); #define SYMB(id) (scene->getSymbol(id)) Scene *scene; #ifdef HAVE_LIBZ gzFile inputFile; #else FILE *inputFile; #endif int isInProtoLibrary = 0; int lineno = 1; Node *targetNode; static Stack nodeStack; static Stack protoStack; static int defName = -1; static int currentType; static NodeList commentNodeList; static List commentList; static void route(const MyString &srcNode, const MyString &srcField, const MyString &dstNode, const MyString &dstField); static Node *newNode(const MyString &nodeType); static int checkField(Node *node, const MyString &fieldName); static void setField(Node *node, int index, FieldValue *value); static void isField(Node *node, const MyString &fieldName, const MyString &isName); static FieldValue *intsToType(IntArray *floats, int type); static FieldValue *floatsToType(DoubleArray *floats, int type); static FieldValue *stringToType(const char* string, int type); static DoubleArray *intsToFloats(IntArray *ints); static FieldValue *emptyMF(int type); static FieldValue *emptyMFNodeOrNULL(int type); static FieldValue *SillyDefaultValue(int type); static MyString uniqName(const MyString name); static MyString checkName(const MyString name); static void repairURL(Node* node); static void addCommentsToNode(Node* node); static void addCommentsToNodeList(NodeList *nodelist); class nameTranslation { public: MyString oldName; MyString newName; nameTranslation(MyString newN,MyString oldN) {newName=newN;oldName=oldN;} }; Array NameTranslation; void vrml1error(void); #line 125 "parser.y" #ifndef YYSTYPE typedef union { int int32; int id; Node *node; NodeList *nodeList; Element *element; FieldValue *value; float sffloat; StringArray *stringArray; IntArray *intArray; DoubleArray *doubleArray; } yystype; # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif #ifndef YYDEBUG # define YYDEBUG 0 #endif #define YYFINAL 155 #define YYFLAG -32768 #define YYNTBASE 28 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ #define YYTRANSLATE(x) ((unsigned)(x) <= 280 ? yytranslate[x] : 68) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; #if YYDEBUG static const short yyprhs[] = { 0, 0, 2, 5, 8, 11, 13, 15, 17, 19, 21, 22, 27, 30, 32, 34, 37, 39, 40, 50, 54, 56, 59, 61, 65, 69, 70, 76, 78, 79, 85, 86, 94, 97, 99, 103, 107, 111, 115, 124, 126, 127, 128, 134, 135, 141, 144, 146, 149, 151, 153, 155, 161, 167, 170, 174, 176, 178, 180, 182, 184, 186, 188, 190, 194, 196, 198, 202, 204, 206, 210, 214, 217, 220, 222, 224, 227, 229, 232, 235, 238, 240, 242, 246, 248, 251, 253 }; static const short yyrhs[] = { 29, 0, 7, 29, 0, 1, 49, 0, 29, 30, 0, 49, 0, 31, 0, 33, 0, 47, 0, 50, 0, 0, 13, 58, 32, 50, 0, 22, 58, 0, 35, 0, 43, 0, 34, 33, 0, 49, 0, 0, 18, 59, 36, 3, 38, 4, 5, 37, 6, 0, 34, 31, 29, 0, 49, 0, 38, 41, 0, 49, 0, 23, 60, 8, 0, 24, 60, 8, 0, 0, 26, 60, 40, 8, 61, 0, 39, 0, 0, 25, 60, 42, 8, 61, 0, 0, 14, 59, 44, 3, 45, 4, 48, 0, 45, 46, 0, 49, 0, 23, 60, 8, 0, 24, 60, 8, 0, 26, 60, 8, 0, 25, 60, 8, 0, 19, 58, 27, 8, 20, 58, 27, 8, 0, 65, 0, 0, 0, 59, 5, 51, 53, 6, 0, 0, 12, 5, 52, 54, 6, 0, 53, 56, 0, 49, 0, 54, 55, 0, 49, 0, 56, 0, 39, 0, 23, 60, 8, 16, 8, 0, 24, 60, 8, 16, 8, 0, 57, 61, 0, 8, 16, 8, 0, 47, 0, 33, 0, 8, 0, 8, 0, 8, 0, 8, 0, 62, 0, 9, 0, 3, 66, 4, 0, 31, 0, 17, 0, 3, 67, 4, 0, 63, 0, 64, 0, 3, 63, 4, 0, 3, 64, 4, 0, 3, 4, 0, 16, 8, 0, 21, 0, 15, 0, 63, 10, 0, 10, 0, 64, 11, 0, 64, 10, 0, 63, 11, 0, 11, 0, 9, 0, 3, 66, 4, 0, 9, 0, 66, 9, 0, 31, 0, 67, 31, 0 }; #endif #if YYDEBUG /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { 0, 159, 165, 166, 168, 174, 176, 178, 179, 181, 183, 183, 185, 187, 189, 191, 193, 195, 195, 215, 218, 220, 226, 228, 230, 231, 231, 234, 236, 236, 239, 239, 258, 264, 266, 268, 269, 273, 278, 285, 288, 290, 290, 302, 302, 317, 319, 321, 343, 345, 347, 348, 349, 351, 354, 356, 357, 359, 363, 366, 369, 373, 375, 376, 378, 379, 380, 382, 383, 384, 385, 386, 387, 390, 392, 394, 396, 398, 400, 401, 402, 404, 406, 409, 412, 414, 420 }; #endif #if (YYDEBUG) || defined YYERROR_VERBOSE /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { "$", "error", "$undefined.", "BRACKET_ON", "BRACKET_OFF", "WING_BRACKET_ON", "WING_BRACKET_OFF", "VRML1", "ID", "STRING", "INT", "FLOAT", "SCRIPT", "DEF", "EXTERNPROTO", "FALSE_TOK", "IS", "NULL_TOK", "PROTO", "ROUTE", "TO", "TRUE_TOK", "USE", "EVENT_IN", "EVENT_OUT", "EXPOSED_FIELD", "FIELD", "'.'", "vrmlScene", "statements", "statement", "nodeStatement", "@1", "protoStatement", "protoStatements", "proto", "@2", "protoBody", "interfaceDeclarations", "restrictedInterfaceDeclaration", "@3", "interfaceDeclaration", "@4", "externproto", "@5", "externInterfaceDeclarations", "externInterfaceDeclaration", "routeStatement", "URLList", "empty", "node", "@6", "@7", "nodeBody", "scriptBody", "scriptBodyElement", "nodeBodyElement", "fieldName", "nodeName", "nodeType", "fieldType", "fieldValue", "sfboolValue", "ints", "floats", "mfstringValue", "strings", "nodeStatements", 0 }; #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { 0, 28, 28, 28, 29, 29, 30, 30, 30, 31, 32, 31, 31, 33, 33, 34, 34, 36, 35, 37, 37, 38, 38, 39, 39, 40, 39, 41, 42, 41, 44, 43, 45, 45, 46, 46, 46, 46, 47, 48, 49, 51, 50, 52, 50, 53, 53, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 57, 58, 59, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 63, 63, 64, 64, 64, 64, 65, 65, 66, 66, 67, 67 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { 0, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0, 4, 2, 1, 1, 2, 1, 0, 9, 3, 1, 2, 1, 3, 3, 0, 5, 1, 0, 5, 0, 7, 2, 1, 3, 3, 3, 3, 8, 1, 0, 0, 5, 0, 5, 2, 1, 2, 1, 1, 1, 5, 5, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 3, 3, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 1, 3, 1, 2, 1, 2 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const short yydefact[] = { 0, 40, 40, 1, 5, 3, 2, 59, 0, 0, 0, 0, 0, 0, 4, 6, 7, 13, 14, 8, 9, 0, 43, 58, 10, 30, 17, 0, 12, 41, 40, 0, 0, 0, 0, 40, 48, 0, 11, 40, 40, 0, 46, 0, 44, 57, 0, 0, 0, 56, 50, 55, 47, 49, 0, 0, 33, 0, 22, 0, 42, 45, 0, 60, 0, 0, 25, 0, 62, 76, 80, 74, 0, 65, 73, 64, 53, 61, 67, 68, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 27, 21, 0, 54, 23, 24, 0, 71, 83, 85, 0, 0, 0, 0, 72, 75, 79, 78, 77, 0, 81, 31, 39, 0, 0, 0, 0, 40, 0, 0, 28, 0, 0, 0, 0, 69, 70, 63, 84, 66, 86, 0, 34, 35, 37, 36, 0, 0, 16, 23, 24, 0, 38, 51, 52, 26, 82, 40, 15, 18, 0, 19, 29, 0, 0, 0 }; static const short yydefgoto[] = { 153, 3, 14, 15, 31, 16, 136, 17, 33, 137, 57, 50, 96, 91, 141, 18, 32, 55, 85, 19, 111, 4, 20, 35, 30, 43, 37, 52, 53, 54, 24, 21, 64, 76, 77, 78, 79, 112, 102, 103 }; static const short yypact[] = { 56,-32768,-32768, 102,-32768,-32768, 102,-32768, 29, 4, 13, 13, 4, 4,-32768,-32768,-32768,-32768,-32768,-32768, -32768, 31,-32768,-32768,-32768,-32768,-32768, 38,-32768,-32768, -32768, 50, 80, 85, 73,-32768,-32768, 53,-32768,-32768, -32768, 75,-32768, 123,-32768, 97, 111, 111, 111,-32768, -32768,-32768,-32768,-32768, 81, 3,-32768, 18,-32768, 4, -32768,-32768, 115,-32768, 117, 122,-32768, 96,-32768,-32768, -32768,-32768, 125,-32768,-32768,-32768,-32768,-32768, -1, 35, 57, 111, 111, 111, 111,-32768, 129, 111, 111, 111, -32768,-32768, 108,-32768, 124, 127, 130,-32768,-32768,-32768, 7, 27, 16, 11,-32768,-32768,-32768,-32768,-32768, 135, -32768,-32768,-32768, 131, 138, 139, 140,-32768, 141, 142, -32768, 143, 144, 145, 81,-32768,-32768,-32768,-32768,-32768, -32768, 78,-32768,-32768,-32768,-32768, 114, 148, 149,-32768, -32768, 150,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 81, 102,-32768, 156, 157,-32768 }; static const short yypgoto[] = { -32768, -2,-32768, -51,-32768, -35,-32768,-32768,-32768,-32768, -32768, 103,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 43, -32768, 0, 128,-32768,-32768,-32768,-32768,-32768, 118,-32768, -8, 101, -34, -118,-32768, 95, 98,-32768, 54,-32768 }; #define YYLAST 165 static const short yytable[] = { 6, 5, 49, 75, 27, 28, 145, 80, 49, 105, 106, 125, 23, 65, 66, 129, 99, 105, 106, 7, 127, 7, 86, 8, 9, 128, 81, 82, 83, 84, 36, 126, 152, 13, 22, 42, 29, 107, 108, 56, 58, 87, 88, 89, 48, 107, 108, 113, 114, 115, 116, 92, 130, 118, 119, 120, -40, 1, 7, 44, 109, 45, 8, 2, -40, 34, 110, 10, -40, -40, -40, 11, 12, 75, -40, -40, 46, 47, -40, 48, 51, 41, 146, 39, 67, 147, 51, 128, 40, 7, 68, 69, 70, 8, 9, 59, 71, 72, 73, 75, 97, 148, 74, 13, 7, 98, 69, 70, 8, 9, 7, 25, 26, 62, 8, 9, 10, 138, 13, 63, 11, 12, 7, 93, 13, 94, 8, 9, 10, 60, 95, 45, 11, 104, 117, 121, 13, 10, 124, 132, 122, 11, 12, 123, 98, 151, 133, 134, 135, 139, 140, 142, 143, 144, 149, -20, 154, 155, 150, 38, 90, 61, 100, 131, 0, 101 }; static const short yycheck[] = { 2, 1, 37, 54, 12, 13, 124, 4, 43, 10, 11, 4, 8, 47, 48, 4, 67, 10, 11, 8, 4, 8, 4, 12, 13, 9, 23, 24, 25, 26, 30, 4, 150, 22, 5, 35, 5, 10, 11, 39, 40, 23, 24, 25, 26, 10, 11, 81, 82, 83, 84, 59, 103, 87, 88, 89, 0, 1, 8, 6, 3, 8, 12, 7, 8, 27, 9, 14, 12, 13, 14, 18, 19, 124, 18, 19, 23, 24, 22, 26, 37, 8, 4, 3, 3, 136, 43, 9, 3, 8, 9, 10, 11, 12, 13, 20, 15, 16, 17, 150, 4, 136, 21, 22, 8, 9, 10, 11, 12, 13, 8, 10, 11, 16, 12, 13, 14, 117, 22, 8, 18, 19, 8, 8, 22, 8, 12, 13, 14, 6, 8, 8, 18, 8, 5, 27, 22, 14, 8, 8, 16, 18, 19, 16, 9, 147, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 0, 0, 8, 31, 57, 43, 67, 109, -1, 67 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/share/bison/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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 the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # endif # 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 /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; # if YYLSP_NEEDED YYLTYPE yyls; # endif }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # if YYLSP_NEEDED # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAX) # else # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAX) # endif /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #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 /* 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 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). When YYLLOC_DEFAULT is run, CURRENT is set the location of the first token. By default, to implement support for ranges, extend its range to the last symbol. */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ #if YYPURE # if YYLSP_NEEDED # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) # else # define YYLEX yylex (&yylval, &yylloc) # endif # else /* !YYLSP_NEEDED */ # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) # else # define YYLEX yylex (&yylval) # endif # endif /* !YYLSP_NEEDED */ #else /* !YYPURE */ # define YYLEX yylex () #endif /* !YYPURE */ /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 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) evaluated with infinite-precision integer arithmetic. */ #if YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #ifdef YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif #line 315 "/usr/share/bison/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM # define YYPARSE_PARAM_DECL # else # define YYPARSE_PARAM_ARG YYPARSE_PARAM # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; # endif #else /* !YYPARSE_PARAM */ # define YYPARSE_PARAM_ARG # define YYPARSE_PARAM_DECL #endif /* !YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ # ifdef YYPARSE_PARAM int yyparse (void *); # else int yyparse (void); # endif #endif /* YY_DECL_VARIABLES -- depending whether we use a pure parser, variables are global, or local to YYPARSE. */ #define YY_DECL_NON_LSP_VARIABLES \ /* The lookahead symbol. */ \ int yychar; \ \ /* The semantic value of the lookahead symbol. */ \ YYSTYPE yylval; \ \ /* Number of parse errors so far. */ \ int yynerrs; #if YYLSP_NEEDED # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES \ \ /* Location data for the lookahead symbol. */ \ YYLTYPE yylloc; #else # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES #endif /* If nonreentrant, generate the variables here. */ #if !YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ int yyparse (YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL { /* If reentrant, generate the variables here. */ #if YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yychar1 = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #if YYLSP_NEEDED /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; #endif #if YYLSP_NEEDED # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else # define YYPOPSTACK (yyvsp--, yyssp--) #endif YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYLSP_NEEDED YYLTYPE yyloc; #endif /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; #if YYLSP_NEEDED yylsp = yyls; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ # if YYLSP_NEEDED YYLTYPE *yyls1 = yyls; /* 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", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; # else yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); # endif yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) goto yyoverflowlab; yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # if YYLSP_NEEDED YYSTACK_RELOCATE (yyls); # endif # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; #if YYLSP_NEEDED yylsp = yyls + yysize - 1; #endif YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyssp >= yyss + yystacksize - 1) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yychar1 = YYTRANSLATE (yychar); #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { YYFPRINTF (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ # ifdef YYPRINT YYPRINT (stderr, yychar, yylval); # endif YYFPRINTF (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to the semantic value of the lookahead token. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; #if YYLSP_NEEDED /* Similarly for the default location. Let the user run additional commands if for instance locations are ranges. */ yyloc = yylsp[1-yylen]; YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); #endif #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { int yyi; YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 1: #line 160 "parser.y" { nodeComment(); addCommentsToNodeList(yyvsp[0].nodeList); scene->addNodes(targetNode, yyvsp[0].nodeList); } break; case 2: #line 165 "parser.y" { vrml1error(); } break; case 4: #line 169 "parser.y" { if (yyvsp[0].node != NULL) yyvsp[0].node->appendTo(yyvsp[-1].nodeList); yyval.nodeList = yyvsp[-1].nodeList; } break; case 5: #line 174 "parser.y" { yyval.nodeList = new NodeList(); } break; case 6: #line 177 "parser.y" { yyval.node = yyvsp[0].node; } break; case 7: #line 178 "parser.y" { yyval.node = NULL; } break; case 8: #line 179 "parser.y" { yyval.node = NULL; } break; case 9: #line 182 "parser.y" { scene->updateURLs(yyvsp[0].node); yyval.node = yyvsp[0].node; } break; case 10: #line 183 "parser.y" { defName = yyvsp[0].id; } break; case 11: #line 184 "parser.y" { yyval.node = yyvsp[0].node; scene->updateURLs(yyvsp[0].node);} break; case 12: #line 185 "parser.y" { yyval.node = scene->use(checkName(SYMB(yyvsp[0].id))); } break; case 17: #line 196 "parser.y" { protoStack.push(new Proto(scene, SYMB(yyvsp[0].id))); if (!scene->addProtoName(SYMB(yyvsp[0].id))) { char buf[1024]; mysnprintf(buf,1024, "proto already definied: %s", (const char*)SYMB(yyvsp[0].id)); yyerror(buf); } } break; case 18: #line 210 "parser.y" { scene->addProto(SYMB(yyvsp[-7].id),protoStack.pop()); stopProto(); } break; case 19: #line 217 "parser.y" { protoStack.peek()->define(yyvsp[-1].node, yyvsp[0].nodeList); } break; case 21: #line 222 "parser.y" { if (protoStack.empty()) yyerror("syntax error"); else protoStack.peek()->addElement(yyvsp[0].element); } break; case 23: #line 229 "parser.y" { yyval.element = new EventIn(yyvsp[-1].int32, SYMB(yyvsp[0].id)); } break; case 24: #line 230 "parser.y" { yyval.element = new EventOut(yyvsp[-1].int32, SYMB(yyvsp[0].id)); } break; case 25: #line 231 "parser.y" { currentType = yyvsp[0].int32; } break; case 26: #line 232 "parser.y" { yyval.element = new Field(yyvsp[-3].int32, SYMB(yyvsp[-1].id), yyvsp[0].value); } break; case 28: #line 236 "parser.y" { currentType = yyvsp[0].int32; } break; case 29: #line 237 "parser.y" { yyval.element = new ExposedField(yyvsp[-3].int32, SYMB(yyvsp[-1].id), yyvsp[0].value); } break; case 30: #line 241 "parser.y" { protoStack.push(new Proto(scene, SYMB(yyvsp[0].id))); if (!scene->addProtoName(SYMB(yyvsp[0].id))) { char buf[1024]; mysnprintf(buf,1024, "proto already definied: %s", (const char*)SYMB(yyvsp[0].id)); yyerror(buf); } } break; case 31: #line 253 "parser.y" { scene->addProto(SYMB(yyvsp[-5].id), protoStack.pop()); stopProto(); } break; case 32: #line 260 "parser.y" { if (protoStack.empty()) yyerror("syntax error"); else protoStack.peek()->addElement(yyvsp[0].element); } break; case 34: #line 267 "parser.y" { yyval.element = new EventIn(yyvsp[-1].int32, SYMB(yyvsp[0].id)); } break; case 35: #line 268 "parser.y" { yyval.element = new EventOut(yyvsp[-1].int32, SYMB(yyvsp[0].id)); } break; case 36: #line 269 "parser.y" { yyval.element = new Field(yyvsp[-1].int32, SYMB(yyvsp[0].id), SillyDefaultValue(yyvsp[-1].int32)); } break; case 37: #line 273 "parser.y" { yyval.element = new ExposedField(yyvsp[-1].int32, SYMB(yyvsp[0].id), SillyDefaultValue(yyvsp[-1].int32)); } break; case 38: #line 280 "parser.y" { route(checkName(SYMB(yyvsp[-6].id)), SYMB(yyvsp[-4].id), checkName(SYMB(yyvsp[-2].id)), SYMB(yyvsp[0].id)); } break; case 41: #line 291 "parser.y" { yyval.node = newNode(SYMB(yyvsp[-1].id)); addCommentsToNode(yyval.node); nodeStack.push(yyval.node); if (defName != -1) { scene->def(uniqName(SYMB(defName)), yyval.node); defName = -1; } } break; case 42: #line 301 "parser.y" { yyval.node = nodeStack.pop(); } break; case 43: #line 302 "parser.y" { yyval.node = new NodeScript(scene); addCommentsToNode(yyval.node); nodeStack.push(yyval.node); if (defName != -1) { scene->def(uniqName(SYMB(defName)), yyval.node); defName = -1; } } break; case 44: #line 312 "parser.y" { yyval.node = nodeStack.pop(); ((NodeScript *) yyval.node)->update(); } break; case 47: #line 323 "parser.y" { if (nodeStack.empty()) yyerror("syntax error"); else if (yyvsp[0].element) { nodeStack.peek()->getProto()->addElement(yyvsp[0].element); nodeStack.peek()->update(); if (yyvsp[0].element->getElementType() == EL_FIELD_DEF) { Field *field = (Field *)yyvsp[0].element; // search for number of field to use setField Proto *proto = nodeStack.peek()->getProto(); for (int i=0; i < proto->getNumFields(); i++) if (proto->getField(i)->getName() == field->getName()) setField(nodeStack.peek(), i, field->getDefault()); } } } break; case 49: #line 346 "parser.y" { yyval.element = NULL; } break; case 51: #line 348 "parser.y" { if (protoStack.empty()) yyerror("IS statement used outside PROTO"); yyval.element = new EventIn(yyvsp[-3].int32, SYMB(yyvsp[-2].id)); } break; case 52: #line 349 "parser.y" { if (protoStack.empty()) yyerror("IS statement used outside PROTO"); yyval.element = new EventOut(yyvsp[-3].int32, SYMB(yyvsp[-2].id)); } break; case 53: #line 352 "parser.y" { setField(nodeStack.peek(), yyvsp[-1].int32, yyvsp[0].value); } break; case 54: #line 354 "parser.y" { isField(nodeStack.peek(), SYMB(yyvsp[-2].id), SYMB(yyvsp[0].id)); } break; case 57: #line 360 "parser.y" { yyval.int32 = checkField(nodeStack.peek(), SYMB(yyvsp[0].id)); } break; case 60: #line 370 "parser.y" { yyval.int32 = typeStringToEnum(SYMB(yyvsp[0].id)); } break; case 62: #line 375 "parser.y" { yyval.value = stringToType(SYMB(yyvsp[0].id), currentType); } break; case 63: #line 377 "parser.y" { yyval.value = new MFString(yyvsp[-1].stringArray); } break; case 64: #line 378 "parser.y" { yyval.value = new SFNode(yyvsp[0].node); } break; case 65: #line 379 "parser.y" { yyval.value = emptyMFNodeOrNULL(currentType); } break; case 66: #line 381 "parser.y" { yyval.value = new MFNode(yyvsp[-1].nodeList); } break; case 67: #line 382 "parser.y" { yyval.value = intsToType(yyvsp[0].intArray, currentType); } break; case 68: #line 383 "parser.y" { yyval.value = floatsToType(yyvsp[0].doubleArray, currentType); } break; case 69: #line 384 "parser.y" { yyval.value = intsToType(yyvsp[-1].intArray, currentType); } break; case 70: #line 385 "parser.y" { yyval.value = floatsToType(yyvsp[-1].doubleArray, currentType); } break; case 71: #line 386 "parser.y" { yyval.value = emptyMF(currentType); } break; case 72: #line 387 "parser.y" { yyval.value = NULL; } break; case 73: #line 391 "parser.y" { yyval.value = new SFBool(true); } break; case 74: #line 392 "parser.y" { yyval.value = new SFBool(false); } break; case 75: #line 395 "parser.y" { yyvsp[-1].intArray->append(yyvsp[0].int32); yyval.intArray = yyvsp[-1].intArray; } break; case 76: #line 396 "parser.y" { yyval.intArray = new IntArray(); yyval.intArray->append(yyvsp[0].int32); } break; case 77: #line 399 "parser.y" { yyvsp[-1].doubleArray->append(yyvsp[0].sffloat); yyval.doubleArray = yyvsp[-1].doubleArray; } break; case 78: #line 400 "parser.y" { yyvsp[-1].doubleArray->append((float) yyvsp[0].int32); yyval.doubleArray = yyvsp[-1].doubleArray; } break; case 79: #line 401 "parser.y" { yyval.doubleArray = intsToFloats(yyvsp[-1].intArray); yyval.doubleArray->append(yyvsp[0].sffloat); delete yyvsp[-1].intArray; } break; case 80: #line 402 "parser.y" { yyval.doubleArray = new DoubleArray(); yyval.doubleArray->append(yyvsp[0].sffloat); } break; case 81: #line 405 "parser.y" { yyval.value = new MFString(SYMB(yyvsp[0].id)); } break; case 82: #line 407 "parser.y" { yyval.value = new MFString(yyvsp[-1].stringArray); } break; case 83: #line 410 "parser.y" { yyval.stringArray = new StringArray(); yyval.stringArray->append(SYMB(yyvsp[0].id)); } break; case 84: #line 412 "parser.y" { yyvsp[-1].stringArray->append(SYMB(yyvsp[0].id)); yyval.stringArray = yyvsp[-1].stringArray; } break; case 85: #line 415 "parser.y" { yyval.nodeList = new NodeList(); if (yyvsp[0].node) yyvsp[0].node->appendTo(yyval.nodeList); } break; case 86: #line 420 "parser.y" { if (yyvsp[0].node) yyvsp[0].node->appendTo(yyvsp[-1].nodeList); yyval.nodeList = yyvsp[-1].nodeList; } break; } #line 705 "/usr/share/bison/bison.simple" yyvsp -= yylen; yyssp -= yylen; #if YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif *++yyvsp = yyval; #if YYLSP_NEEDED *++yylsp = yyloc; #endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else #endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1; /*--------------------------------------------------. | yyerrlab1 -- error raised explicitly by an action | `--------------------------------------------------*/ yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; /*-------------------------------------------------------------------. | yyerrdefault -- current state does not do anything special for the | | error token. | `-------------------------------------------------------------------*/ yyerrdefault: #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault; #endif /*---------------------------------------------------------------. | yyerrpop -- pop the current state because it cannot handle the | | error token | `---------------------------------------------------------------*/ yyerrpop: if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #if YYLSP_NEEDED yylsp--; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif /*--------------. | yyerrhandle. | `--------------*/ yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; /*---------------------------------------------. | yyoverflowab -- parser overflow comes here. | `---------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 426 "parser.y" int yywrap(void) { return 1; } void yyerror(const char *s) { scene->setErrorLineNumber(lineno); #ifdef HAVE_LIBZ scene->errorf("%s in line %d\n", s, lineno); #else if (strcmp(s,"parse error")==0) scene->errorf("%s (or unsupported compression (no gzip in this version)) in line %d\n", s, lineno); else scene->errorf("%s in line %d\n", s, lineno); #endif } void vrml1error(void) { scene->setErrorLineNumber(1); scene->errorf("VRML Version 1 not supported\n"); } static Node * newNode(const MyString &nodeType) { Proto *proto; if (scene->getProtoPrefix() != NULL) { proto = scene->getProto(scene->getNodeWithPrefix(nodeType)); if (proto) return proto->create(scene); } proto = scene->getProto(nodeType); if (!proto) { scene->errorf("invalid node type %s in %d\n", (const char *) nodeType, lineno); return NULL; } else { return proto->create(scene); } } static FieldValue * intsToType(IntArray *ints, int type) { FieldValue *r = NULL; const int *data = ints->getData(); int len = ints->size(); switch(type) { case SFCOLOR: if (len != 3) { yyerror("SFColor must have 3 values"); } else { r = new SFColor((float) data[0], (float) data[1], (float) data[2]); } break; case SFFLOAT: if (len != 1) { yyerror("SFFloat must have 1 float value"); } else { r = new SFFloat((float) data[0]); } break; case SFIMAGE: if (len < 3) { yyerror("SFImage must have at least 3 values"); } else { int width = data[0]; int height = data[1]; int depth = data[2]; if (len - 3 != width * height) { char buf[1024]; sprintf(buf, "SFImage data must have %d values\n", width * height); yyerror(buf); } else { r = new SFImage(width, height, depth, data + 3); } } break; case SFINT32: if (len != 1) { yyerror("SFInt32 must have 1 integer value"); } else { r = new SFInt32(data[0]); } break; case SFROTATION: if (len != 4) { yyerror("SFRotation must have 4 values"); } else { r = new SFRotation((float) data[0], (float) data[1], (float) data[2], (float) data[3]); } break; case SFTIME: if (len != 1) { yyerror("SFTime must have 1 value"); } else { r = new SFTime((double) data[0]); } break; case SFVEC2F: if (len != 2) { yyerror("SFVec2f must have 2 values"); } else { r = new SFVec2f((float) data[0], (float) data[1]); } break; case SFVEC3F: if (len != 3) { yyerror("SFVec3f must have 3 values"); } else { r = new SFVec3f((float) data[0], (float) data[1], (float) data[2]); } break; case MFINT32: r = new MFInt32(ints->extractData(), len); break; case MFCOLOR: case MFFLOAT: case MFROTATION: case MFTIME: case MFVEC2F: case MFVEC3F: r = floatsToType(intsToFloats(ints), type); break; default: yyerror("type mismatch"); break; } delete ints; return r; } static FieldValue * floatsToType(DoubleArray *floats, int type) { FieldValue *r = NULL; const double *data = floats->getData(); int len = floats->size(); switch(type) { case SFCOLOR: if (len != 3) { yyerror("SFColor must have 3 values"); } else { r = new SFColor(data[0], data[1], data[2]); } break; case SFFLOAT: if (len != 1) { yyerror("SFFloat must have 1 float value"); } else { r = new SFFloat(data[0]); } break; case SFROTATION: if (len != 4) { yyerror("SFRotation must have 4 values"); } else { r = new SFRotation(data[0], data[1], data[2], data[3]); } break; case SFTIME: if (len != 1) { yyerror("SFTime must have 1 value"); } else { r = new SFTime((double) data[0]); } break; case SFVEC2F: if (len != 2) { yyerror("SFVec2f must have 2 values"); } else { r = new SFVec2f(data[0], data[1]); } break; case SFVEC3F: if (len != 3) { yyerror("SFVec3f must have 3 values"); } else { r = new SFVec3f(data[0], data[1], data[2]); } break; case MFCOLOR: if (len % 3 != 0) { yyerror("MFColor must be a multiple of 3 values"); } else { r = new MFColor(floats->extractData(), len); } break; case MFFLOAT: r = new MFFloat(floats->extractData(), len); break; case MFROTATION: if (len % 4 != 0) { yyerror("MFRotation must be a multiple of 4 values"); } else { r = new MFRotation(floats->extractData(), len); } break; case MFTIME: r = new MFTime(data, len); break; case MFVEC2F: if (len % 2 != 0) { yyerror("MFVec2f must be a multiple of 2 values"); } else { r = new MFVec2f(floats->extractData(), len); } break; case MFVEC3F: if (len % 3 != 0) { yyerror("MFVec3f must be a multiple of 2 values"); } else { r = new MFVec3f(floats->extractData(), len); } break; default: yyerror("type mismatch"); break; } delete floats; return r; } static FieldValue * stringToType(const char *string, int type) { FieldValue *r = NULL; switch(type) { case SFSTRING: r=new SFString(string); break; case MFSTRING: r=new MFString(string); break; default: yyerror("type mismatch"); break; } return r; } static FieldValue * emptyMFNodeOrNULL(int type) { if (type==SFNODE) return new SFNode(NULL); else if (type==MFNODE) return emptyMF(type); else { /* NULL only allowed for Node types see VRML97 Grammar http://www.web3d.org/x3d/spec/vrml/ISO_IEC_14772-All/part1/grammar.html#Fields sfnodeValue ::= nodeStatement | NULL ; */ yyerror("NULL only allowed for Node types, assuming \"[]\""); return emptyMF(type); } } static FieldValue * emptyMF(int type) { switch(type) { case MFCOLOR: return new MFColor(); case MFFLOAT: return new MFFloat(); case MFINT32: return new MFInt32(); case MFNODE: return new MFNode(); case MFROTATION: return new MFRotation(); case MFSTRING: return new MFString(); case MFTIME: return new MFTime(); case MFVEC2F: return new MFVec2f(); case MFVEC3F: return new MFVec3f(); default: yyerror("type mismatch"); return NULL; } } /* * Currently, EXTERNPROTO Definitions are not read * field need a senseful default value */ static FieldValue * SillyDefaultValue(int type) { if (scene->hasExternProtoWarning()) { fprintf(stderr,"Warning: Currently, EXTERNPROTO definitions are not read\n"); fprintf(stderr,"Warning: Default field values of this EXTERNPROTO are incorrect\n"); } if (FieldValue *value=typeDefaultValue(type)) return value; else { yyerror("intern error: type no supported"); return NULL; } } // // checkField() - verify a field reference // // check that the node "node" has the field "fieldName" // if not, print an error // if so, stash its type in the lexer, and return its index static int checkField(Node *node, const MyString &fieldName) { if (!node) return INVALID_INDEX; Proto *proto = node->getProto(); if (!proto) return INVALID_INDEX; int index = proto->lookupField(fieldName); if (index == INVALID_INDEX) { scene->invalidField(proto->getName(), fieldName); } else { currentType = proto->getField(index)->getType(); } return index; } static void setField(Node *node, int index, FieldValue *value) { FieldValue *newValue; if (!node || !value || index < 0) return; Proto *proto = node->getProto(); if (!proto) return; Field *field = proto->getField(index); if (value->getType() == SFSTRING && field->getType() == MFSTRING) { newValue = new MFString(((SFString *) value)->getValue()); delete value; value = newValue; } else if (value->getType() == SFNODE && field->getType() == MFNODE) { NodeList *list = new NodeList(); list->append(((SFNode *) value)->getValue()); newValue = new MFNode(list); delete value; value = newValue; } if (value->getType() != field->getType()) { scene->errorf("type mismatch: field \"%s\"\n", (const char *) field->getName()); delete value; } else { node->setField(index, value); } } static void isField(Node *node, const MyString &fieldName, const MyString &isName) { int srcField, srcEventIn, srcEventOut, srcExposedField; int dstField, dstEventIn, dstEventOut, dstExposedField; if (!node) return; Proto *source = node->getProto(); if (!source) return; if (protoStack.empty()) { scene->errorf("IS statement used outside PROTO"); return; } Proto *proto = protoStack.peek(); if ((srcExposedField = source->lookupExposedField(fieldName)) != -1) { dstEventIn = proto->lookupEventIn(isName); dstEventOut = proto->lookupEventOut(isName); if ((dstField = proto->lookupField(isName)) != -1) { // FIXME: do something useful } else if ((dstEventIn = proto->lookupEventIn(isName)) != -1) { // FIXME: do something useful } else if ((dstEventOut = proto->lookupEventOut(isName)) != -1) { // FIXME: do something useful } else if ((dstExposedField = proto->lookupExposedField(isName)) != -1) { // FIXME: do something useful } else { scene->invalidField(source->getName(), isName); } } else if ((srcField = source->lookupField(fieldName)) != -1) { dstField = proto->lookupField(isName); if (dstField != -1) { // FIXME: do something useful } else { scene->invalidField(source->getName(), isName); } } else if ((srcEventIn = source->lookupEventIn(fieldName)) != -1) { dstEventIn = proto->lookupEventIn(isName); if (dstEventIn != -1) { // FIXME: do something useful } else { scene->invalidField(source->getName(), isName); } } else if ((srcEventOut = source->lookupEventOut(fieldName)) != -1) { dstEventOut = proto->lookupEventOut(isName); if (dstEventOut != -1) { // FIXME: do something useful } else { scene->invalidField(source->getName(), isName); } } } static void route(const MyString &srcNode, const MyString &srcField, const MyString &dstNode, const MyString &dstField) { int eventIn; int eventOut; bool valid = true; Node *src = scene->use(srcNode); if (!src) { scene->invalidNode(srcNode); valid = false; } else { eventOut = src->lookupEventOut(srcField); if (eventOut == INVALID_INDEX) { scene->errorf("node \"%s\" has no eventOut \"%s\"", (const char *) srcNode, (const char *) srcField); valid = false; } } Node *dst = scene->use(dstNode); if (!dst) { scene->invalidNode(dstNode); valid = false; } else { eventIn = dst->lookupEventIn(dstField); if (eventIn == INVALID_INDEX) { scene->errorf("node \"%s\" has no eventIn \"%s\"", (const char *) dstNode, (const char *) dstField); valid = false; } } if (valid) { src->update(); dst->update(); if (!scene->addRoute(src, eventOut, dst, eventIn)) scene->errorf("invalid ROUTE command in line %d\n",lineno); } } static DoubleArray * intsToFloats(IntArray *ints) { if (ints == NULL ) return NULL; int len = ints->size(); DoubleArray *r = new DoubleArray(len); const int *d = ints->getData(); for (int i = 0; i < len; i++) { r->set(i, (float) d[i]); } return r; } /* avoid double DEFs while file import */ static MyString uniqName(const MyString name) { int i=0; if (scene->hasAlreadyName(name)) { while (true) { char* buf=(char*) malloc(strlen((const char*) name)+512); sprintf(buf, "%s_%d", (const char*) name, i++); MyString* newName=new MyString(buf); free(buf); if (!scene->hasAlreadyName(*newName)) { NameTranslation.append(new nameTranslation(*newName,name)); return *newName; } } } return name; } /* replace double DEFs while file import */ static MyString checkName(const MyString name) { for (int i=NameTranslation.size()-1;i>=0;i--) if (name==NameTranslation[i]->oldName) { return NameTranslation[i]->newName; } return name; } static void addCommentsToNode(Node* node) { if (commentNodeList.size() > 0) { for (int i = 0;i < commentNodeList.size(); i++) node->appendComment(commentNodeList[i]); commentNodeList.resize(0); } } static void addCommentsToNodeList(NodeList *nodelist) { if (commentNodeList.size() > 0) { for (int i = 0;i < commentNodeList.size(); i++) nodelist->append(commentNodeList[i]); commentNodeList.resize(0); } } void addToCurrentComment(char *string) { if (strlen(string) > 0) commentList.append(string); } void nodeComment(void) { if (commentList.size()!=0) { StringArray *mfString = new StringArray(); for (List::Iterator* commentpointer = commentList.first(); commentpointer != NULL; commentpointer = commentpointer->next() ) { const char *string = commentpointer->item(); bool isVRMLheader = false; if (strcmp(string, "#VRML V2.0 utf8") == 0) isVRMLheader = true; if (!isVRMLheader) { if (string[0] == '\n') string++; mfString->append(strdup(++string)); } } if (mfString->size() > 0) { NodeComment *node = (NodeComment *) scene->createNode("#"); node->comment(new MFString(mfString)); commentNodeList.append(node); } commentList.removeAll(); } } void insideNodeComment(void) { } void MFComment(void) { } void insideMFComment(void) { }