Click here to Skip to main content
15,881,803 members
Articles / Desktop Programming / MFC

VRMLTest - Full VRML 1.x parser and partial viewer

Rate me:
Please Sign up or sign in to vote.
4.58/5 (9 votes)
6 Feb 2000 129.6K   7.4K   42  
VRML parser and Partial viewer
/*  A Bison parser, made from vrml1.y with Bison version GNU Bison version 1.24
  */

#define YYBISON 1  /* Identify Bison output.  */

#define	TK_VRML_ID	258
#define	TK_VRML_DEF	259
#define	TK_VRML_USE	260
#define	TK_VRML_VALUE_INTEGER	261
#define	TK_VRML_VALUE_HEX	262
#define	TK_VRML_VALUE_OCT	263
#define	TK_VRML_VALUE_FLOAT	264
#define	TK_VRML_VALUE_STRING	265
#define	TK_VRML_FIELDS	266
#define	TK_VRML_NODE_ID	267
#define	TK_VRML_SFBITMASK	268
#define	TK_VRML_SFBOOL	269
#define	TK_VRML_SFCOLOR	270
#define	TK_VRML_SFENUM	271
#define	TK_VRML_SFFLOAT	272
#define	TK_VRML_SFIMAGE	273
#define	TK_VRML_SFLONG	274
#define	TK_VRML_SFMATRIX	275
#define	TK_VRML_SFROTATION	276
#define	TK_VRML_SFSTRING	277
#define	TK_VRML_SFVEC2F	278
#define	TK_VRML_SFVEC3F	279
#define	TK_VRML_MFCOLOR	280
#define	TK_VRML_MFLONG	281
#define	TK_VRML_MFFLOAT	282
#define	TK_VRML_MFVEC2F	283
#define	TK_VRML_MFVEC3F	284
#define	TK_VRML_MFSTRING	285

#line 11 "vrml1.y"


#include <afx.h>
#include "vrml.h"
#define YYPARSE_PARAM pvrsc
#define YYPARSE_PARAM_DECL CVRMLScene*
#define YY_DECL int yylex(YYSTYPE* pyylval)


#line 20 "vrml1.y"
typedef union {
   double dVal;
   int iVal;
   CString *pstr;
   CVRMLFieldType* pvrft;
   CVRMLFieldTypes* pvrfts;
   CVRMLNode* pvrn;
   CVRMLNodes* pvrns;
   CVRMLNodeType* pvrnt;
   CVRMLValue* pvrv;   
   CVRMLFieldValues* pvrfvs;
} YYSTYPE;

#ifndef YYLTYPE
typedef
  struct yyltype
    {
      int timestamp;
      int first_line;
      int first_column;
      int last_line;
      int last_column;
      char *text;
   }
  yyltype;

#define YYLTYPE yyltype
#endif

#ifndef YYDEBUG
#define YYDEBUG 1
#endif

#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		110
#define	YYFLAG		-32768
#define	YYNTBASE	38

#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)

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,    35,
    36,     2,     2,    33,     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,
    31,     2,    32,     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,    34,    37,     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,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
    26,    27,    28,    29,    30
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
    20,    22,    24,    26,    28,    30,    32,    34,    36,    39,
    41,    45,    50,    54,    56,    60,    65,    69,    71,    75,
    80,    84,    86,    90,    95,    99,   101,   105,   109,   111,
   113,   115,   117,   119,   121,   124,   127,   129,   132,   136,
   138,   140,   142,   144,   146,   148,   150,   152,   154,   156,
   158,   161,   166,   170,   173,   177,   182,   184,   188,   190,
   194,   198,   200,   203,   206,   209,   212,   214
};

