-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the XML part with the latest version of ModelicaXML and FlatM…
…odelicaXML git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2377 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
60 changed files
with
47,960 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#ifndef INC_FlatModelicaLexer_hpp_ | ||
#define INC_FlatModelicaLexer_hpp_ | ||
|
||
#include <antlr/config.hpp> | ||
/* $ANTLR 2.7.3: "flat_modelica_lexer.g" -> "FlatModelicaLexer.hpp"$ */ | ||
#include <antlr/CommonToken.hpp> | ||
#include <antlr/InputBuffer.hpp> | ||
#include <antlr/BitSet.hpp> | ||
#include "FlatModelicaTokenTypes.hpp" | ||
#include <antlr/CharScanner.hpp> | ||
#line 1 "flat_modelica_lexer.g" | ||
|
||
#ifdef WIN32 | ||
#pragma warning( disable : 4267) // Disable warning messages C4267 | ||
#endif | ||
//disable: 'initializing' : conversion from 'size_t' to 'int', possible loss of data | ||
|
||
#line 19 "FlatModelicaLexer.hpp" | ||
class CUSTOM_API FlatModelicaLexer : public ANTLR_USE_NAMESPACE(antlr)CharScanner, public FlatModelicaTokenTypes | ||
{ | ||
#line 1 "flat_modelica_lexer.g" | ||
#line 23 "FlatModelicaLexer.hpp" | ||
private: | ||
void initLiterals(); | ||
public: | ||
bool getCaseSensitiveLiterals() const | ||
{ | ||
return true; | ||
} | ||
public: | ||
FlatModelicaLexer(ANTLR_USE_NAMESPACE(std)istream& in); | ||
FlatModelicaLexer(ANTLR_USE_NAMESPACE(antlr)InputBuffer& ib); | ||
FlatModelicaLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state); | ||
ANTLR_USE_NAMESPACE(antlr)RefToken nextToken(); | ||
public: void mLPAR(bool _createToken); | ||
public: void mRPAR(bool _createToken); | ||
public: void mLBRACK(bool _createToken); | ||
public: void mRBRACK(bool _createToken); | ||
public: void mLBRACE(bool _createToken); | ||
public: void mRBRACE(bool _createToken); | ||
public: void mEQUALS(bool _createToken); | ||
public: void mASSIGN(bool _createToken); | ||
public: void mPLUS(bool _createToken); | ||
public: void mMINUS(bool _createToken); | ||
public: void mSTAR(bool _createToken); | ||
public: void mSLASH(bool _createToken); | ||
public: void mDOT(bool _createToken); | ||
public: void mCOMMA(bool _createToken); | ||
public: void mLESS(bool _createToken); | ||
public: void mLESSEQ(bool _createToken); | ||
public: void mGREATER(bool _createToken); | ||
public: void mGREATEREQ(bool _createToken); | ||
public: void mEQEQ(bool _createToken); | ||
public: void mLESSGT(bool _createToken); | ||
public: void mCOLON(bool _createToken); | ||
public: void mSEMICOLON(bool _createToken); | ||
public: void mPOWER(bool _createToken); | ||
public: void mWS(bool _createToken); | ||
public: void mML_COMMENT(bool _createToken); | ||
protected: void mML_COMMENT_CHAR(bool _createToken); | ||
public: void mSL_COMMENT(bool _createToken); | ||
public: void mIDENT(bool _createToken); | ||
protected: void mNONDIGIT(bool _createToken); | ||
protected: void mDIGIT(bool _createToken); | ||
protected: void mEXPONENT(bool _createToken); | ||
public: void mUNSIGNED_INTEGER(bool _createToken); | ||
public: void mSTRING(bool _createToken); | ||
protected: void mSCHAR(bool _createToken); | ||
protected: void mSESCAPE(bool _createToken); | ||
protected: void mESC(bool _createToken); | ||
private: | ||
|
||
static const unsigned long _tokenSet_0_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0; | ||
static const unsigned long _tokenSet_1_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1; | ||
static const unsigned long _tokenSet_2_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_2; | ||
static const unsigned long _tokenSet_3_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3; | ||
static const unsigned long _tokenSet_4_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4; | ||
static const unsigned long _tokenSet_5_data_[]; | ||
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_5; | ||
}; | ||
|
||
#endif /*INC_FlatModelicaLexer_hpp_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* Copyright (c)2000 Linköping University Sweden, All Rights Reserved | ||
/* Programming Environments Laboratory | ||
******************************************************************************* | ||
File : "FlatModelicaXML.cpp" | ||
Author : Adrian Pop 2005-05-26 | ||
Description : Antlr Parser caller and XML serializer for Flat Modelica | ||
------------------------------------------------------------------------------- | ||
Source: | ||
Revision: | ||
Author: Adrian Pop | ||
Date: 2004-05-26 | ||
******************************************************************************* | ||
*/ | ||
|
||
|
||
//** HEADERS ************************************************************ | ||
|
||
// standard include files | ||
#include <iostream> | ||
#include <sstream> | ||
#include <cstdlib> | ||
#include <fstream> | ||
|
||
// ModelicaParser related include file | ||
// the following header files are automatically generated by the antlr parser (Do not modify them) | ||
#include "Flat_Modelica_Lexer.hpp" | ||
#include "Flat_Modelica_Parser.hpp" | ||
#include "Flat_Modelica_Tree_Parser.hpp" | ||
#include "Flat_Modelica_ParserTokenTypes.hpp" | ||
#include "Flat_Modelica_Tree_ParserTokenTypes.hpp" | ||
#include "parse_tree_dumper.hpp" | ||
|
||
// antlr related include files | ||
#include "antlr/AST.hpp" | ||
#include "antlr/CommonAST.hpp" | ||
#include "antlr/ASTFactory.hpp" | ||
#include "MyAST.h" | ||
|
||
|
||
using namespace std; | ||
|
||
//----------------------------------------------------------------------------- | ||
// func : main function for the modelica optimizer | ||
// author : Adrian Pop 2003-10-25 | ||
// organization : Linköping University Sweden, Programming Environment Laboratory | ||
//----------------------------------------------------------------------------- | ||
// the function accept as argument a flattened modelica file ad will generate as output the corresponding C files | ||
// for the Modelica Simulator | ||
int main( int argc, char* argv[] ) | ||
{ | ||
ifstream file; | ||
//ofstream wfile; | ||
|
||
// check if the modelica file is present in the argument list | ||
if (argc < 2) | ||
{ | ||
cerr << "Incorrect number of arguments\n"; | ||
return 1; | ||
} | ||
|
||
//open the file passed as an argument | ||
file.open(argv[1]); | ||
|
||
//if the file cannot be opened | ||
if (!file) | ||
{ | ||
cerr << "Could not open file: " << argv[1] << "\n"; | ||
getchar(); | ||
return 2; | ||
} | ||
|
||
try | ||
{ | ||
antlr::ASTFactory my_factory("MyAST", MyAST::factory); | ||
flat_modelica_lexer lexer(file); | ||
lexer.setFilename(argv[1]); | ||
flat_modelica_parser parser(lexer); | ||
parser.initializeASTFactory(my_factory); | ||
parser.setASTFactory(&my_factory); | ||
parser.stored_definition(); | ||
//wfile.open("output.txt"); | ||
//wfile << parser.getAST()->toStringList() << std::endl; | ||
antlr::RefAST ast = parser.getAST(); | ||
//parse_tree_dumper dumper(std::cout); | ||
std::cout << std::flush; | ||
if (ast) | ||
{ | ||
//dumper.dump(ast); | ||
flat_modelica_tree_parser walker; | ||
walker.initializeASTFactory(my_factory); | ||
walker.setASTFactory(&my_factory); | ||
std::string xmlFile(argv[1]); | ||
/* | ||
http://www.ida.liu.se/~adrpo/modelica/xml/modelicaxml-v2.dtd | ||
c:\\dev\\src\\modelicaxml\\modelicaxml-v2.dtd | ||
*/ | ||
// set the doctype | ||
std::string docType( | ||
(argc > 2)?argv[2]:"http://www.ida.liu.se/~adrpo/modelica/xml/modelicaxml-v2.dtd"); | ||
xmlFile += ".xml"; | ||
walker.stored_definition( | ||
RefMyAST(ast), | ||
xmlFile, | ||
argv[1], | ||
docType); | ||
} | ||
else | ||
{ | ||
//wfile << std::endl << "Parse error: <NULL> AST\n"; | ||
std::cerr << std::endl << "Parse error: <NULL> AST\n"; | ||
} | ||
} | ||
catch(antlr::ANTLRException& e) | ||
{ | ||
std::cerr << "Parser/Lexer/Walker Exception: " << e.toString() << std::endl; | ||
file.close(); | ||
std::cerr << "ERROR! File:" << argv[1] << std::endl; | ||
getchar(); | ||
return EXIT_FAILURE; | ||
} | ||
catch(std::exception& e) | ||
{ | ||
std::cerr << "Exception: " << e.what() << std::endl; | ||
file.close(); | ||
std::cerr << "ERROR! File:" << argv[1] << std::endl; | ||
getchar(); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
file.close(); | ||
std::cout << "SUCCESS! File:" << argv[1] << std::endl; | ||
//wfile << std::endl << "SUCCESS! File:" << argv[1] << std::endl; | ||
//wfile.close(); | ||
return EXIT_SUCCESS; | ||
} |
Oops, something went wrong.