nedparser.h

Go to the documentation of this file.
00001 //==========================================================================
00002 //  NEDPARSER.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //==========================================================================
00008 
00009 /*--------------------------------------------------------------*
00010   Copyright (C) 2002-2008 Andras Varga
00011   Copyright (C) 2006-2008 OpenSim Ltd.
00012 
00013   This file is distributed WITHOUT ANY WARRANTY. See the file
00014   `license' for details on this and other legal matters.
00015 *--------------------------------------------------------------*/
00016 
00017 #ifndef __NEDPARSER_H
00018 #define __NEDPARSER_H
00019 
00020 #include <stdio.h>
00021 #include "nedelement.h"
00022 #include "nedyydefs.h"
00023 #include "nederror.h"
00024 
00025 NAMESPACE_BEGIN
00026 
00027 class NEDFileBuffer;
00028 class NEDParser;
00029 
00030 extern NEDParser *np;
00031 
00032 /* to EXPR_TYPE: */
00033 #define TYPE_NUMERIC   'N'
00034 #define TYPE_CONST_NUM 'C'
00035 #define TYPE_STRING    'S'
00036 #define TYPE_BOOL      'B'
00037 #define TYPE_XML       'X'
00038 #define TYPE_ANYTYPE   'A'
00039 
00040 
00049 class NEDXML_API NEDParser
00050 {
00051   public:
00052     // INTERNAL: error and debug handling, called from grammar file
00053     void error(const char *msg, int line);
00054 
00055     NEDErrorStore *getErrors() {return errors;}
00056     NEDFileBuffer *getSource() {return nedsource;}
00057 
00058   protected:
00059     bool parseexpr;            // whether to parse expressions or not
00060     bool storesrc;             // whether to fill in sourceCode attributes
00061     const char *filename;      // name of file being parsed
00062     NEDErrorStore *errors;     // accumulates error messages
00063     NEDFileBuffer *nedsource;  // represents the source file
00064 
00065     bool loadFile(const char *osfname, const char *fname);
00066     bool loadText(const char *nedtext, const char *fname);
00067     NEDElement *parseNED();
00068     NEDElement *parseMSG();
00069     static bool guessIsNEDInNewSyntax(const char *txt);
00070 
00071   public:
00075     NEDParser(NEDErrorStore *e);
00076 
00080     ~NEDParser();
00081 
00086     static const char *getBuiltInDeclarations();
00087 
00093     void setParseExpressions(bool b) {parseexpr = b;}
00094 
00100     void setStoreSource(bool b) {storesrc = b;}
00101 
00105     bool getParseExpressionsFlag() {return parseexpr;}
00106 
00110     bool getStoreSourceFlag() {return storesrc;}
00111 
00115     const char *getFileName() {return filename;}
00116 
00123     NEDElement *parseNEDFile(const char *osfname, const char *fname=NULL);
00124 
00131     NEDElement *parseNEDText(const char *nedtext, const char *fname=NULL);
00132 
00137     NEDElement *parseNEDExpression(const char *nedexpression);
00138 
00145     NEDElement *parseMSGFile(const char *osfname, const char *fname=NULL);
00146 
00153     NEDElement *parseMSGText(const char *nedtext, const char *fname=NULL);
00154 };
00155 
00156 NAMESPACE_END
00157 
00158 
00159 #endif
00160 
Generated on Tue Dec 2 11:16:31 2014 for OMNeT++ NEDXML by  doxygen 1.6.3