static const short yyrhs[] = {    13,
     0,    14,     0,    15,     0,    16,     0,    17,     0,    18,
     0,    19,     0,    20,     0,    21,     0,    22,     0,    23,
     0,    24,     0,    25,     0,    26,     0,    27,     0,    28,
     0,    29,     0,    30,     0,    31,    32,     0,    51,     0,
    40,    33,    51,     0,    31,    40,    33,    32,     0,    31,
    40,    32,     0,    55,     0,    42,    33,    55,     0,    31,
    42,    33,    32,     0,    31,    42,    32,     0,    56,     0,
    44,    33,    56,     0,    31,    44,    33,    32,     0,    31,
    44,    32,     0,    54,     0,    42,    33,    54,     0,    31,
    46,    33,    32,     0,    31,    46,    32,     0,     3,     0,
    48,    34,     3,     0,    35,    48,    36,     0,     3,     0,
     9,     0,     6,     0,     7,     0,     6,     0,     8,     0,
    51,    51,     0,    53,    51,     0,    10,     0,    51,    51,
     0,    51,    51,    51,     0,    49,     0,    50,     0,     9,
     0,    52,     0,    54,     0,    53,     0,    41,     0,    43,
     0,    45,     0,    47,     0,    39,     0,    38,     3,     0,
    12,    11,    31,    58,     0,    59,    33,    58,     0,    59,
    32,     0,    59,    33,    32,     0,    12,    11,    31,    32,
     0,    60,     0,    61,     3,    57,     0,    12,     0,     4,
     3,    12,     0,    62,     3,    57,     0,    62,     0,    63,
    64,     0,    63,    37,     0,    61,    37,     0,     5,     3,
     0,    64,     0,    65,    64,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
    64,    69,    74,    79,    84,    89,    94,    99,   104,   109,
   114,   119,   124,   129,   134,   139,   144,   149,   156,   159,
   163,   167,   168,   171,   175,   179,   180,   183,   187,   191,
   192,   195,   199,   203,   204,   206,   211,   217,   219,   225,
   229,   234,   238,   242,   248,   253,   258,   264,   272,   282,
   283,   284,   288,   289,   290,   291,   292,   293,   294,   295,
   298,   305,   316,   326,   327,   328,   340,   341,   357,   366,
   392,   430,   431,   441,   444,   449,   459,   464
};

static const char * const yytname[] = {   "$","error","$undefined.","TK_VRML_ID",
"TK_VRML_DEF","TK_VRML_USE","TK_VRML_VALUE_INTEGER","TK_VRML_VALUE_HEX","TK_VRML_VALUE_OCT",
"TK_VRML_VALUE_FLOAT","TK_VRML_VALUE_STRING","TK_VRML_FIELDS","TK_VRML_NODE_ID",
"TK_VRML_SFBITMASK","TK_VRML_SFBOOL","TK_VRML_SFCOLOR","TK_VRML_SFENUM","TK_VRML_SFFLOAT",
"TK_VRML_SFIMAGE","TK_VRML_SFLONG","TK_VRML_SFMATRIX","TK_VRML_SFROTATION","TK_VRML_SFSTRING",
"TK_VRML_SFVEC2F","TK_VRML_SFVEC3F","TK_VRML_MFCOLOR","TK_VRML_MFLONG","TK_VRML_MFFLOAT",
"TK_VRML_MFVEC2F","TK_VRML_MFVEC3F","TK_VRML_MFSTRING","'['","']'","','","'|'",
"'('","')'","'}'","PR_VRML_TYPE","PR_VRML_VALUE_MFEMPTY","PR_VRML_VALUE_SFFLOAT_LIST",
"PR_VRML_VALUE_MFFLOAT","PR_VRML_VALUE_SFVEC2F_LIST","PR_VRML_VALUE_MFVEC2F",
"PR_VRML_VALUE_SFVEC3F_LIST","PR_VRML_VALUE_MFVEC3F","PR_VRML_VALUE_SFSTRING_LIST",
"PR_VRML_VALUE_MFSTRING","PR_VRML_VALUE_SFBITMASK_LIST","PR_VRML_VALUE_SFBITMASK",
"PR_VRML_VALUE_SFENUM","PR_VRML_VALUE_SFFLOAT","PR_VRML_VALUE_SFLONG","PR_VRML_VALUE_SFVECnF",
"PR_VRML_VALUE_SFSTRING","PR_VRML_VALUE_SFVEC2F","PR_VRML_VALUE_SFVEC3F","PR_VRML_VALUE",
"PR_VRML_FIELD_TYPE","PR_VRML_NODE_FIELDS","PR_VRML_NODE_TYPE_HDR","PR_VRML_NODE_TYPE",
"PR_VRML_NODE_INST_HDR","PR_VRML_NODE_INST","PR_VRML_NODE","PR_VRML_SCENE",""
};
#endif

