Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed parser to a 1.4 compliant antlr-based parser. made some updat…
…es to absyn to handle new 1.4 primitives. Fixed for-loop scooping in equations git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@667 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
henjo
committed
Dec 5, 2001
1 parent
0678dd1
commit f1a259b
Showing
11 changed files
with
1,855 additions
and
7 deletions.
There are no files selected for viewing
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
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
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,69 @@ | ||
CC=gcc | ||
CXX=g++ | ||
|
||
ANTLR_HOME = /home/pelab/pub/pkg/antlr-2.7.1 | ||
ANTLR_CPP = $(ANTLR_HOME)/lib/cpp/gcc-2.95.2 | ||
|
||
ANTLR_INCP = -I$(ANTLR_CPP)/include | ||
ANTLR_LIBP = -L$(ANTLR_CPP)/lib | ||
|
||
RML_HOME = /home/pelab/pub/pkg/rml/current | ||
RML_INCP = -I$(RML_HOME)/sparc-sol2-gcc/include/plain | ||
|
||
PARSE_HOME = ../../modelica_parser | ||
PARSE_INCP = -I$(PARSE_HOME)/src | ||
PARSE_LIBP = -L$(PARSE_HOME)/src | ||
|
||
INCP = $(ANTLR_INCP) $(PARSE_INCP) $(RML_INCP) | ||
LIBP = $(ANTLR_LIBP) $(PARSE_LIBP) | ||
|
||
CFLAGS = $(INCP) -g -Wall | ||
CXXFLAGS = $(CFLAGS) | ||
LINKFLAGS = $(LIBP) | ||
|
||
LIBS = -lantlr -lmodelica_parser | ||
|
||
PARSER_OBJS = $(PARSE_HOME)/src/modelica_parser.o $(PARSE_HOME)/src/modelica_lexer.o \ | ||
$(PARSE_HOME)/src/token_names.o $(PARSE_HOME)/src/parse_tree_dumper.o | ||
|
||
|
||
walkergen= modelica_tree_parser.cpp modelica_tree_parser.hpp \ | ||
modelica_tree_parserTokenTypes.hpp modelica_tree_parserTokenTypes.txt | ||
|
||
walkersrcs=$(filter %.cpp,$(walkergen)) | ||
walkerobjs=$(walkersrcs:.cpp=.o) | ||
|
||
OBJS += $(walkerobjs) $(PARSER_OBJS) parse.o yacclib.o | ||
|
||
ANTLR = java -cp $(ANTLR_HOME) antlr.Tool | ||
|
||
all : parser absyn_builder.a | ||
|
||
|
||
parser: | ||
cd $(PARSE_HOME)/src; $(MAKE) -f Makefile | ||
|
||
absyn_builder.a : $(OBJS) | ||
ar -r $@ $(OBJS) | ||
|
||
#walker : $(OBJS) | ||
# $(CXX) -o $@ $(OBJS) $(LINKFLAGS) $(LIBS) | ||
|
||
$(walkergen): walker.g modelica_parserTokenTypes.txt | ||
java antlr.Tool $(ANTLRFLAGS) $< | ||
|
||
|
||
modelica_parserTokenTypes.txt : $(PARSE_HOME)/src/modelica_parserTokenTypes.txt | ||
cp $(PARSE_HOME)/src/modelica_parserTokenTypes.txt . | ||
|
||
clean: | ||
-rm -f *.o *~ core *.core walker absyn_builder.a | ||
-rm -f $(walkergen) modelica_parserTokenTypes.txt | ||
|
||
reallyclean: clean | ||
|
||
|
||
|
||
walker.o : walker.cpp $(PARSE_HOME)/src/modelica_lexer.hpp $(PARSE_HOME)/src/modelica_parser.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,71 @@ | ||
|
||
#include <iostream> | ||
#include <strstream> | ||
#include <fstream> | ||
|
||
#include "modelica_lexer.hpp" | ||
#include "modelica_parser.hpp" | ||
#include "modelica_tree_parser.hpp" | ||
#include "parse_tree_dumper.hpp" | ||
|
||
extern "C" | ||
{ | ||
|
||
int check_debug_flag(char const* strdata); | ||
|
||
#include <errno.h> | ||
|
||
|
||
void Parser_5finit(void) | ||
{ | ||
} | ||
|
||
|
||
RML_BEGIN_LABEL(Parser__parse) | ||
{ | ||
char* filename = RML_STRINGDATA(rmlA0); | ||
bool debug = check_debug_flag("parsedump"); | ||
try | ||
{ | ||
std::ifstream stream(filename); | ||
|
||
modelica_lexer lex(stream); | ||
modelica_parser parse(lex); | ||
parse.stored_definition(); | ||
antlr::RefAST t = parse.getAST(); | ||
|
||
if (t) | ||
{ | ||
if (debug) | ||
{ | ||
parse_tree_dumper dumper(std::cout); | ||
dumper.dump(t); | ||
} | ||
|
||
modelica_tree_parser build; | ||
void* ast = build.stored_definition(t); | ||
|
||
if (debug) | ||
{ | ||
std::cout << "Build done\n"; | ||
} | ||
|
||
rmlA0 = ast ? ast : mk_nil(); | ||
|
||
RML_TAILCALLK(rmlSC); | ||
} | ||
} | ||
catch (std::exception &e) | ||
{ | ||
std::cerr << "Error while parsing:\n" << e.what() << "\n"; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << "Error while parsing\n"; | ||
} | ||
RML_TAILCALLK(rmlFC); | ||
} | ||
RML_END_LABEL | ||
|
||
} // extern "C" | ||
|
Oops, something went wrong.