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 
126  std::string m_commentBefore;
127 
132 
137 
142 
147 
153 
154  // current symbol tables, used also in parser.yy
157 
164 
169  std::list<std::pair<std::string, Y2Namespace *> > m_autoimport_predefined;
170 
171 public:
180  Scanner (FILE *inputfile, const char *filename);
181 
188  Scanner(const char *inputbuffer);
189 
198  Scanner(int input_fd, const char *filename);
199 
203  ~Scanner();
204 
209  void setBuffered();
210 
219  void initTables (SymbolTable *globalTable, SymbolTable *localTable);
220 
225  SymbolTable *globalTable () const;
226 
231  SymbolTable *localTable () const;
232 
239  int yylex();
240 
251  int LexerInput( char* buf, int max_size );
252 
257  void LexerError( const char* msg );
258 
263  tokenValue scannedValue() const;
264 
269  constTypePtr scannedType() const;
270 
271  std::string commentBefore () const;
272 
276  int lineNumber() const;
277 
281  string filename() const;
282 
290  void logError (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
291 
295  void logWarning (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
296 
300  const std::list<std::pair<std::string, Y2Namespace *> > & autoimport_predefined() const { return m_autoimport_predefined; };
301 
305  static char *doStrdup (const char *s);
306 
310  void closeInput ();
311 
312 private:
317  void setScannedToken (const tokenValue & value, constTypePtr type);
318 
319  void setCommentBefore (const string & comment_before);
320 
325  char *extend_scanbuffer (int size);
326 
327 public:
328 
329  virtual void error(string error);
330  virtual void warning(string warning);
331 
332 };
333 
334 #endif // Scanner_h
c++ interface for logging
Definition: libycp/src/include/ycp/y2log.h:73
struct formalparamstack * next
ptr to next formal parameter
Definition: Scanner.h:45
char * m_scandataBufferPtr
Definition: Scanner.h:136
constTypePtr m_scannedType
Definition: Scanner.h:121
bool bval
Definition: Scanner.h:52
formalparam_t * fpval
Definition: Scanner.h:62
struct formalparamstack formalparam_t
linked list for formal parameters (not a stack at all)
Definition: Scanner.h:51
string m_filename
Definition: Scanner.h:92
linked list for formal parameters (not a stack at all)
Definition: Scanner.h:44
Definition: SymbolTable.h:100
constTypePtr type
type of formal parameter
Definition: Scanner.h:47
double fval
Definition: Scanner.h:54
declaration_t * dval
Definition: Scanner.h:60
std::list< std::pair< std::string, Y2Namespace * > > m_autoimport_predefined
Definition: Scanner.h:169
STL namespace.
FILE * m_inputFile
Definition: Scanner.h:104
#define yyFlexLexer
Definition: scanner.cc:23
char * yval
Definition: Scanner.h:58
const char * nval
Definition: Scanner.h:59
std::string format(const char *format,...) __attribute__((format(printf
Definition: IniParser.cc:1030
char * pval
Definition: Scanner.h:57
long long ival
Definition: Scanner.h:53
SymbolTable * m_localTable
Definition: Scanner.h:156
int m_inputFd
Definition: Scanner.h:111
const char * sval
Definition: Scanner.h:55
unsigned int line
line number of name token
Definition: Scanner.h:48
Scanner for scanning YCP syntax.
Definition: Scanner.h:76
TableEntry * tval
Definition: Scanner.h:61
static int variable_not_used __attribute__((unused))
int yylex(YYSTYPE *, void *)
Definition: parser.cc:6310
int m_lineNumber
Definition: Scanner.h:131
void * val
Definition: Scanner.h:63
Definition: StaticDeclaration.h:71
SymbolTable * m_globalTable
Definition: Scanner.h:155
std::string m_commentBefore
Definition: Scanner.h:126
const char * name
name of formal parameter
Definition: Scanner.h:46
unsigned char * cval
Definition: Scanner.h:56
bool m_owningLocal
Definition: Scanner.h:163
char * m_scandataBuffer
Definition: Scanner.h:141
Definition: Y2Namespace.h:43
const char * m_inputBuffer
Definition: Scanner.h:98
bool m_owningGlobal
Definition: Scanner.h:162
int m_scandataBufferSize
Definition: Scanner.h:146
bool m_buffered
Definition: Scanner.h:152
Definition: SymbolTable.h:42
tokenValue m_scannedValue
Definition: Scanner.h:116

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