static const short yyr1[] = {     0,
    38,    38,    38,    38,    38,    38,    38,    38,    38,    38,
    38,    38,    38,    38,    38,    38,    38,    38,    39,    40,
    40,    41,    41,    42,    42,    43,    43,    44,    44,    45,
    45,    46,    46,    47,    47,    48,    48,    49,    50,    51,
    51,    52,    52,    52,    53,    53,    54,    55,    56,    57,
    57,    57,    57,    57,    57,    57,    57,    57,    57,    57,
    58,    59,    59,    60,    60,    60,    61,    61,    62,    62,
    62,    63,    63,    64,    64,    64,    65,    65
};

static const short yyr2[] = {     0,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     2,     1,
     3,     4,     3,     1,     3,     4,     3,     1,     3,     4,
     3,     1,     3,     4,     3,     1,     3,     3,     1,     1,
     1,     1,     1,     1,     2,     2,     1,     2,     3,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     2,     4,     3,     2,     3,     4,     1,     3,     1,     3,
     3,     1,     2,     2,     2,     2,     1,     2
};

static const short yydefact[] = {     0,
     0,     0,    69,     0,    67,     0,    72,     0,    77,     0,
     0,    76,     0,    64,     0,     0,    75,     0,    74,    73,
    78,    70,     0,     1,     2,     3,     4,     5,     6,     7,
     8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
    18,    65,     0,    63,    39,    43,    42,    44,    52,    47,
     0,     0,    60,    56,    57,    58,    59,    50,    51,     0,
    53,    55,    54,    68,    71,    66,    62,    61,    41,    40,
    19,     0,     0,     0,     0,    20,    32,    24,    28,    36,
     0,    45,    46,    23,     0,    27,     0,    31,     0,    35,
     0,    48,     0,    38,    22,    21,    26,     0,    33,    25,
    30,     0,    29,    34,    49,    37,    48,     0,     0,     0
};

static const short yydefgoto[] = {    43,
    53,    72,    54,    73,    55,    74,    56,    75,    57,    81,
    58,    59,    60,    61,    62,    63,    78,    79,    64,    44,
     4,     5,     6,     7,     8,     9,    10
};

static const short yypact[] = {    44,
    24,    40,    39,   -25,-32768,     2,    50,    -2,-32768,    55,
    53,-32768,    78,-32768,    56,     9,-32768,     9,-32768,-32768,
-32768,-32768,    76,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,    84,-32768,-32768,    52,-32768,-32768,    57,-32768,
    14,   110,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   101,
-32768,   101,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   -19,   -11,     0,    79,   101,-32768,-32768,-32768,-32768,
   -30,-32768,-32768,-32768,    22,-32768,    20,-32768,    36,-32768,
    82,   101,   112,-32768,-32768,-32768,-32768,   101,-32768,-32768,
-32768,   101,-32768,-32768,-32768,-32768,-32768,   101,   116,-32768
};

static const short yypgoto[] = {-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,   -51,-32768,-32768,   -50,    30,    29,   102,    96,
-32768,-32768,-32768,-32768,-32768,    54,-32768
};


#define	YYLAST		120


static const short yytable[] = {    76,
    77,     1,     2,    93,    16,    94,    14,    15,    82,     3,
    83,    45,    84,    85,    46,    47,    48,    49,    50,    69,
    86,    87,    70,    50,    92,    69,    11,    69,    70,    50,
    70,    88,    89,    96,    19,    98,    99,   102,    17,    51,
   105,    69,    12,    52,    70,    71,   107,     1,     2,    13,
   108,    97,    18,    95,   109,     3,   105,   -41,     1,     2,
   -41,    20,   -40,    21,    22,   -40,     3,   101,    24,    25,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    41,    68,    42,    24,    25,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    41,    69,    66,    23,    70,
    90,    91,    80,   104,   106,   110,   100,   103,    67,    65
};

