00001 //========================================================================== 00002 // NEDPARSER.H - part of 00003 // 00004 // OMNeT++/OMNEST 00005 // Discrete System Simulation in C++ 00006 // 00007 //========================================================================== 00008 00009 /*--------------------------------------------------------------* 00010 Copyright (C) 2002-2005 Andras Varga 00011 00012 This file is distributed WITHOUT ANY WARRANTY. See the file 00013 `license' for details on this and other legal matters. 00014 *--------------------------------------------------------------*/ 00015 00016 #ifndef __NEDPARSER_H 00017 #define __NEDPARSER_H 00018 00019 #include <stdio.h> 00020 00021 #include "nedgrammar.h" 00022 #include "nedelement.h" 00023 00024 class NEDFileBuffer; 00025 class NEDParser; 00026 extern NEDParser *np; 00027 00028 /* to EXPR_TYPE: */ 00029 #define TYPE_NUMERIC 'N' 00030 #define TYPE_CONST_NUM 'C' 00031 #define TYPE_STRING 'S' 00032 #define TYPE_BOOL 'B' 00033 #define TYPE_XML 'X' 00034 #define TYPE_ANYTYPE 'A' 00035 00036 00045 class NEDParser 00046 { 00047 public: 00048 NEDElement *tree; // tree to build 00049 NEDFileBuffer *nedsource; // NED File object 00050 00051 protected: 00052 bool parseexpr; // whether to parse expressions or not 00053 bool storesrc; // whether to fill in sourceCode attributes 00054 00055 const char *filename; // file being parsed 00056 int num_errors; // number of errors so far 00057 00058 public: 00062 NEDParser(); 00063 00067 ~NEDParser(); 00068 00074 void setParseExpressions(bool b) {parseexpr = b;} 00075 00081 void setStoreSource(bool b) {storesrc = b;} 00082 00086 bool parseFile(const char *fname); 00087 00091 bool parseText(const char *nedtext); 00092 00097 NEDElement *getTree(); 00098 00099 // INTERNAL: error and debug handling, called from grammar file 00100 void error(const char *msg, int line); 00101 void dbg(YYLTYPE lc, const char *what); 00102 }; 00103 00104 #endif 00105