00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: Parser.h 00014 00015 Author: Mathias Kettner <kettner@suse.de> 00016 Maintainer: Klaus Kaempf <kkaempf@suse.de> 00017 00018 /-*/ 00019 /* 00020 * YCP interface to the bison generated parser 00021 */ 00022 00023 #ifndef Parser_h 00024 #define Parser_h 00025 00026 #include <stdio.h> 00027 #include <string> 00028 00029 #include "ycp/Scanner.h" 00030 #include "ycp/YCode.h" 00031 00032 class Scanner; 00033 class blockstack_t; 00034 class scannerstack_t; 00035 class YBlock; 00036 00063 class Parser 00064 { 00068 Scanner *m_scanner; 00069 00074 bool m_buffered; 00075 00080 bool m_depends; 00081 00085 string m_restore_name; 00086 00090 bool m_at_eof; 00091 00092 public: 00097 YCodePtr m_result; 00098 00102 int m_lineno; 00103 00104 //parserret: 00105 //const char *filename; 00106 //parserret() : result (0), lineno (0) { } 00107 00112 int m_loop_count; 00113 00118 int m_parser_errors; 00119 00123 blockstack_t *m_block_stack; 00124 00128 scannerstack_t *m_scanner_stack; 00129 00133 YBlockPtr m_current_block; 00134 00138 int m_blockstack_depth; 00139 00143 void init (); 00144 00145 public: 00150 Parser(); 00151 00158 Parser(FILE *file, const char *filename=0); 00159 00163 Parser(const char *buf); 00164 00171 Parser(int fd, const char *filename=0); 00172 00176 ~Parser(); 00177 00190 YCodePtr parse(SymbolTable *gTable = 0, SymbolTable *lTable = 0); 00191 00195 Scanner *scanner (); 00196 00201 void setScanner (Scanner *); 00202 00208 bool atEOF (); 00209 00216 void setInput(FILE *file, const char *filename=0); 00217 00221 void setInput(const char *buf); 00222 00229 void setInput(int fd, const char *filename = 0); 00230 00235 void setBuffered(); 00236 00240 void setDepends(); 00241 00245 bool depends() const; 00246 00250 const char *filename () const; 00251 00255 void setFilename (const string f); 00256 00260 void restoreFilename () const; 00261 00266 // void reset(); 00267 }; 00268 00269 #endif // Parser_h