static const short yycheck[] = {    51,
    51,     4,     5,    34,     3,    36,    32,    33,    60,    12,
    62,     3,    32,    33,     6,     7,     8,     9,    10,     6,
    32,    33,     9,    10,    76,     6,     3,     6,     9,    10,
     9,    32,    33,    85,    37,    87,    87,    89,    37,    31,
    92,     6,     3,    35,     9,    32,    98,     4,     5,    11,
   102,    32,     3,    32,     0,    12,   108,     6,     4,     5,
     9,     8,     6,    10,    12,     9,    12,    32,    13,    14,
    15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    25,    26,    27,    28,    29,    30,     3,    32,    13,    14,
    15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    25,    26,    27,    28,    29,    30,     6,    32,    31,     9,
    32,    33,     3,    32,     3,     0,    87,    89,    23,    18
};
#define YYPURE 1

/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, 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.  */

#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if HAVE_ALLOCA_H
#include <alloca.h>
#else /* not HAVE_ALLOCA_H */
#ifdef _AIX
 #pragma alloca
#else /* not _AIX */
char *alloca ();
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */
#endif /* not __GNUC__ */

extern void yyerror(char* s);

#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if (defined (MSDOS) && !defined (__TURBOC__)) || defined (WIN32)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* 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.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	return(0)
#define YYABORT 	return(1)
#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

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse (void);
#endif

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_memcpy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (from, to, count)
     char *from;
     char *to;
     int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (char *from, char *to, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

/* 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
#ifndef YYPARSE_PARAM_DECL
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif 
#else
#define YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#endif

extern YY_DECL;

int
yyparse(YYPARSE_PARAM_DECL YYPARSE_PARAM) {
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  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 - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* 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;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
      /* 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, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yyls1, size * sizeof (*yylsp),
		 &yystacksize);
#else
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yystacksize);
#endif

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto 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)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      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 */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (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
	  fprintf (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.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
    yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 1:
#line 64 "vrml1.y"
{ 
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFBitMask);
    ;
    break;}
case 2:
#line 69 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFBool);
    ;
    break;}
case 3:
#line 74 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFColor);
    ;
    break;}
case 4:
#line 79 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFEnum);
    ;
    break;}
case 5:
#line 84 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFFloat);
    ;
    break;}
case 6:
#line 89 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFImage);
    ;
    break;}
case 7:
#line 94 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFLong);
    ;
    break;}
case 8:
#line 99 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFMatrix);
    ;
    break;}
case 9:
#line 104 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFRotation);
    ;
    break;}
case 10:
#line 109 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFString);
    ;
    break;}
case 11:
#line 114 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFVec2f);
    ;
    break;}
case 12:
#line 119 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CSFVec3f);
    ;
    break;}
case 13:
#line 124 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFColor);
    ;
    break;}
case 14:
#line 129 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFLong);
    ;
    break;}
case 15:
#line 134 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFFloat);
    ;
    break;}
case 16:
#line 139 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFVec2f);
    ;
    break;}
case 17:
#line 144 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFVec3f);
    ;
    break;}
case 18:
#line 149 "vrml1.y"
{
        yyval.pvrft = new CVRMLFieldType();
        yyval.pvrft->m_pvrvValue = NULL;
        yyval.pvrft->m_pvrtType = RUNTIME_CLASS(CMFString);
    ;
    break;}
case 19:
#line 156 "vrml1.y"
{ yyval.pvrv = new CMFEmpty(); ;
    break;}
case 20:
#line 159 "vrml1.y"
{
        yyval.pvrv = new CMFFloat();
        (DYNAMIC_DOWNCAST(CMFFloat,yyval.pvrv))->m_vfValues.Add(DYNAMIC_DOWNCAST(CSFFloat,yyvsp[0].pvrv));
    ;
    break;}
case 21:
#line 163 "vrml1.y"
{
        yyval.pvrv = yyvsp[-2].pvrv;
        (DYNAMIC_DOWNCAST(CMFFloat,yyval.pvrv))->m_vfValues.Add(DYNAMIC_DOWNCAST(CSFFloat,yyvsp[0].pvrv));
    ;
    break;}
