#include <Scanner.h>
Public Member Functions | |
Scanner (FILE *inputfile, const char *filename) | |
Scanner (const char *inputbuffer) | |
Scanner (int input_fd, const char *filename) | |
~Scanner () | |
void | setBuffered () |
void | initTables (SymbolTable *globalTable, SymbolTable *localTable) |
SymbolTable * | globalTable () const |
SymbolTable * | localTable () const |
int | yylex () |
int | LexerInput (char *buf, int max_size) |
void | LexerError (const char *msg) |
tokenValue | scannedValue () const |
constTypePtr | scannedType () const |
int | lineNumber () const |
void | logError (const char *loginfo, int lineno,...) __attribute__((format(printf |
void | logWarning (const char *loginfo, int lineno,...) __attribute__((format(printf |
const std::list< std::pair< std::string, Y2Namespace * > > & | autoimport_predefined () const |
void | closeInput () |
Static Public Member Functions | |
char * | doStrdup (const char *s) |
Private Member Functions | |
void | setScannedToken (const tokenValue &value, constTypePtr type) |
char * | extend_scanbuffer (int size) |
Private Attributes | |
string | m_filename |
const char * | m_inputBuffer |
FILE * | m_inputFile |
int | m_inputFd |
tokenValue | m_scannedValue |
constTypePtr | m_scannedType |
int | m_lineNumber |
char * | m_scandataBufferPtr |
char * | m_scandataBuffer |
int | m_scandataBufferSize |
bool | m_buffered |
SymbolTable * | m_globalTable |
SymbolTable * | m_localTable |
bool | m_owningGlobal |
bool | m_owningLocal |
std::list< std::pair< std::string, Y2Namespace * > > | m_autoimport_predefined |
Static Private Attributes | |
const int | STRING_HUNK = 1024 |
|
Creates a new scanner that scans from an open clib-level file descriptor that has been opened with fopen(filename, "r"). You have to close the file yourself afterwards.
|
|
Creates a new scanner that scans from a zero terminated constant C string. Your buffer is left untouched. We don't make a copy of it, so ist must be valid all the time this class is used.
|
|
Creates a new scanner that scans from an open unix lowlevel file descriptor. You have to close the descriptor yourself afterwards
|
|
Cleans up |
|
get list of predefined namespaces which have been autoloaded by the scanner |
|
|
|
strdup via new, so delete [] can be used safely |
|
Internal helper function that deals with strings of arbitrary length |
|
return current globalTable. used by parser. |
|
Initialize tables for global and local symbols. If gTable and lTable are set, they're used instead of local ones. This is used for include files using the symbol tables of the including block. see: Parser::parse() |
|
Is called by the flex lexer, if a scan error occurs. Calls logError. |
|
Overriden from yyFlexLexer. The flex scanner uses this function to get the next input characters. Our implementation always returns just one character. Too much lookahead would result in blocking and deadlock in a protocol situation. FIXME: when reading from file read max_size characters
|
|
Gets the line number of the latest scanned token. |
|
return current localTable. used by parser. |
|
Is called by LexerError. Is also called by yyerror for error reporting. It reports the error via y2log and also reports the filename, if available and the linenumber.
|
|
logs a warning. |
|
Gets the value of the latest scanned token. Returns 0, if that token does not represent a proper value. |
|
Gets the value of the latest scanned token. Returns 0, if that token does not represent a proper value. |
|
Makes the scanner use buffering, i.e. read more than one character at once. |
|
Used in the rules of the scanner to define the value of a token. |
|
Scans and returns the next token. Return 0, in case of EOF. The value of the scanned token is saved in scanned_value and can be retrieved with scannedValue. The implementation of this function is generated by flex++. |
|
list of predefined namespace which have been auto-imported Y2Namespace is non-const since the block might get evaluated (constructor) |
|
Is true, if the input can be buffered, i.e. more than one character may be read at once in order to gain performance. |
|
The name of the file being parsed. It is used for generating nice error messages only. It is the empty string, if no filename is available (e.g. while scanning from stdin). |
|
|
|
If the YCP text source is given in form of a string buffer, this buffer is stored here. 0 otherwise. |
|
If the YCP text source is given in form of a unix lowlevel file descriptor, this variable holds the descriptor. Must be -1 otherwise, since 0 is a valid file descriptor (stdin). |
|
If the YCP text source is given in form of an open clib-level file pointer, this variable hold it. Must be 0 otherwise. |
|
Holds the line number of scanned_value |
|
|
|
This is a kludge rather than proper memory management. Klaus, who owns the tables in various cases? |
|
|
|
Used for string constant scanning |
|
Used for string constant scanning |
|
Used for string constant scanning |
|
Holds the type of the value being scanned lastly. |
|
Holds the value being scanned lastly. |
|
Allocate this many bytes for a string. If a larger string is encountered, the buffer size is at least doubled. I don't believe, that the value of STRING_HUNK has a great impact on speed. 1024 is probably a nice value for it. |