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 00065 class Parser 00066 { 00070 Scanner *m_scanner; 00071 00076 bool m_buffered; 00077 00082 bool m_depends; 00083 00087 bool m_at_eof; 00088 00089 public: 00094 YCodePtr m_result; 00095 00099 int m_lineno; 00100 00105 int m_loop_count; 00106 00111 int m_parser_errors; 00112 00116 blockstack_t *m_block_stack; 00117 00121 switchstack_t *m_switch_stack; 00122 00126 scannerstack_t *m_scanner_stack; 00127 00131 YBlockPtr m_current_block; 00132 00136 int m_blockstack_depth; 00137 00141 void init (); 00142 00143 public: 00148 Parser(); 00149 00156 Parser(FILE *file, const char *filename=0); 00157 00161 Parser(const char *buf); 00162 00169 Parser(int fd, const char *filename=0); 00170 00174 ~Parser(); 00175 00188 YCodePtr parse(SymbolTable *gTable = 0, SymbolTable *lTable = 0); 00189 00193 Scanner *scanner (); 00194 00199 void setScanner (Scanner *); 00200 00206 bool atEOF (); 00207 00214 void setInput(FILE *file, const char *filename=0); 00215 00219 void setInput(const char *buf); 00220 00227 void setInput(int fd, const char *filename = 0); 00228 00233 void setBuffered(); 00234 00238 void setDepends(); 00239 00243 bool depends() const; 00244 }; 00245 00246 #endif // Parser_h