case 22:
#line 167 "vrml1.y"
{ yyval.pvrv = yyvsp[-2].pvrv; ;
    break;}
case 23:
#line 168 "vrml1.y"
{ yyval.pvrv = yyvsp[-1].pvrv; ;
    break;}
case 24:
#line 171 "vrml1.y"
{
        yyval.pvrv = new CMFVec2f();
        (DYNAMIC_DOWNCAST(CMFVec2f, yyval.pvrv))->m_v2Values.Add(DYNAMIC_DOWNCAST(CSFVec2f, yyvsp[0].pvrv));
    ;
    break;}
case 25:
#line 175 "vrml1.y"
{
        yyval.pvrv = yyvsp[-2].pvrv;
        (DYNAMIC_DOWNCAST(CMFVec2f, yyval.pvrv))->m_v2Values.Add(DYNAMIC_DOWNCAST(CSFVec2f, yyvsp[0].pvrv));
    ;
    break;}
case 26:
#line 179 "vrml1.y"
{ yyval.pvrv = yyvsp[-2].pvrv; ;
    break;}
case 27:
#line 180 "vrml1.y"
{ yyval.pvrv = yyvsp[-1].pvrv; ;
    break;}
case 28:
#line 183 "vrml1.y"
{
        yyval.pvrv = new CMFVec3f();
        (DYNAMIC_DOWNCAST(CMFVec3f,yyval.pvrv))->m_v3Values.Add(DYNAMIC_DOWNCAST(CSFVec3f, yyvsp[0].pvrv));
    ;
    break;}
case 29:
#line 187 "vrml1.y"
{
        yyval.pvrv = yyvsp[-2].pvrv;
        (DYNAMIC_DOWNCAST(CMFVec3f, yyval.pvrv))->m_v3Values.Add(DYNAMIC_DOWNCAST(CSFVec3f, yyvsp[0].pvrv));
    ;
    break;}
case 30:
#line 191 "vrml1.y"
{ yyval.pvrv = yyvsp[-2].pvrv; ;
    break;}
case 31:
#line 192 "vrml1.y"
{ yyval.pvrv = yyvsp[-1].pvrv; ;
    break;}
case 32:
#line 195 "vrml1.y"
{
        yyval.pvrv = new CMFString();
        (DYNAMIC_DOWNCAST(CMFString, yyval.pvrv))->m_vsValues.Add(DYNAMIC_DOWNCAST(CSFString, yyvsp[0].pvrv));
    ;
    break;}
case 33:
#line 199 "vrml1.y"
{
        yyval.pvrv = yyvsp[-2].pvrv;
        (DYNAMIC_DOWNCAST(CMFString, yyval.pvrv))->m_vsValues.Add(DYNAMIC_DOWNCAST(CSFString, yyvsp[0].pvrv));
    ;
    break;}
case 34:
#line 203 "vrml1.y"
{ yyval.pvrv = yyvsp[-2].pvrv; ;
    break;}
case 35:
#line 204 "vrml1.y"
{ yyval.pvrv = yyvsp[-1].pvrv; ;
    break;}
case 36:
#line 206 "vrml1.y"
{ 
        yyval.pvrv = new CSFBitMask();
        (DYNAMIC_DOWNCAST(CSFBitMask, yyval.pvrv))->m_strValues.Add(*yyvsp[0].pstr);
        delete yyvsp[0].pstr;
    ;
    break;}
case 37:
#line 211 "vrml1.y"
{
        yyval.pvrv = yyvsp[-2].pvrv;
        (DYNAMIC_DOWNCAST(CSFBitMask, yyval.pvrv))->m_strValues.Add(*yyvsp[0].pstr);
        delete yyvsp[0].pstr;
    ;
    break;}
case 38:
#line 217 "vrml1.y"
{ yyval.pvrv = yyvsp[-1].pvrv; ;
    break;}
