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 switchstack_t; 00036 class YBlock; 00037 00064 class Parser 00065 { 00069 Scanner *m_scanner; 00070 00075 bool m_buffered; 00076 00081 bool m_depends; 00082 00086 bool m_at_eof; 00087 00088 public: 00093 YCodePtr m_result; 00094 00098 int m_lineno; 00099 00104 int m_loop_count; 00105 00110 int m_parser_errors; 00111 00115 blockstack_t *m_block_stack; 00116 00120 switchstack_t *m_switch_stack; 00121 00125 scannerstack_t *m_scanner_stack; 00126 00130 YBlockPtr m_current_block; 00131 00135 int m_blockstack_depth; 00136 00140 void init (); 00141 00142 public: 00147 Parser(); 00148 00155 Parser(FILE *file, const char *filename=0); 00156 00160 Parser(const char *buf); 00161 00168 Parser(int fd, const char *filename=0); 00169 00173 ~Parser(); 00174 00187 YCodePtr parse(SymbolTable *gTable = 0, SymbolTable *lTable = 0); 00188 00192 Scanner *scanner (); 00193 00198 void setScanner (Scanner *); 00199 00205 bool atEOF (); 00206 00213 void setInput(FILE *file, const char *filename=0); 00214 00218 void setInput(const char *buf); 00219 00226 void setInput(int fd, const char *filename = 0); 00227 00232 void setBuffered(); 00233 00237 void setDepends(); 00238 00242 bool depends() const; 00243 }; 00244 00245 #endif // Parser_h