Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Examples

Scanner.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |  
00003 |                      __   __    ____ _____ ____                      |  
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |  
00005 |                       \ V / _` \___ \ | |   __) |                    |  
00006 |                        | | (_| |___) || |  / __/                     |  
00007 |                        |_|\__,_|____/ |_| |_____|                    |  
00008 |                                                                      |  
00009 |                               core system                            | 
00010 |                                                        (C) SuSE GmbH |  
00011 \----------------------------------------------------------------------/ 
00012 
00013    File:        Scanner.h
00014 
00015    Author:      Klaus Kaempf <kkaempf@suse.de>
00016                 Mathias Kettner <kettner@suse.de>
00017    Maintainer:  Klaus Kaempf <kkaempf@suse.de>
00018 
00019 /-*/
00020 // -*- c++ -*-
00021 
00022 /*
00023  * Interface to the flex generated scanner
00024  *
00025  */
00026 
00027 #ifndef Scanner_h
00028 #define Scanner_h
00029 
00030 #include "FlexLexer.h"
00031 #include "ycp/StaticDeclaration.h"
00032 #include <stdio.h>
00033 #include <string>
00034 
00035 class TableEntry;
00036 class SymbolTable;
00037 #include "ycp/Type.h"
00038 
00039 // linked list for formal parameters
00040 typedef struct formalparamstack {
00041     struct formalparamstack *next;      // ptr to next formal parameter
00042     const char *name;                   // name of formal parameter
00043     constTypePtr type;                  // type of formal parameter
00044     unsigned int line;                  // line number of name token
00045 } formalparam_t;
00046 
00047 typedef union {
00048         bool bval;              // boolean
00049         long long ival;         // integer
00050         double fval;            // float
00051         const char *sval;       // string
00052         unsigned char *cval;    // bytecode
00053         char *pval;             // path
00054         char *yval;             // symbol
00055         const char *nval;       // name
00056         declaration_t *dval;    // builtin declaration
00057         TableEntry *tval;       // table entry
00058         formalparam_t *fpval;   // formal parameter chain
00059         void *val;              // any other value
00060 } tokenValue;
00061 
00072 class Scanner : public yyFlexLexer
00073 {
00074 private:
00081     static const int STRING_HUNK = 1024;
00082 
00088     string m_filename;
00089 
00094     const char *m_inputBuffer;
00095 
00100     FILE *m_inputFile;
00101 
00107     int m_inputFd;
00108 
00112     tokenValue m_scannedValue;
00113 
00117     constTypePtr m_scannedType;
00118 
00122     int m_lineNumber;
00123 
00127     char *m_scandataBufferPtr;
00128 
00132     char *m_scandataBuffer;
00133 
00137     int m_scandataBufferSize;
00138 
00143     bool m_buffered;
00144 
00145     // current symbol tables, used also in parser.yy
00146     SymbolTable *m_globalTable;
00147     SymbolTable *m_localTable;
00148 
00153     bool m_owningGlobal;
00154     bool m_owningLocal;
00155 
00160     std::list<std::pair<std::string, Y2Namespace *> > m_autoimport_predefined;
00161 
00162 public:
00171     Scanner (FILE *inputfile, const char *filename);
00172 
00179     Scanner(const char *inputbuffer);
00180 
00189     Scanner(int input_fd, const char *filename);
00190 
00194     ~Scanner();
00195 
00200     void setBuffered();
00201 
00210     void initTables (SymbolTable *globalTable, SymbolTable *localTable);
00211 
00216     SymbolTable *globalTable () const;
00217 
00222     SymbolTable *localTable () const;
00223 
00230     int yylex();
00231 
00242     int LexerInput( char* buf, int max_size );
00243 
00248     void LexerError( const char* msg );
00249 
00254     tokenValue scannedValue() const;
00255 
00260     constTypePtr scannedType() const;
00261 
00265     int lineNumber() const;
00266 
00274     void logError (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
00275 
00279     void logWarning (const char *loginfo, int lineno, ...) __attribute__ ((format (printf, 2, 4)));
00280 
00284     const std::list<std::pair<std::string, Y2Namespace *> > & autoimport_predefined() const { return m_autoimport_predefined; };
00285 
00289     static char *doStrdup (const char *s);
00290 
00294     void closeInput ();
00295     
00296 private:
00301     void setScannedToken (const tokenValue & value, constTypePtr type);
00302 
00307     char *extend_scanbuffer (int size);
00308 
00309 };
00310 
00311 #endif // Scanner_h

Generated on Fri Nov 9 18:15:22 2007 for yast2-core by doxygen 1.3.6