yast2-core
Scanner.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
8 | |
9 | core system |
10 | (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12 
13  File: Scanner.h
14 
15  Author: Klaus Kaempf <kkaempf@suse.de>
16  Mathias Kettner <kettner@suse.de>
17  Maintainer: Klaus Kaempf <kkaempf@suse.de>
18 
19 /-*/
20 // -*- c++ -*-
21 
22 /*
23  * Interface to the flex generated scanner
24  *
25  */
26 
27 #ifndef Scanner_h
28 #define Scanner_h
29 
30 #ifndef __FLEX_LEXER_H
31 #include "FlexLexer.h"
32 #endif
33 
34 #include "ycp/StaticDeclaration.h"
35 #include <stdio.h>
36 #include <string>
37 
38 class TableEntry;
39 class SymbolTable;
40 #include "ycp/Type.h"
41 #include "ycp/y2log.h"
42 
44 typedef struct formalparamstack {
46  const char *name;
47  constTypePtr type;
48  unsigned int line;
50 
51 typedef union {
52  bool bval; // boolean
53  long long ival; // integer
54  double fval; // float
55  const char *sval; // string
56  unsigned char *cval; // bytecode
57  char *pval; // path
58  char *yval; // symbol
59  const char *nval; // name
60  declaration_t *dval; // builtin declaration
61  TableEntry *tval; // table entry
62  formalparam_t *fpval; // formal parameter chain
63  void *val; // any other value
64 } tokenValue;
65 
76 class Scanner : public yyFlexLexer, public Logger
77 {
78 private:
85  static const int STRING_HUNK = 1024;
86 
92  string m_filename;
93 
98  const char *m_inputBuffer;
99 
104  FILE *m_inputFile;
105 
112 
117 
121  constTypePtr m_scannedType;
122 
127 
132 
137 
142 
148 
149  // current symbol tables, used also in parser.yy
152 
159 
164  std::list<std::pair<std::string, Y2Namespace *> > m_autoimport_predefined;
165 
166 public:
175  Scanner (FILE *inputfile, const char *filename);
176 
183  Scanner(const char *inputbuffer);
184 
193  Scanner(int input_fd, const char *filename);
194 
198  ~Scanner();
199 
204  void setBuffered();
205 
215 
220  SymbolTable *globalTable () const;
221 
226  SymbolTable *localTable () const;
227 
234  int yylex();
235 
246  int LexerInput( char* buf, int max_size );
247 
252  void LexerError( const char* msg );
253 
258  tokenValue scannedValue() const;
259 
264  constTypePtr scannedType() const;
265 
269  int lineNumber() const;
270 
274  string filename() const;
275 
283  void logError (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
284 
288  void logWarning (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
289 
293  const std::list<std::pair<std::string, Y2Namespace *> > & autoimport_predefined() const { return m_autoimport_predefined; };
294 
298  static char *doStrdup (const char *s);
299 
303  void closeInput ();
304 
305 private:
310  void setScannedToken (const tokenValue & value, constTypePtr type);
311 
316  char *extend_scanbuffer (int size);
317 
318 public:
319 
320  virtual void error(string error);
321  virtual void warning(string warning);
322 
323 };
324 
325 #endif // Scanner_h

Generated on a sunny day for yast2-core by doxygen 1.8.2