]> www.ginac.de Git - ginac.git/blobdiff - ginac/parser/parser.cpp
Fixed dirty hack in parser to distinguish between serial numbers and pointers.
[ginac.git] / ginac / parser / parser.cpp
index 2bc218218e5ab3a07e227e96a3daeb07afe3553c..d639bfe1465f1f693c627c3ec03c7ddf610f7403 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's parser. */
 
 /*
- *  GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -24,8 +24,8 @@
 #include "lexer.h"
 #include "debug.h"
 #include "mul.h"
-#include "function.h"
 #include "constant.h"
+#include "function.h"
 
 #include <sstream>
 #include <stdexcept>
@@ -66,8 +66,16 @@ ex parser::parse_identifier_expr()
                Parse_error_("no function \"" << name << "\" with " <<
                             args.size() << " arguments");
        }
-       ex ret = function(reader->second, args);
-       return ret;
+       // dirty hack to distinguish between serial numbers of functions and real
+       // pointers.
+       try {
+               GiNaC::function f(reinterpret_cast<unsigned>(reader->second), args);
+               return f;
+       }
+       catch ( std::runtime_error ) {
+               ex ret = reader->second(args);
+               return ret;
+       }
 }
 
 /// paren_expr:  '(' expression ')'