1 /**************************************************************************
2 * parser.y -- scenery file parser
4 * Written by Curtis Olson, started June 1997.
6 * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 **************************************************************************/
33 #include "parsevrml.h"
40 /*#DEFINE YYDEBUG 1 */
42 /* interfacing with scanner.l (lex) */
45 int push_input_stream ( char *input );
47 /* we must define this ourselves */
50 /* handle for a mesh structure */
51 struct mesh *mesh_ptr;
55 /* top level reserved words */
56 %token IncludeSym ShapeSym GeometrySym ElevationGridSym
59 %token Identifier Number StringLiteral
62 %token EqualSym LBraceSym RBraceSym LParenSym RParenSym
63 %token LSqBracketSym RSqBracketSym CommaSym
66 %token BadStringLiteral ErrorMisc
92 IncludeSym StringLiteral
94 yytext = strip_quotes(yytext);
95 printf("Need to include %s\n", yytext);
96 push_input_stream(yytext);
103 ShapeSym LBraceSym shape_body RBraceSym
107 /* appearance */ geometry
118 vrmlInitGeometry(yytext);
120 LBraceSym geom_item_list RBraceSym
122 vrmlHandleGeometry();
129 | geom_item_list geom_item
133 Identifier { vrmlGeomOptionName(yytext); }
139 | LSqBracketSym value_list RSqBracketSym
148 Number { vrmlGeomOptionsValue(yytext); }
152 /* C Function Section */
156 int yyerror(char *s) {
157 printf("Error: %s at line %d.\n", s, line_num);
162 /* this is a simple main for testing the parser */
165 int main(int argc, char **argv) {
170 printf("input file = %s\n", argv[1]);
171 push_input_stream(argv[1]);
179 /* parse a VRML scenery file */
180 int fgParseVRML(char *file) {
183 printf("input file = %s\n", file);
184 push_input_stream(file);