ViSP
vpSkipio.cpp
1 /****************************************************************************
2  *
3  * $Id: vpSkipio.cpp 5310 2015-02-11 11:57: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 "skipio.c" contient les procedures d'analyse
35  * syntaxique du fichier "source" qui permettent de traiter
36  * les commandes inconnues.
37  *
38  * Authors:
39  * Jean-Luc CORRE
40  *
41  *****************************************************************************/
42 
43 
44 
45 
46 
47 
48 #include <visp/vpConfig.h>
49 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 #include <visp/vpMy.h>
52 #include <visp/vpToken.h>
53 #include <visp/vpLex.h>
54 #include <visp/vpSkipio.h>
55 #include <stdio.h>
56 /*
57  * La procedure "skip_cmd" saute les structures d'une commande
58  * jusqu'a reconnaitre le debut d'une nouvelle commande.
59  * Entree :
60  * f Fichier en sortie.
61  */
62 void skip_cmd (void)
63 {
64  int token;
65 
66  fprintf (stderr, "\n$ ");
67  fwrite (mytext, mylength, 1, stderr);
68  while ((token = lexecho (stderr, '$')) != T_EOF && token != '$') {};
69  unlex ();
70 }
71 
72 /*
73  * La procedure "skip_keyword" saute les structures des articles
74  * jusqu'a reconnaitre le mot cle de jeton "token".
75  * Entree :
76  * token Jeton du mot cle a reconnaitre.
77  * err Message d'erreur si le mot cle n'est pas reconnu.
78  */
79 void skip_keyword (int token, const char *err)
80 {
81  int t;
82 
83  switch (t = lex ()) {
84  case T_IDENT : /* saute le mot cle inconnu */
85  while ((t = lex ()) != 0){
86  switch (t) {
87  case '$' : /* nouvelle commande */
88  case T_EOF : /* fin de fichier */
89  lexerr ("start", err, NULL);
90  break;
91  default :
92  if (t == token) return;
93  break;
94  }
95  }
96  break;
97  default :
98  if (t == token) return;
99  break;
100  }
101  lexerr ("start", err, NULL);
102 }
103 
104 #endif
105