case 39:
#line 219 "vrml1.y"
{
        yyval.pvrv = new CSFEnum();
        *(DYNAMIC_DOWNCAST(CSFEnum,yyval.pvrv)) = *yyvsp[0].pstr;
        delete yyvsp[0].pstr;
    ;
    break;}
case 40:
#line 225 "vrml1.y"
{
        yyval.pvrv = new CSFFloat();
        *(DYNAMIC_DOWNCAST(CSFFloat,yyval.pvrv)) = yyvsp[0].dVal;
    ;
    break;}
case 41:
#line 229 "vrml1.y"
{
        yyval.pvrv = new CSFFloat();
        *(DYNAMIC_DOWNCAST(CSFFloat,yyval.pvrv)) = yyvsp[0].iVal;
    ;
    break;}
case 42:
#line 234 "vrml1.y"
{
        yyval.pvrv = new CSFLong();
        *(DYNAMIC_DOWNCAST(CSFLong, yyval.pvrv)) = yyvsp[0].iVal;
    ;
    break;}
case 43:
#line 238 "vrml1.y"
{
        yyval.pvrv = new CSFLong();
        *(DYNAMIC_DOWNCAST(CSFLong, yyval.pvrv)) = yyvsp[0].iVal;
    ;
    break;}
case 44:
#line 242 "vrml1.y"
{
        yyval.pvrv = new CSFLong();
        *(DYNAMIC_DOWNCAST(CSFLong, yyval.pvrv)) = yyvsp[0].iVal;
    ;
    break;}
case 45:
#line 248 "vrml1.y"
{
        yyval.pvrv = new CSFVecnf();
        (DYNAMIC_DOWNCAST(CSFVecnf, yyval.pvrv))->m_vnValues.Add(DYNAMIC_DOWNCAST(CSFFloat,yyvsp[-1].pvrv));
        (DYNAMIC_DOWNCAST(CSFVecnf, yyval.pvrv))->m_vnValues.Add(DYNAMIC_DOWNCAST(CSFFloat,yyvsp[0].pvrv));
    ;
    break;}
case 46:
#line 253 "vrml1.y"
{
        yyval.pvrv = yyvsp[-1].pvrv;
        (DYNAMIC_DOWNCAST(CSFVecnf, yyval.pvrv))->m_vnValues.Add(DYNAMIC_DOWNCAST(CSFFloat,yyvsp[0].pvrv));
    ;
    break;}
case 47:
#line 258 "vrml1.y"
{ 
    yyval.pvrv = new CSFString();
    *(DYNAMIC_DOWNCAST(CSFString, yyval.pvrv)) = *yyvsp[0].pstr;
    delete yyvsp[0].pstr;
    ;
    break;}
case 48:
#line 264 "vrml1.y"
{
        yyval.pvrv = new CSFVec2f();
        (DYNAMIC_DOWNCAST(CSFVec2f,yyval.pvrv))->m_dValues[0] = *(DYNAMIC_DOWNCAST(CSFFloat, yyvsp[-1].pvrv));
        (DYNAMIC_DOWNCAST(CSFVec2f,yyval.pvrv))->m_dValues[1] = *(DYNAMIC_DOWNCAST(CSFFloat, yyvsp[0].pvrv));
        delete yyvsp[-1].pvrv;
        delete yyvsp[0].pvrv;
    ;
    break;}
case 49:
#line 272 "vrml1.y"
{
        yyval.pvrv = new CSFVec3f();
        (DYNAMIC_DOWNCAST(CSFVec3f,yyval.pvrv))->m_dValues[0] = *(DYNAMIC_DOWNCAST(CSFFloat, yyvsp[-2].pvrv));
        (DYNAMIC_DOWNCAST(CSFVec3f,yyval.pvrv))->m_dValues[1] = *(DYNAMIC_DOWNCAST(CSFFloat, yyvsp[-1].pvrv));
        (DYNAMIC_DOWNCAST(CSFVec3f,yyval.pvrv))->m_dValues[2] = *(DYNAMIC_DOWNCAST(CSFFloat, yyvsp[0].pvrv));
        delete yyvsp[-2].pvrv;
        delete yyvsp[-1].pvrv;
        delete yyvsp[0].pvrv;
    ;
    break;}
