Skip to content

Commit

Permalink
adrpo checking in version 2004-05-14
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1173 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed May 14, 2004
1 parent 1a0e285 commit 25dd20f
Show file tree
Hide file tree
Showing 21 changed files with 8,564 additions and 7,348 deletions.
29 changes: 14 additions & 15 deletions xml/ModelicaXML.cpp
Expand Up @@ -8,7 +8,7 @@
Source:
Revision:
Author: Adrian Pop
Date: 2003-10-25
Date: 2004-05-12
*******************************************************************************
*/

Expand All @@ -34,7 +34,7 @@
#include "antlr/AST.hpp"
#include "antlr/CommonAST.hpp"
#include "antlr/ASTFactory.hpp"

#include "MyAST.h"


using namespace std;
Expand All @@ -49,7 +49,7 @@ using namespace std;
int main( int argc, char* argv[] )
{
ifstream file;
ofstream wfile;
//ofstream wfile;

// check if the modelica file is present in the argument list
if (argc != 2){
Expand All @@ -67,20 +67,20 @@ int main( int argc, char* argv[] )
return 2;
}

/*try*/
try
{
antlr::ASTFactory my_factory;
antlr::ASTFactory my_factory("MyAST", MyAST::factory);
modelica_lexer lexer(file);
lexer.setFilename(argv[1]);
modelica_parser parser(lexer);
parser.initializeASTFactory(my_factory);
parser.setASTFactory(&my_factory);
parser.stored_definition();
wfile.open("output.txt");
wfile << parser.getAST()->toStringList() << endl;
//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;
//parse_tree_dumper dumper(std::cout);
//std::cout << std::flush;
if (ast)
{
//dumper.dump(ast);
Expand All @@ -89,14 +89,14 @@ int main( int argc, char* argv[] )
walker.setASTFactory(&my_factory);
std::string xmlFile(argv[1]);
xmlFile += ".xml";
walker.stored_definition(ast, xmlFile);
walker.stored_definition(RefMyAST(ast), xmlFile, argv[1]);
}
else
{
wfile << std::endl << "Parse error: <NULL> AST\n";
//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;
Expand All @@ -113,11 +113,10 @@ int main( int argc, char* argv[] )
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();
//wfile << std::endl << "SUCCESS! File:" << argv[1] << std::endl;
//wfile.close();
return EXIT_SUCCESS;
}
10 changes: 5 additions & 5 deletions xml/ModelicaXML.sln
@@ -1,12 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModelicaXML", "ModelicaXML.vcproj", "{57E77DDB-F6BC-4CE1-91E7-D669544DCFFC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{57E77DDB-F6BC-4CE1-91E7-D669544DCFFC}.Debug.ActiveCfg = Debug|Win32
Expand Down
79 changes: 60 additions & 19 deletions xml/ModelicaXML.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Version="7.10"
Name="ModelicaXML"
ProjectGUID="{57E77DDB-F6BC-4CE1-91E7-D669544DCFFC}"
Keyword="Win32Proj">
Expand All @@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)\antlr-2.7.2\lib\cpp\&quot;;&quot;$(InputDir)\xercesc\include&quot;"
AdditionalIncludeDirectories="&quot;$(InputDir)\..\antlr-2.7.3\lib\cpp\&quot;;&quot;$(InputDir)\..\xercesc\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
Expand All @@ -35,7 +35,7 @@
AdditionalDependencies="antlrD.lib xerces-c_2D.lib"
OutputFile="$(OutDir)/ModelicaXML.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(InputDir)\xercesc\lib&quot;;&quot;$(InputDir)\lib\&quot;"
AdditionalLibraryDirectories="&quot;$(InputDir)\..\xercesc\lib&quot;;&quot;$(InputDir)\lib\&quot;"
IgnoreDefaultLibraryNames="libcmtd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/ModelicaXML.pdb"
Expand All @@ -53,8 +53,14 @@
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
Expand All @@ -67,7 +73,7 @@
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="&quot;$(InputDir)\antlr-2.7.2\lib\cpp\&quot;;&quot;$(InputDir)\xercesc\include&quot;"
AdditionalIncludeDirectories="&quot;$(InputDir)\..\antlr-2.7.3\lib\cpp\&quot;;&quot;$(InputDir)\..\xercesc\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
Expand All @@ -81,9 +87,9 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="antlr.lib xerces-c_2.lib"
OutputFile="$(OutDir)/ModelicaXMLr.exe"
OutputFile="$(OutDir)/ModelicaXML.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(InputDir)\xercesc\lib&quot;;&quot;$(InputDir)\lib\&quot;"
AdditionalLibraryDirectories="&quot;$(InputDir)\..\xercesc\lib&quot;;&quot;$(InputDir)\lib\&quot;"
IgnoreDefaultLibraryNames="libcmt.lib"
GenerateDebugInformation="TRUE"
SubSystem="1"
Expand All @@ -102,20 +108,22 @@
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="ModelicaXML.cpp">
</File>
<File
RelativePath="ModelicaXMLUtilities.cpp">
</File>
<File
RelativePath="modelica_lexer.cpp">
</File>
Expand Down Expand Up @@ -164,6 +172,12 @@
<File
RelativePath="modelica_tree_parser.cpp">
</File>
<File
RelativePath="ModelicaXML.cpp">
</File>
<File
RelativePath="ModelicaXMLUtilities.cpp">
</File>
<File
RelativePath="parse_tree_dumper.cpp">
</File>
Expand Down Expand Up @@ -194,12 +208,6 @@
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="ModelicaXMLUtilities.hpp">
</File>
<File
RelativePath="modelicaTokenTypes.hpp">
</File>
<File
RelativePath="modelica_lexer.hpp">
</File>
Expand All @@ -215,9 +223,18 @@
<File
RelativePath="modelica_tree_parserTokenTypes.hpp">
</File>
<File
RelativePath="modelicaTokenTypes.hpp">
</File>
<File
RelativePath="modelicaxml.h">
</File>
<File
RelativePath="ModelicaXMLUtilities.hpp">
</File>
<File
RelativePath=".\MyAST.h">
</File>
<File
RelativePath="parse_tree_dumper.hpp">
</File>
Expand All @@ -243,9 +260,18 @@
<File
RelativePath="ModelicaTreeParserTokenTypes.txt">
</File>
<File
RelativePath=".\modelicaxml-detailed.dtd">
</File>
<File
RelativePath="modelicaxml-v2.dtd">
</File>
<File
RelativePath=".\walker-2004-03-18.txt">
</File>
<File
RelativePath=".\save\walker.g">
</File>
</Filter>
<Filter
Name="testfiles"
Expand All @@ -256,9 +282,24 @@
<File
RelativePath="testsuite\GenMicroCircuit.mo">
</File>
<File
RelativePath="testsuite\GenMicroCircuit.mo.xml">
</File>
<File
RelativePath="test\output.txt">
</File>
<File
RelativePath="testsuite\SecondOrderSystem.mo">
</File>
<File
RelativePath="test\test.mo">
</File>
<File
RelativePath="test\test.mo.xml">
</File>
<File
RelativePath="trash.txt">
</File>
</Filter>
</Files>
<Globals>
Expand Down
10 changes: 2 additions & 8 deletions xml/README.txt
Expand Up @@ -4,15 +4,9 @@ ModelicaXML
Adrian Pop adrpo@ida.liu.se
http://www.ida.liu.se/~adrpo/modelica/

2004-02-26 ModelicaXML alpha version
2004-05-14 ModelicaXML version 0.2
----------------------------------------------------------------------------
# this version is not stable yet and:

* some element contents are not yet as they are defined in modelica.dtd.
* some nonterminals should not appear in the xml file.

# tested on Modelica base library 1.5.
# packaged with striped down versions of antlr and xerces.
# it works on Windows (VC++ 7.0, GCC-Cygwin), Linux, Solaris
- with some recompilation of libraries and Makefile hacks
-----------------------------------------------------------------------------
Expand All @@ -21,6 +15,6 @@ http://www.ida.liu.se/~adrpo/modelica/
Note:
- Changes into include/lib inside MSVC++ project are
needed to compile this.
- ANTLR and XercesC++ are needed
- ANTLR > 2.7.3 and XercesC++ 2.5.0 are needed


17 changes: 13 additions & 4 deletions xml/modelicaTokenTypes.hpp
@@ -1,8 +1,15 @@
#ifndef INC_modelicaTokenTypes_hpp_
#define INC_modelicaTokenTypes_hpp_

/* $ANTLR 2.7.2: "modelica_lexer.g" -> "modelicaTokenTypes.hpp"$ */
struct modelicaTokenTypes {
/* $ANTLR 2.7.3: "modelica_lexer.g" -> "modelicaTokenTypes.hpp"$ */

#ifndef CUSTOM_API
# define CUSTOM_API
#endif

#ifdef __cplusplus
struct CUSTOM_API modelicaTokenTypes {
#endif
enum {
EOF_ = 1,
ALGORITHM = 4,
Expand Down Expand Up @@ -40,8 +47,8 @@ struct modelicaTokenTypes {
LOOP = 36,
MODEL = 37,
NOT = 38,
OVERLOAD = 39,
OUTER = 40,
OUTER = 39,
OVERLOAD = 40,
OR = 41,
OUTPUT = 42,
PACKAGE = 43,
Expand Down Expand Up @@ -98,5 +105,7 @@ struct modelicaTokenTypes {
ESC = 94,
NULL_TREE_LOOKAHEAD = 3
};
#ifdef __cplusplus
};
#endif
#endif /*INC_modelicaTokenTypes_hpp_*/
8 changes: 4 additions & 4 deletions xml/modelicaTokenTypes.txt
@@ -1,4 +1,4 @@
// $ANTLR 2.7.2: modelica_lexer.g -> modelicaTokenTypes.txt$
// $ANTLR 2.7.3: modelica_lexer.g -> modelicaTokenTypes.txt$
modelica // output token vocab name
ALGORITHM="algorithm"=4
AND="and"=5
Expand Down Expand Up @@ -35,8 +35,8 @@ INPUT="input"=35
LOOP="loop"=36
MODEL="model"=37
NOT="not"=38
OVERLOAD="overload"=39
OUTER="outer"=40
OUTER="outer"=39
OVERLOAD="overload"=40
OR="or"=41
OUTPUT="output"=42
PACKAGE="package"=43
Expand Down Expand Up @@ -82,7 +82,7 @@ WS=82
ML_COMMENT=83
ML_COMMENT_CHAR=84
SL_COMMENT=85
IDENT=86
IDENT("an identifier")=86
NONDIGIT=87
DIGIT=88
EXPONENT=89
Expand Down

0 comments on commit 25dd20f

Please sign in to comment.