ViSP
vpParser.cpp
1 /****************************************************************************
2  *
3  * $Id: vpParser.cpp 5284 2015-02-09 14:24:10Z fspindle $
4  *
5 * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  * Description:
34  * Le module "parser.c" contient les procedures de gestion
35  * de l'analyse syntaxique d'un fichier source dont la grammaire
36  * possede les symboles terminaux de "lex.c".
37  *
38  * Authors:
39  * Jean-Luc CORRE
40  *
41  *****************************************************************************/
42 
43 
44 
45 
46 #include <visp/vpMy.h>
47 #include <visp/vpArit.h>
48 #include <visp/vpView.h>
49 #include <visp/vpBound.h>
50 #include <visp/vpToken.h>
51 #include <visp/vpLex.h>
52 #include <visp/vpSkipio.h>
53 
54 #include <stdio.h>
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 
57 #ifdef used
58 extern Byte *get_remove (void);
59 extern View_parameters *get_view_parameters (void);
60 #endif /* used */
61 
62 /*
63  * La procedure "parser" fait l'analyse syntaxique du fichier source.
64  * Entree/Sortie :
65  * bsp Scene surfacique polygonale a lire.
66  */
67 void parser (Bound_scene *bsp)
68 {
69  int token;
70 
71  while ((token = lex ()) != T_EOF)
72  switch (token) {
73  case '$' :
74  switch (lex ()) {
75  case T_IDENT : /* saute la commande inconnue */
76  skip_cmd (/* stderr */);
77  unlex ();
78  break;
79  case T_EXIT :
80  return;
81  break;
82  case T_BOUND :
83  if (bsp->bound.nbr == BOUND_NBR) {
84  fprintf (stderr, "mire: too much bound\n");
85  return;
86  }
87  fscanf_Bound (
88  &(bsp->bound.ptr[bsp->bound.nbr++]));
89  break;
90 #ifdef used
91  case T_REMOVE :
92  fscanf_Remove (get_remove ());
93  break;
94  case T_VIEW :
95  fscanf_View_parameters (get_view_parameters ());
96  set_projection (void);
97  break;
98 #endif /* used */
99  default :
100  lexerr ("start", "keyword expected", NULL);
101  break;
102  }
103  break;
104  default :
105  lexerr ("start", "symbol '$' expected", NULL);
106  break;
107  }
108 }
109 
110 #endif