case 50:
#line 282 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 51:
#line 283 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 52:
#line 284 "vrml1.y"
{ 
        yyval.pvrv = new CSFFloat(); 
        *(DYNAMIC_DOWNCAST(CSFFloat,yyval.pvrv)) = yyvsp[0].dVal;
    ;
    break;}
case 53:
#line 288 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 54:
#line 289 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 55:
#line 290 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 56:
#line 291 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 57:
#line 292 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 58:
#line 293 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 59:
#line 294 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 60:
#line 295 "vrml1.y"
{ yyval.pvrv = yyvsp[0].pvrv; ;
    break;}
case 61:
#line 298 "vrml1.y"
{
        yyval.pvrft = yyvsp[-1].pvrft;
        yyval.pvrft->m_strName = *yyvsp[0].pstr;
        delete yyvsp[0].pstr;
    ;
    break;}
case 62:
#line 305 "vrml1.y"
{ 
        // Create a new node type and the field
        {
            CVRMLNodeType* pvrnt=new CVRMLNodeType();
            yyval.pvrnt = pvrnt;
            pvrnt->m_strName = *yyvsp[-3].pstr;
            pvrnt->m_vrftTypes.Add(yyvsp[0].pvrft);

            delete yyvsp[-3].pstr;
        }
    ;
    break;}
case 63:
#line 316 "vrml1.y"
{ 
        // Add the field
        {
            CVRMLNodeType* pvrnt = yyvsp[-2].pvrnt;
            yyval.pvrnt = pvrnt;
            pvrnt->m_vrftTypes.Add(yyvsp[0].pvrft);
        }
    ;
    break;}
case 64:
#line 326 "vrml1.y"
{ yyval.pvrnt = yyvsp[-1].pvrnt; ;
    break;}
case 65:
#line 327 "vrml1.y"
{ yyval.pvrnt = yyvsp[-2].pvrnt; ;
    break;}
case 66:
#line 328 "vrml1.y"
{
        // Create a new node type with empty fields list
        {
            CVRMLNodeType* pvrnt = new CVRMLNodeType();
            yyval.pvrnt = pvrnt;
            pvrnt->m_strName = *yyvsp[-3].pstr;

            delete yyvsp[-3].pstr;
        }
    ;
    break;}
case 67:
#line 340 "vrml1.y"
{ yyval.pvrnt = yyvsp[0].pvrnt; ;
    break;}
case 68:
#line 341 "vrml1.y"
{
        // Add field-values to the node type (default values)
        {   
            CVRMLNodeType* pvrnt = yyvsp[-2].pvrnt;
            yyval.pvrnt = pvrnt;
            CVRMLFieldType* pvrft = pvrnt->GetFieldTypeNamed(*yyvsp[-1].pstr);
            // Add value to the field (value check) 
            pvrft->m_pvrvValue = (CVRMLValue*) pvrft->m_pvrtType->CreateObject(); 
            pvrft->m_pvrvValue->SetValue(*yyvsp[0].pvrv);

            delete yyvsp[0].pvrv;
            delete yyvsp[-1].pstr;
        }
    ;
    break;}
case 69:
#line 357 "vrml1.y"
{
       {
            CVRMLNode* pvrn = new CVRMLNode();
            yyval.pvrn = pvrn;
            pvrn->m_strName = "";
            pvrn->m_pvrntType = pvrsc->m_vrlLib.GetNamed(*yyvsp[0].pstr);
            delete yyvsp[0].pstr;
       }
    ;
    break;}
