Skip to content

Commit

Permalink
Reverted errormessages in parse. Did not work in interactive.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2240 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 21, 2006
1 parent 459cdb2 commit 82f11e2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 139 deletions.
2 changes: 1 addition & 1 deletion Compiler/Main.rml
Expand Up @@ -505,7 +505,7 @@ relation simcodegen: (Absyn.Path, (* classname *)
Util.string_append_list([cname_str,".makefile"]) => makefilename &
SimCodegen.generate_functions(p,dae,indexed_dlow',classname,funcfilename) => libs &
SimCodegen.generate_simulation_code(dae,indexed_dlow',ass1,ass2,m,mt,comps,classname,filename,funcfilename) &
SimCodegen.generate_init_data(indexed_dlow',classname,init_filename,0.0,1.0,500.0) &
SimCodegen.generate_init_data(indexed_dlow',classname,cname_str,init_filename,0.0,1.0,500.0) &
SimCodegen.generate_makefile(makefilename,cname_str,libs)
----------------------------------------------------------------------------------
simcodegen(classname,p,dae,dlow,ass1,ass2,m,mt,comps)
Expand Down
196 changes: 58 additions & 138 deletions Compiler/absyn_builder/parse.cpp
Expand Up @@ -403,6 +403,11 @@ extern "C"
* ast is initialized */
void* ast = mk_nil();

/* adrpo added 2004-10-27
* I use this to delete [] the temp allocation of get_string(...)
*/
char* getStringHolder = NULL;

try
{
ANTLR_USE_NAMESPACE(antlr)ASTFactory my_factory( "MyAST", MyAST::factory );
Expand Down Expand Up @@ -446,115 +451,52 @@ extern "C"
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string(e.getMessage()));
add_source_message(2, /* Grammar error, see Error.rml */
"GRAMMAR",
"ERROR",
"Parse error: %s",
tokens,
e.getLine(),
e.getColumn(),
e.getLine(),
e.getColumn(),
false,
"");
stringStream << "[" << e.getLine() << ":" << e.getColumn()
<< "]: error: " << e.getMessage() << std::endl;
// std::cerr << stringStream.str().c_str();
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon(("Error")); a1set=true;
rmlA1 = mk_scon((getStringHolder = get_string(stringStream))); a1set=true;
}
catch (ANTLR_USE_NAMESPACE(antlr)CharStreamException &e)
{

std::list<std::string> tokens;
tokens.push_back(std::string(lex.getText()));
rmlA0 = mk_nil(); a0set=true;
add_source_message(1, /* syntax error, see Error.rml */
"SYNTAX",
"ERROR",
"Syntax error near: %s",
tokens,
lex.getLine(),
lex.getColumn(),
lex.getLine(),
lex.getColumn(),
false,
"");
rmlA1 = mk_scon("Error"); a1set=true;
// std::cerr << "Lexical error (CharStreamException). " << std::endl;
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon("[-,-]: internal error: lexical error"); a1set=true;
}
catch (ANTLR_USE_NAMESPACE(antlr)TokenStreamException &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string("illegal token"));
add_source_message(2, /* Grammar error, see Error.rml */
"GRAMMAR",
"ERROR",
"Parse error: %s",
tokens,
0,
0,
0,
0,
false,
"");
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon("Error"); a1set=true;
{
stringStream << "[" << lex.getLine() << ":" << lex.getColumn()
<< "]: error: illegal token" << std::endl;
// std::cerr << stringStream.str().c_str();
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon((getStringHolder = get_string(stringStream))); a1set=true;
}
catch (ANTLR_USE_NAMESPACE(antlr)ANTLRException &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string("while parsing"));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");

rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon("Error"); a1set=true;
// std::cerr << "ANTLRException: " << e.getMessage() << std::endl;
stringStream << "[-,-]: internal error: " << e.getMessage() << std::endl;
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon((getStringHolder = get_string(stringStream))); a1set=true;
}
catch (std::exception &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string("while parsing"));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon("Error"); a1set=true;
// std::cerr << "Error while parsing: " << e.what() << "\n";
stringStream << "[-,-]: internal error: " << e.what() << std::endl;
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon((getStringHolder = get_string(stringStream))); a1set=true;
}
catch (...)
{
std::list<std::string> tokens;
tokens.push_back(std::string("while parsing"));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");

rmlA1 = mk_scon("Error"); a1set=true;
// std::cerr << "Error while parsing\n";
rmlA0 = mk_nil(); a0set=true;
rmlA1 = mk_scon("[-,-]: internal error"); a1set=true;
}

/* adrpo added 2004-10-27
* no need for getStringHolder temp value allocated from get_string
*/
if (getStringHolder) delete [] getStringHolder;

if (! a0set)
{
rmlA0 = mk_nil(); a0set=true;
Expand All @@ -579,6 +521,13 @@ extern "C"
* ast is initialized */
void* ast = mk_nil();


/* adrpo added 2004-10-27
* I use this to delete [] the temp allocation of get_string(...)
*/
char* getStringHolder = NULL;


try
{
std::istringstream stream(str);
Expand Down Expand Up @@ -623,60 +572,31 @@ extern "C"
}
catch (ANTLR_USE_NAMESPACE(antlr)ANTLRException &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string("while parsing:")+
std::string(e.getMessage()));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");
//std::cerr << "Error while parsing expression:\n" << e.getMessage() << "\n";
stringStream << "[-,-]: internal error: " << e.getMessage() << std::endl;
rmlA0 = mk_nil();
rmlA1 = mk_scon("Error");
rmlA1 = mk_scon((getStringHolder = get_string(stringStream)));
}
catch (std::exception &e)
{
std::list<std::string> tokens;
tokens.push_back(std::string(e.what()));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");
//std::cerr << "Error while parsing expression:\n" << e.what() << "\n";
stringStream << "[-,-]: internal error: " << e.what() << std::endl;
rmlA0 = mk_nil();
rmlA1 = mk_scon("Error");
rmlA1 = mk_scon((getStringHolder = get_string(stringStream)));
}
catch (...)
{
std::list<std::string> tokens;
tokens.push_back(std::string("while parsing:"));
add_source_message(63, /* Internal error, see Error.rml */
"TRANSLATION",
"ERROR",
"Internal error %s",
tokens,
0,
0,
0,
0,
false,
"");

rmlA0 = mk_nil();
rmlA1 = mk_scon("Error");
}
//std::cerr << "Error while parsing expression\n";
stringStream << "Error while parsing expression. Unknown exception in parse.cpp." << std::endl;
rmlA0 = mk_nil();
rmlA1 = mk_scon((getStringHolder = get_string(stringStream)));
}

/* adrpo added 2004-10-27
* no need for getStringHolder temp value allocated from get_string
*/
if (getStringHolder) delete [] getStringHolder;


RML_TAILCALLK(rmlSC);
}
Expand Down

0 comments on commit 82f11e2

Please sign in to comment.