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 **************************************************************************/
36 #include "parsevrml.h"
43 /*#DEFINE YYDEBUG 1 */
45 /* interfacing with scanner.l (lex) */
48 int push_input_stream ( char *input );
50 /* we must define this ourselves */
53 /* handle for a mesh structure */
54 struct mesh *mesh_ptr;
58 /* top level reserved words */
59 %token IncludeSym ShapeSym GeometrySym
62 %token Identifier Number StringLiteral
65 %token EqualSym LBraceSym RBraceSym LParenSym RParenSym
66 %token LSqBracketSym RSqBracketSym CommaSym
69 %token BadStringLiteral ErrorMisc
95 IncludeSym StringLiteral
97 yytext = strip_quotes(yytext);
98 printf("Need to include %s\n", yytext);
99 push_input_stream(yytext);
106 ShapeSym LBraceSym shape_body RBraceSym
110 /* appearance */ geometry
121 vrmlInitGeometry(yytext);
123 LBraceSym geom_item_list RBraceSym
125 vrmlHandleGeometry();
132 | geom_item_list geom_item
136 Identifier { vrmlGeomOptionName(yytext); }
142 | LSqBracketSym value_list RSqBracketSym
151 Number { vrmlGeomOptionsValue(yytext); }
155 /* C Function Section */
159 int yyerror(char *s) {
160 printf("Error: %s at line %d.\n", s, line_num);
165 /* this is a simple main for testing the parser */
168 int main(int argc, char **argv) {
173 printf("input file = %s\n", argv[1]);
174 push_input_stream(argv[1]);
182 /* parse a VRML scenery file */
183 int fgParseVRML(char *file) {
186 printf("input file = %s\n", file);
187 push_input_stream(file);