case 70:
#line 366 "vrml1.y"
{
        {
            CVRMLNode* pvrn = new CVRMLNode();
            yyval.pvrn = pvrn;
            pvrn->m_strName = *yyvsp[-1].pstr;
			
			/* Add this node also as CVRMLNodeType */
			CVRMLNodeType* pvrnt = new CVRMLNodeType();
			pvrnt->m_strName = *yyvsp[-1].pstr;
			pvrnt->m_pvrntDef = pvrsc->m_vrlLib.GetNamed(*yyvsp[0].pstr);
			pvrsc->m_vrlLib.Add(pvrnt);

			/* When fully parsed, the node values for this node will have to be passed 
			   to the VRMLNodeType and deleted from this VRMLNode */
			
			/* Set this node type as the recently added NodeType, actually
			only NodeTypes have a name, all the other nodes have the same "DEFed" name as 
			its NodeType, thus if you modify one DEFed, all the rest of the same name as the
			last inserted get modified as well (as the standard says) */
			
			pvrn->m_pvrntType = pvrnt;
			
            delete yyvsp[-1].pstr;
            delete yyvsp[0].pstr;
        }
    ;
    break;}
case 71:
#line 392 "vrml1.y"
{
        {
            CVRMLNode* pvrn = yyvsp[-2].pvrn;
            yyval.pvrn = pvrn;
			
			/** @todo Perhaps some sanity check about existance of this CVRMLFieldType 
				   should be made, anyway, it should be made in other twenty places or more */

			// Retrieve the field type info
			CVRMLFieldType* pvrft = pvrn->m_pvrntType->GetFieldTypeNamed(*yyvsp[-1].pstr);

			// Create and set the value (wether it's a default value for a node type or a 
			// value for an instance of a node)
			CVRMLValue* pvrv = (DYNAMIC_DOWNCAST(CVRMLValue, (pvrft->m_pvrtType->CreateObject())));
			pvrv->SetValue(*yyvsp[0].pvrv);

			if (pvrn->m_pvrntType->m_pvrntDef) {
				// If it's a DEFed node, we have to add the value to the type and not to 
				// the node itself, so we create a new CVRMLFieldType
				// USE nodes have no body, so there's no danger that we do this twice or more
				// on the same DEF node.
				pvrft = new CVRMLFieldType(*pvrft);
				pvrft->m_pvrvValue = pvrv;
				pvrn->m_pvrntType->m_vrftTypes.Add(pvrft);
			} else {
			    // If it's not a DEFed node, just add the value to a new CVRMLFieldValue
				CVRMLFieldValue* pvrfv = new CVRMLFieldValue();
				pvrfv->m_pvrftType = pvrft;
				pvrfv->m_pvrvValue = pvrv;
				pvrn->m_vrfvValues.Add(pvrfv);
			}
			
            delete yyvsp[-1].pstr;
            delete yyvsp[0].pvrv;
        }
    ;
    break;}
case 72:
#line 430 "vrml1.y"
{ yyval.pvrn = yyvsp[0].pvrn; ;
    break;}
case 73:
#line 431 "vrml1.y"
{
        // Add the child node to the parent
        {
            CVRMLNode* pvrn=yyvsp[-1].pvrn;
            yyval.pvrn = pvrn;
            pvrn->m_vrnChildren.Add(yyvsp[0].pvrn);
        }
    ;
    break;}
case 74:
#line 441 "vrml1.y"
{
        yyval.pvrn = yyvsp[-1].pvrn;
    ;
    break;}
case 75:
#line 444 "vrml1.y"
{
        yyval.pvrn = NULL;
        // Add it to the node library
        pvrsc->m_vrlLib.Add(yyvsp[-1].pvrnt);
    ;
    break;}
case 76:
#line 449 "vrml1.y"
{
	    {
			/** @todo Retrieve the last NodeType with name $1 from the library, that
			node type is the type of this node $$ */
			// Retrieve the type of node to use
			pvrsc->m_vrlLib.GetNamed(*yyvsp[0].pstr);
		}
    ;
    break;}
case 77:
#line 459 "vrml1.y"
{
        if (yyvsp[0].pvrn != NULL)
            // Instance node, add it to the collection of scene nodes
            pvrsc->m_vrnNodes.Add(yyvsp[0].pvrn);
    ;
    break;}
case 78:
#line 464 "vrml1.y"
{
        if (yyvsp[0].pvrn != NULL)
            // Instance node, add it to the collection of scene nodes
            pvrsc->m_vrnNodes.Add(yyvsp[0].pvrn);
    ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#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 */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  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;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      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. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

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;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 470 "vrml1.y"

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions