beltoforion / muparser Goto Github PK
View Code? Open in Web Editor NEWmuparser is a fast math parser library for C/C++ with (optional) OpenMP support.
Home Page: http://beltoforion.de/en/muparser
License: BSD 2-Clause "Simplified" License
muparser is a fast math parser library for C/C++ with (optional) OpenMP support.
Home Page: http://beltoforion.de/en/muparser
License: BSD 2-Clause "Simplified" License
I see that in the source code operator %
(mod) seems to be available, but not in the documentation http://muparser.beltoforion.de/mup_features.html . Indeed, I am getting a invalid parser state when I use %
.
Do you plan to include %
in future release?
What steps will reproduce the problem?
1.`export PATH=$PATH:$MY_ANDROID_STANDALONE_TOOLCHAIN/bin`
2.`./configure --disable-samples
--prefix=$MY_ANDROID_STANDALONE_TOOLCHAIN/sysroot --host=arm-linux-androideabi`
What is the expected output? What do you see instead?
compile everything without any error but it outputs
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `arm-linux-androideabi':
system `androideabi' not recognized
configure: error: /bin/sh build/autoconf/config.sub arm-linux-androideabi
What version of the product are you using? On what operating system?
Linux localhost.localdomain 3.13.11-100.fc19.x86_64 #1 SMP Wed Apr 23 20:10:57
UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Please provide any additional information below.
SEE:
http://stackoverflow.com/questions/4594736/configure-does-not-recognize-androide
abi
GET: https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
NOTE: Android dont support versioned libraries. this did the trick:
Makefile.in 263:
`@COND_SHARED_1@ $(SHARED_LD_CXX) $@ $(MUPARSER_DLL_OBJECTS)
$(__muParser_dll___macinstnamecmd) $(__muParser_dll___importlib)
$(__muParser_dll___macver) $(LDFLAGS) $(LIBS)`
removed the `$(__muParser_dll___soname_flags)`
perform a conditional check to remove this if compiling for Android.
Alternate solution:
use Android NDK. afaik better and easier (for everyone).
Original issue reported on code.google.com by [email protected]
on 13 Aug 2014 at 11:27
The error handler muErrorHandler_t should have a void* context
arg to help handling errors more easily
Incorrect string assignment, causing 1+2+3 to be parsed as "1", "+", and "2+3".
Though the RPN part fix this and calculates the correct output.
In
bool ParserTokenReader::IsValTok(token_type &a_Tok)
the line
strTok.assign(m_strFormula.c_str(), iStart, m_iPos);
should be
strTok.assign(m_strFormula.c_str(), iStart, m_iPos-iStart);
.
The string assign function uses count, not a second position:
_Myt& assign(const _Myt& _Right,
size_type _Roff, size_type _Count)
Original issue reported on code.google.com by [email protected]
on 25 Nov 2013 at 9:37
Weird time results when compiling with clang v6 and gcc 7+:
Expression 41 of 440: "((cos(cos(tan(pi)))+a)/a)"; Progress: #####
[01] ExprTk ( 8.000 ns, 1.491183914425581625, 13.683879358191861186)
[02] ExprTkFloat ( 9.000 ns, 1.491183876991271973, 13.683879375457763672)
[03] FParser 4.5 ( 15.900 ns, 1.491183914425581625, 13.683879358191861186)
[04] muparser 2.2.4 (36478.800 ns, 1.491183914425581625, 13.683879358191861186)
[05] muparser 2.2.4 (omp) (38305.600 ns, 1.491183914425581625, 13.683879358191861186)
CPU details:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 20
On-line CPU(s) list: 0-19
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) W-2155 CPU @ 3.30GHz
Stepping: 4
CPU MHz: 1869.970
CPU max MHz: 4500.0000
CPU min MHz: 1200.0000
BogoMIPS: 6600.00
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 14080K
NUMA node0 CPU(s): 0-19
sample code:
p.DefineVar("b", &fVal);
p.DefineFun("MySqr", MySqr);
p.SetExpr("MySqr(a)*_pi+min(10,a)");
logcat:
06-19 15:09:44.960 2640-2640/com.autonavi.minimap.ajx3 A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 2640 (vi.minimap.ajx3)
06-19 15:09:45.063 289-289/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-19 15:09:45.063 289-289/? A/DEBUG: Build fingerprint: 'Xiaomi/cancro_wc_lte/cancro:6.0.1/MMB29M/7.5.25:user/release-keys'
06-19 15:09:45.063 289-289/? A/DEBUG: Revision: '0'
06-19 15:09:45.063 289-289/? A/DEBUG: ABI: 'arm'
06-19 15:09:45.064 289-289/? A/DEBUG: pid: 2640, tid: 2640, name: vi.minimap.ajx3 >>> com.autonavi.minimap.ajx3 <<<
06-19 15:09:45.064 289-289/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
06-19 15:09:45.087 289-289/? A/DEBUG: r0 00000000 r1 00000a50 r2 00000006 r3 b6f0cb7c
06-19 15:09:45.088 289-289/? A/DEBUG: r4 b6f0cb84 r5 b6f0cb34 r6 00000002 r7 0000010c
06-19 15:09:45.088 289-289/? A/DEBUG: r8 be93d1f4 r9 be93d1cc sl 00000001 fp be93d1f8
06-19 15:09:45.088 289-289/? A/DEBUG: ip 00000006 sp be93d170 lr b6c68c69 pc b6c6b058 cpsr 400b0010
06-19 15:09:45.102 289-289/? A/DEBUG: backtrace:
06-19 15:09:45.103 289-289/? A/DEBUG: #00 pc 00042058 /system/lib/libc.so (tgkill+12)
06-19 15:09:45.104 289-289/? A/DEBUG: #01 pc 0003fc65 /system/lib/libc.so (pthread_kill+32)
06-19 15:09:45.104 289-289/? A/DEBUG: #02 pc 0001c403 /system/lib/libc.so (raise+10)
06-19 15:09:45.104 289-289/? A/DEBUG: #03 pc 000195b5 /system/lib/libc.so (__libc_android_abort+34)
06-19 15:09:45.105 289-289/? A/DEBUG: #04 pc 00017508 /system/lib/libc.so (abort+4)
06-19 15:09:45.105 289-289/? A/DEBUG: #05 pc 005bd8d7 /data/app/com.autonavi.minimap.ajx3-2/lib/arm/libajx_v3.so
06-19 15:09:45.105 289-289/? A/DEBUG: #06 pc 005bd949 /data/app/com.autonavi.minimap.ajx3-2/lib/arm/libajx_v3.so (_Unwind_Resume+24)
06-19 15:09:45.105 289-289/? A/DEBUG: #07 pc 0059e611 /data/app/com.autonavi.minimap.ajx3-2/lib/arm/libajx_v3.so
unwind_phase2(unw_context_t*, _Unwind_Control_Block*, bool)
/Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libunwind_llvm/src/Unwind-EHABI.cpp:685
_Unwind_Resume
/Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libunwind_llvm/src/Unwind-EHABI.cpp:750
__cxa_end_cleanup
Please review the attached patch, it removes a redundant else if()-branch in
example1.cpp. The same branch is already defined a few lines above.
Many thanks for looking at this patch and best regards
Martin Ettl
Original issue reported on code.google.com by [email protected]
on 17 Apr 2015 at 12:29
Attachments:
I tried compiling the library using floats instead of doubles. I changed the corresponding line inside muParserDef.h to #define MUP_BASETYPE float
but there were some compilation errors related to muParserDLL.h
To fix those, I also had to to change line 50 of muParserDLL.h to be
typedef float muFloat_t
I might have missed something while reading library documentation, but if the user is expected to make this little extra change maybe we could write something inside the Compiler switches web page, in the MUP_BASETYPE section.
Originally the configure script assumed that if the compiler was gcc and the system was darwin, then it would be Apple's gcc and the -no-cpp-precomp
flag was used. This assumption is no longer true - other versions of gcc are used on darwin now, to get more modern compilers - but these FSF gcc versions error on the -no-cpp-precomp
flag.
See https://gcc.gnu.org/ml/gcc/2005-12/msg00367.html.
I think the darwin test in the gcc block could be deleted, as the -no-cpp-precomp
flag does not appear to do anything since gcc3.x according to the link. I changed the block in the configure script to:
DEPS_TRACKING=1
if test "x$GCC" = "xyes"; then
DEPSMODE=gcc
DEPSFLAG="-MMD"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: gcc" >&5
$as_echo "gcc" >&6; }
and it no longer causes errors when compiled with newer non-Apple gcc versions.
void Error(EErrorCodes a_iErrc,
int a_iPos = (int)mu::string_type::npos, // <--- This line doesn't look safe
const string_type &a_strTok = string_type() ) const;
std::string::npos
is size_type
, it's a 64-bit value in 64-bit mode. The highlighted line truncates it to 32-bit signed int
. It's probably not causing any actual runtime errors, but looks bad and causes a host of compiler warnings (remember, it's in .h file so a warning is emitted for every .cpp that includes it).
Hello,
we are using muparser happily for many years in our academic software.
I was not the one who integrated muparser (that guy is no longer available), but I used it. Now I updated to the newest version to make benefit from the cmake features. With 2.2.6.1 I get the regression that two of our callbacks are not compiling any more:
'double ()(const char, double, double, double)'
and
'double ()(const char, double, double, double, double)'
A 'double ()(const char, double, double)' compiles via
muParser.h: typedef value_type (strfun_type3)(const char_type, value_type, value_type);
So I think, there is just an implementation for strfun_type4 and strfun_type5 missing.
Might it be, that this once existed or is there another way to implement it?
If muparser needs to be extended, I assume this is a quick thing for an expert but would be rather involved for me to extend muparser.
Is there another option (e.g. a hero) who can help me? Otherwise I would try it by myself and either attempt to officially patch muparser or patch it always on our side.
I don't know about the development community so I better ask.
Thanks!
Suppose i have a composed expression a=10 , b=20 + c , d = 30, e= 40 where the 2nd expression(b=20 +c) is erroneous. In this case, muParser will correctly throw exception and not evaluate 3rd and 4th expression. But i dont want to throw exception in the middle and want that the 3rd and 4th expression gets calculated.
How can i achieve this ?
Hi,
I am using the library on Ubuntu-subsystem on Windows 10.
I have g++ 5.4.0.
After "./configure", and when doing a "make" i get the error:
/include/muParserToken.h:72:12: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
After checking, the compile command, it seems missing "-std=c++11".
After adding it manually to the Makefile, the library compiles smoothly !
Regards,
The unit tests in example1 should have a non-interactive mode, otherwise the CI is blocking.
Would it be possible to add a check function that would raise up basic syntax errors without trying to evaluate the whole expression ? This would be helpful to detect basic problems without having to set up the whole context (variable could have any value, or even not being declared, as long as the tokens are at least well formed)
compilation fails with visual studio because std::isgraph is not found, because the cctype include is missing:
https://en.cppreference.com/w/cpp/string/byte/isgraph
v2.2.5 provides these libs:
/usr/lib64/libmuparser.so
/usr/lib64/libmuparser.so.2
/usr/lib64/libmuparser.so.2.2.4 (shold be 2.2.5 instead?!?)
/usr/lib64/pkgconfig/muparser.pc
v2.2.3 provides these libs:
/usr/lib64/libmuparser.so
/usr/lib64/libmuparser.so.2
/usr/lib64/libmuparser.so.2.2.3
/usr/lib64/pkgconfig/muparser.pc
Greetings muparser developers and contributors,
We’re reaching out because your project is an important part of the open source ecosystem, and we’d like to invite you to integrate with our fuzzing service, OSS-Fuzz. OSS-Fuzz is a free fuzzing infrastructure you can use to identify security vulnerabilities and stability bugs in your project. OSS-Fuzz will:
Many widely used open source projects like OpenSSL, FFmpeg, LibreOffice, and ImageMagick are fuzzing via OSS-Fuzz, which helps them find and remediate critical issues.
Even though typical integrations can be done in < 100 LoC, we have a reward program in place which aims to recognize folks who are not just contributing to open source, but are also working hard to make it more secure.
We want to stress that anyone who meets the eligibility criteria and integrates a project with OSS-Fuzz is eligible for a reward.
To help you getting started, we can attach our internal fuzzer for your project that you are welcome to use directly, or to use it as a starting point.
If you're not interested in integrating with OSS-Fuzz, it would be helpful for us to understand why—lack of interest, lack of time, or something else—so we can better support projects like yours in the future.
If we’ve missed your question in our FAQ, feel free to reply or reach out to us at [email protected].
Thanks!
Tommy
OSS-Fuzz Team
std::auto_ptr
is deprecated and removed in C++17.
fix problems with non set thousands separator on macos
Original issue reported on code.google.com by [email protected]
on 29 Apr 2014 at 7:30
Attachments:
Hi, there are some warnings during compilation with gcc6.2.1, please review when possible.
[filiperosset@rosset-laptop muParser]$ fedpkg local
Executando (%prep): /bin/sh -e /var/tmp/rpm-tmp.JZ1nfm
Configuration for muparser 2.2.4 successfully completed.
Summary of main configuration settings for muparser:
./src/muParserTest.cpp:1388:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4127)
./src/muParserTest.cpp:1390:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(pop)
In file included from ./include/muParserStack.h:35:0,
from ./include/muParserBase.h:39,
from ./include/muParser.h:32,
from ./include/muParserTest.h:32,
from ./src/muParserTest.cpp:26:
./include/muParserToken.h:72:12: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr m_pCallback;
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserBase.h:33,
from ./include/muParser.h:32,
from ./include/muParserTest.h:32,
from ./src/muParserTest.cpp:26:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
In file included from ./include/muParser.h:32:0,
from ./include/muParserTest.h:32,
from ./src/muParserTest.cpp:26:
./include/muParserBase.h:291:10: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserBase.h:33,
from ./include/muParser.h:32,
from ./include/muParserTest.h:32,
from ./src/muParserTest.cpp:26:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
./src/muParserTest.cpp: In member function 'int mu::Test::ParserTester::EqnTest(const string_type&, double, bool)':
./src/muParserTest.cpp:1261:14: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr p1;
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserBase.h:33,
from ./include/muParser.h:32,
from ./include/muParserTest.h:32,
from ./src/muParserTest.cpp:26:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
In file included from ./include/muParserStack.h:35:0,
from ./include/muParserBase.h:39,
from ./include/muParserInt.h:29,
from ./src/muParserInt.cpp:26:
./include/muParserToken.h:72:12: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr m_pCallback;
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserBase.h:33,
from ./include/muParserInt.h:29,
from ./src/muParserInt.cpp:26:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
In file included from ./include/muParserInt.h:29:0,
from ./src/muParserInt.cpp:26:
./include/muParserBase.h:291:10: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserBase.h:33,
from ./include/muParserInt.h:29,
from ./src/muParserInt.cpp:26:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
In file included from ./include/muParserTokenReader.h:39:0,
from ./src/muParserTokenReader.cpp:32:
./include/muParserToken.h:72:12: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr m_pCallback;
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserTokenReader.h:34,
from ./src/muParserTokenReader.cpp:32:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
In file included from ./src/muParserTokenReader.cpp:33:0:
./include/muParserBase.h:291:10: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserTokenReader.h:34,
from ./src/muParserTokenReader.cpp:32:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
./src/muParserTokenReader.cpp: In member function 'mu::ParserTokenReader* mu::ParserTokenReader::Clone(mu::ParserBase*) const':
./src/muParserTokenReader.cpp:150:10: warning: 'template class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr ptr(new ParserTokenReader(*this));
^~~~~~~~
In file included from /usr/include/c++/6.2.1/memory:81:0,
from ./include/muParserTokenReader.h:34,
from ./src/muParserTokenReader.cpp:32:
/usr/include/c++/6.2.1/bits/unique_ptr.h:49:28: note: declared here
template class auto_ptr;
^~~~~~~~
g++ -shared -fPIC -o lib/libmuparser.so.2.2.4 muParser_dll_muParser.o muParser_dll_muParserBase.o muParser_dll_muParserBytecode.o muParser_dll_muParserCallback.o muParser_dll_muParserDLL.o muParser_dll_muParserError.o muParser_dll_muParserInt.o muParser_dll_muParserTest.o muParser_dll_muParserTokenReader.o -Wl,-soname,libmuparser.so.2 -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
(cd ./lib/; rm -f libmuparser.so libmuparser.so.2; ln -s libmuparser.so.2.2.4 libmuparser.so.2; ln -s libmuparser.so.2 libmuparser.so)
dirname $f
; then dirname $f
; Are you calulating with floats internally? It would be cool to have a eval function that evaluates "0.8*0.8" to "0.64" instead of the float 0,6400000000000001.
Let's have an expression 'max(0/0,1)' and mathematically equal
expression 'max(1,0/0)'. I expect (why shouldn't I ?) to get the same results.
However, muParser calculates
max(0/0,1) = -nan(ind)
max(1,0/0) = 1
max(1,0/0,1) = 1
Verified using the latest commit from Jan 23 2018 (6cf2746)
and an older version 2.2.4 (more than 2yrs old).
Is there a bug or my expectations are incorrect?
Thanks in advance,
Marcel
Export C++ symbols for Windows using macro. This is done adding MUPARSERLIB_EXPORTS
to every classes that belongs to the API.
There seems to be _pi and _e defined. Where can I find other constants?
As discussed in geodynamics/aspect#2540, it turns out that muparser evaluates both branches of an if
statement, even if only one is needed. This may not be optimal performancewise, but more importantly it leads to trouble if one has floating point exceptions switched on: in that case, the evaluation of the inactive branch can lead to a floating point exception even though the result of that evaluation is not actually used.
Dear developer,
If I define "k" as postfix (*1e3), and parsing this kind of equation.
"a+k+3k" --> it will be error ParserTokenReader::IsVarTok
I found this is cause by 'noVal' flag and can be fixed by change the order of IsPostFix to the presence of isVarTok.
How do you think??
Hello,
Here's a CMake file that allows to build muparser with cmake in a
cross-platform manner.
Basically removes the need for specific build systems on each platforms (almost
everything in /build): configure, bakefiles (build/bakefiles), mingw specific
makefile (makefile.mingw), and msvc projects
(./build/msvc2013/muparser*.vcxproj)
Usage:
cd [path to muParser]
cmake [-DBUILD_SHARED_LIBS=ON/OFF] [-DBUILD_SAMPLES=ON/PFF]
[-DCMAKE_BUILD_TYPE=Release/Debug]
make
[sudo*] make install
Also builds tarballs muparser-2.2.4.zip|tar.gz:
make package_source
Has in it almost all that is needed to solve #3. We should then create a
muParserDef.h.in file to be configured with the conditional definition of
MUP_USE_OPENMP. Then cmake can take advantage of arguments
[-DUSE_OPENMP=ON/OFF]. See comments inside.
Tested on linux, mingw-w64, should build on msvc too.
Would you consider this as a build-system replacement ?
Original issue reported on code.google.com by [email protected]
on 25 Feb 2015 at 4:50
Attachments:
Hello,
As described in http://beltoforion.de/article.php?a=muparser&hl=en&p=features&s=idDef2#idDef2, built-in function log() returns logarithm to the base 10.
When running example1, log() returns natural logarithm:
Version 2.2.5 (20150427; GC; 64BIT; RELEASE; ASCII)
(C) 2015 Ingo Berg
Running test suite:
testing name restriction enforcement...passed
testing syntax engine...passed
testing postfix operators...passed
testing infix operators...passed
testing variable/constant detection...passed
testing multiarg functions...passed
testing expression samples...passed
testing if-then-else operator...passed
testing member functions...passed
testing binary operators...passed
testing error codes...passed
testing string arguments...passed
testing bulkmode...passedTest passed (542 expressions)
Commands:
list var - list parser variables
list exprvar - list expression variables
list const - list all numeric parser constants
opt on - enable optimizer (default)
opt off - disable optimizer
locale de - switch to german locale
locale en - switch to english locale
locale reset - reset locale
test bulk - test bulk mode
quit - exits the parserConstants:
"_e" 2.718281828459045235360287
"_pi" 3.141592653589793238462643
Enter an expression or a command:
log(10)
ans=2.30258509299
ln(10)
ans=2.30258509299
log10(10)
ans=1
^C
G++ version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu114.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu14.04.3)
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1
Best regards,
Wanup0
I noticed that weak_ptr/unique_ptr
are used ParserTokenReader::Clone(ParserBase *a_pParent) const
. Does it mean the compiler has to support c++11
or c++0x
etc to compile the library.
Is yes, which version can be used with a compiler which only has c++98
support? We wish to support CentOS-5
in our application, which has only gcc4.1 by default (I know its pretty old).
Probably a good idea to mention it in the documentation.
I pulled v 2.2.6.1 and tried to build the 'debug static' and 'release static' versions.
Two problems with the MSVC 'muparser.sln' configurations:
The 'Code Generation | Smaller Type Check' property is Yes, which causes the '/RTCc' option to be used on the compiler. This inhibits the muparser build. Lots of '/RTCc rejects conformant code' errors.
The 'MUPARSER_STATIC' preprocessor directive is missing which causes lots of 'dll-specification' errors - again, when compiling the 'static' configurations. Needed to add this preprocessor directive to those build configurations.
This repo links to http://muparser.beltoforion.de, but that website is offline.
beltoforion.de specifies the following nameservers:
docks19.rzone.de
shades17.rzone.de
…but those nameservers return neither an A
nor CNAME
record for the muparser.beltoforion.de domain.
Is the domain permanently offline (and should the links thus be changed), or is this a temporary issue?
Because of a somewhat confusing usage of "infix" to mean "prefix" in muParser,
the author of ParserTokenReader::ExtractOperatorToken validates the input
characters for binary operators against ValidInfixOprtChars(), whereas it
should be validated against ValidOprtChars().
Attached is a patch for the problem.
What steps will reproduce the problem?
1. Add an extra operator char, eg ";"
m_parser.DefineOprtChars(
// standard operator chars as defined in mu::Parser::InitCharSets()
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"+-*^/?<>=#!$%&|~'_"
// our additions
";");
2.
Add the extra binary operator
m_parser.DefineOprt(";", statementSeparator, -2);
3.
Add some suitable expression
m_parser.SetExpr("12.0 ; 13.0");
4. Call m_parser.Eval();
This will throw with an unexpected token exception.
What version of the product are you using? On what operating system?
2.2.3 compiled on OpenSUSE 12.2
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 28 Sep 2014 at 6:37
Attachments:
Please review the attached patch. It fixes a bunch of typos in C++-comments.
There are no functional changes.
Best regards
Martin Ettl
Original issue reported on code.google.com by [email protected]
on 17 Apr 2015 at 1:03
Attachments:
What steps will reproduce the problem?
1. Set a mu::Parser's expression to one of the following:
1000*Part_0
1000.2*Part_0
0000.2*Part_0
2. Call mu::Parser::GetUsedVar()
3. 1000, 1000, and 0000 will be returned as variables for the cases listed
above.
What is the expected output? What do you see instead?
I only expect to see Part_0 as a used variable.
-For the first case, muParser does not throw an exception, but it does say that
1000 is a variable. I should say that it is a value.
-For the second case (1000.2*Part_0): I get the exception message: "Unexpected
token ".2*Part_0*Part_1 " found at position 4."
-For the last case (000.2*Part_0): I get the exception message "Unexpected
token ".2*Part_0*Part_1 " found at position 4."
muParser parses the expressions correctlywhen I use 999 and 999.2 in the
expressions (instead of 1000 and 1000.2).
What version of the product are you using? On what operating system?
muParser 2.2.3. I tried this with 2.2.4 taken from the svn repo and it also
occurred. I'm on OSX version 10.7.5, and I am building muParser with the
provided configure and make scripts. For my code, I'm compiling it with Apple
LLVM 4.2 with C++11 support and linking to the libc++ std lib. I compiled
muParser so that it also uses the same compiler settings as my code.
Please provide any additional information below.
I set some breakpoints in the muParser code to try and track it down. I tried
to figure it out myself, but it's taking me a long time. Here's what I've got
so far, and hopefully someone who knows the code better can take it from here:
In ParserBase::CreateRPN(), the line of code on line 1199:
opt = m_pTokenReader->ReadNextToken();
It returns an opt with the following state:
(mu::ParserBase::token_type) opt = {
m_iCode = cmVAR
m_iType = tpDBL
m_pTok = 0x0000000100c038b8
m_iIdx = -1
m_strTok = "1000"
m_strVal = ""
m_fVal = 6.95322297490987e-310
m_pCallback = {
__ptr_ = 0x0000000000000000
}
}
I believe that m_iCode should NOT be set to cmVAR, and should instead be set to
cmVAL. I tried to dig deeper, but I didn't get very far.
Thanks for looking at this.
Original issue reported on code.google.com by [email protected]
on 22 Aug 2013 at 11:40
In ParserBase::SetExpr
, we see the code:
// Check locale compatibility
std::locale loc;
if (m_pTokenReader->GetArgSep()==std::use_facet<numpunct<char_type> >(loc).decimal_point())
Error(ecLOCALE);
However, ParserBase
also has static member s_locale
defined as follows:
static std::locale s_locale; ///< The locale used by the parser
We can manipulate s_locale
with SetThousandsSep
and SetDecSep
. However, when we go to validate our settings, we validate a new std::locale
instead of s_locale
. Shouldn't the validation code look more like this? (I've substituted "s_locale" for "loc")
// Check locale compatibility
if (m_pTokenReader->GetArgSep()==std::use_facet<numpunct<char_type> >(s_locale).decimal_point())
Error(ecLOCALE);
Running nmake with VS140 toolset produces the file example2.exe, which works.
Running msbuild with VS140 toolset to build vcxproj (which is produced by VS120 toolset produces the file example2.exe, which crashes when user inputs something like "list var".
What steps will reproduce the problem?
1. read the documentation of DefineFun, DefineOprt, DefineInfixOprt and
DefinePostfixOprt function
2.
3.
What is the expected output? What do you see instead?
I expect this function to receive either a member function as a callback or a
function with one more parameter/pointer to the user data
What version of the product are you using? On what operating system?
Ubuntu
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 6 Aug 2015 at 6:36
I have compiled the latest build to a lib.
I am checking mem leaks in my code via:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
_CrtDumpMemoryLeaks();
And comes up lots of unallocated blocks:
Data: Too many paramet 54 6F 6F 20 6D 61 6E 79 20 70 61 72 61 6D 65 74
{200} normal block at 0x0000017BA829D210, 32 bytes long.
Data: Missing parenthe 4D 69 73 73 69 6E 67 20 70 61 72 65 6E 74 68 65
{199} normal block at 0x0000017BA829D160, 64 bytes long.
Data: Function argumen 46 75 6E 63 74 69 6F 6E 20 61 72 67 75 6D 65 6E
{198} normal block at 0x0000017BA829D0B0, 64 bytes long.
Data: Unexpected varia 55 6E 65 78 70 65 63 74 65 64 20 76 61 72 69 61
These are all strings allocated by MuParser (error strings).
My code is:
#include "muParser.h"
int Eval() {
using namespace mu;
std::string sstr = "1 == 1";
int e = 0;
Parser p;
p.SetExpr((char *)sstr.c_str());
try {
e = p.Eval();
}
catch (mu::Parser::exception_type &e)
{
OutputDebugString(e.GetMsg().c_str());
}
return e;
}
and in the main routine, I am calling Eval()
Any clues?
Thanks
The .travis-ci.yml is part of the directory and is working correctly: https://travis-ci.org/giraldeau/muparser
Let's enable that for the upstream project to ensure we don't break anything when merging stuff.
According the C++ specification, the const
word, already reserved is C, is a reserved word.
Yet, the source code uses const string_type& GetMsg() const;
in include/muParserError.h
.
Reference
Inheriting from std::exception is very helpful, as it helps in getting the operating system to read the error message if the exception is not caught. I see that you have a message part of the exception, and an error code, etc. How about you inherit from std::exception, and then override that what()
to return something like: "Error [code]: [error message]"?
Is there a particular reason why muparser exceptions are not inherited from std::exception in muparser?
auto_ptr should be replaced with unique_ptr;
Can we make these changes
--- include/muParserBase.h.orig 2018-09-05 20:00:43 UTC
+++ include/muParserBase.h
@@ -288,7 +288,7 @@ friend class ParserTokenReader; (private)
mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments
stringbuf_type m_vStringVarBuf;
- std::auto_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
+ std::unique_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
funmap_type m_FunDef; ///< Map of function names and pointers.
funmap_type m_PostOprtDef; ///< Postfix operator callbacks
--- include/muParserToken.h.orig 2018-09-05 20:01:07 UTC
+++ include/muParserToken.h
@@ -69,7 +69,7 @@ namespace mu
TString m_strTok; ///< Token string
TString m_strVal; ///< Value for string variables
value_type m_fVal; ///< the value
- std::auto_ptr<ParserCallback> m_pCallback;
+ std::unique_ptr<ParserCallback> m_pCallback;
public:
--- src/muParserTest.cpp.orig 2018-09-05 20:00:19 UTC
+++ src/muParserTest.cpp
@@ -1258,7 +1258,7 @@ namespace mu
try
{
- std::auto_ptr<Parser> p1;
+ std::unique_ptr<Parser> p1;
Parser p2, p3; // three parser objects
// they will be used for testing copy and assignment operators
// p1 is a pointer since i'm going to delete it in order to test if
--- src/muParserTokenReader.cpp.orig 2018-09-05 19:59:55 UTC
+++ src/muParserTokenReader.cpp
@@ -147,7 +147,7 @@ namespace mu
*/
ParserTokenReader* ParserTokenReader::Clone(ParserBase *a_pParent) const
{
- std::auto_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this));
+ std::unique_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this));
ptr->SetParent(a_pParent);
return ptr.release();
}
In one of the examples, mu::Parser::valmap_type is used, however, in the current version this type if found via mu::valmap_type.
Hello,
OpenTURNS, an open-source lib dedicated to the treatment of uncertainties, use
MuParser for some study. By the way, thanks for your work!
So, for some large study we would like to speed up a little bit the
computation. So we would like to enable OpenMP inside muParser.
We know that using a just in time parser would be much faster, but it would
involve much more work. OpenMP in muParser is the first easy step to speed up
our code.
I tried to enable OpenMP support on Linux (using autoconf).
But using the revision 10 of http://muparser.googlecode.com/svn/trunk source,
if I uncomment the line "#define MUP_USE_OPENMP" it does not enable OpenMP
compilation switch and the compilation fails.
I made a patch and the compilation using autoconf runs fine now.
The patch add an --enable-openmp feature (openmp is disabled by default).
./configure --enable-openmp
make
...
My system is running on ubuntu 12.04 64bits.
Do you think the patch is good enough? I do not know if it will break
compilation on other systems (windows ...) as I know only autoconf and cmake.
Could you consider merging this patch to muParser source code?
Beset regards,
Mathieu Souchaud
Original issue reported on code.google.com by [email protected]
on 21 Dec 2013 at 5:41
Attachments:
jony@jony-unbroken:~/3rd_party_lib/muparser$ make
/home/jony/3rd_party_lib/muparser/bk-deps g++ -c -o muParser_dll_muParser.o -DNDEBUG -DMUPARSER_DLL -DMUPARSERLIB_EXPORTS -I./include -fPIC -DPIC -O2 ./src/muParser.cpp
In file included from ./include/muParserStack.h:34:0,
from ./include/muParserBase.h:39,
from ./include/muParser.h:32,
from ./src/muParser.cpp:26:
./include/muParserError.h:110:57: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
ParserErrorMsg& operator=(const ParserErrorMsg &) = delete;
^
./include/muParserError.h:111:45: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
ParserErrorMsg(const ParserErrorMsg&) = delete;
^
./include/muParserError.h:114:24: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
~ParserErrorMsg() = default;
^
In file included from ./include/muParserStack.h:35:0,
from ./include/muParserBase.h:39,
from ./include/muParser.h:32,
from ./src/muParser.cpp:26:
./include/muParserToken.h:72:12: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
std::unique_ptr m_pCallback;
^
./include/muParserToken.h: In constructor ‘mu::ParserToken<TBase, TString>::ParserToken()’:
./include/muParserToken.h:91:10: error: class ‘mu::ParserToken<TBase, TString>’ does not have any field named ‘m_pCallback’
,m_pCallback()
^
./include/muParserToken.h: In member function ‘void mu::ParserToken<TBase, TString>::Assign(const mu::ParserToken<TBase, TString>&)’:
./include/muParserToken.h:135:9: error: ‘m_pCallback’ was not declared in this scope
m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone()
^
./include/muParserToken.h: In member function ‘mu::ParserToken<TBase, TString>& mu::ParserToken<TBase, TString>::Set(const mu::ParserCallback&, const TString&)’:
./include/muParserToken.h:174:9: error: ‘m_pCallback’ was not declared in this scope
m_pCallback.reset(new ParserCallback(a_pCallback));
^
./include/muParserToken.h: In member function ‘mu::ParserToken<TBase, TString>& mu::ParserToken<TBase, TString>::SetVal(TBase, const TString&)’:
./include/muParserToken.h:197:9: error: ‘m_pCallback’ was not declared in this scope
m_pCallback.reset(0);
^
./include/muParserToken.h: In member function ‘mu::ParserToken<TBase, TString>& mu::ParserToken<TBase, TString>::SetVar(TBase*, const TString&)’:
./include/muParserToken.h:215:9: error: ‘m_pCallback’ was not declared in this scope
m_pCallback.reset(0);
^
./include/muParserToken.h: In member function ‘mu::ParserToken<TBase, TString>& mu::ParserToken<TBase, TString>::SetString(const TString&, std::size_t)’:
./include/muParserToken.h:233:9: error: ‘m_pCallback’ was not declared in this scope
m_pCallback.reset(0);
^
./include/muParserToken.h: In member function ‘mu::ECmdCode mu::ParserToken<TBase, TString>::GetCode() const’:
./include/muParserToken.h:276:13: error: ‘m_pCallback’ was not declared in this scope
if (m_pCallback.get())
^
./include/muParserToken.h: In member function ‘mu::ETypeCode mu::ParserToken<TBase, TString>::GetType() const’:
./include/muParserToken.h:289:13: error: ‘m_pCallback’ was not declared in this scope
if (m_pCallback.get())
^
./include/muParserToken.h: In member function ‘int mu::ParserToken<TBase, TString>::GetPri() const’:
./include/muParserToken.h:302:15: error: ‘m_pCallback’ was not declared in this scope
if ( !m_pCallback.get())
^
./include/muParserToken.h:305:14: error: ‘m_pCallback’ was not declared in this scope
if ( m_pCallback->GetCode()!=cmOPRT_BIN && m_pCallback->GetCode()!=cmO
^
./include/muParserToken.h:308:16: error: ‘m_pCallback’ was not declared in this scope
return m_pCallback->GetPri();
^
./include/muParserToken.h: In member function ‘mu::EOprtAssociativity mu::ParserToken<TBase, TString>::GetAssociativity() const’:
./include/muParserToken.h:314:13: error: ‘m_pCallback’ was not declared in this scope
if (m_pCallback.get()==NULL || m_pCallback->GetCode()!=cmOPRT_BIN)
^
./include/muParserToken.h:317:16: error: ‘m_pCallback’ was not declared in this scope
return m_pCallback->GetAssociativity();
^
./include/muParserToken.h: In member function ‘mu::value_type (* mu::ParserToken<TBase, TString>::GetFuncAddr() const)()’:
./include/muParserToken.h:337:17: error: ‘m_pCallback’ was not declared in this scope
return (m_pCallback.get()) ? (generic_fun_type)m_pCallback->GetAddr()
^
./include/muParserToken.h: In member function ‘int mu::ParserToken<TBase, TString>::GetArgCount() const’:
./include/muParserToken.h:379:14: error: ‘m_pCallback’ was not declared in this scope
if (!m_pCallback->GetAddr())
^
./include/muParserToken.h:382:16: error: ‘m_pCallback’ was not declared in this scope
return m_pCallback->GetArgc();
^
In file included from ./include/muParser.h:32:0,
from ./src/muParser.cpp:26:
./include/muParserBase.h: At global scope:
./include/muParserBase.h:291:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
std::unique_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to
^
Makefile:332: recipe for target 'muParser_dll_muParser.o' failed
make: *** [muParser_dll_muParser.o] Error 1
While for constants, the following works:
mu::valmap_type cmap_c = parser.GetConst();
if (cmap_c.size())
{
mu::valmap_type::const_iterator item = cmap_c.begin();
for (; item != cmap_c.end(); ++item)
{
for variables, the iterator cannot be a const_iterator as given in the example, but works with
mu::varmap_type variables = parser.GetVar();
if (variables.size())
{
mu::varmap_type::iterator item = variables.begin();
for (; item != variables.end(); ++item)
{
the code in muParser.cpp
int Parser::IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal)
{
....
....
below one will crash on android(NDK)
stream >> fVal;//stringstream not working right on android plaform
....
}
so I have change as
//return how many string is legal for value,if return 0 this is not a value
inline int Mywtof( const wchar_t* e_str,double_e_pdValue )
int Parser::IsVal(const char_type_ a_szExpr, int *a_iPos, value_type *a_fVal)
{
value_type fVal(0);
int l_iValueLength = Mywtof(a_szExpr,&fVal);
if( l_iValueLength == 0 )
return 0;
*a_iPos += l_iValueLength;
*a_fVal = fVal;
return 1;
}
inline int Mywtof( const wchar_t* e_str,double*e_pdValue )
{
int l_iLegalValueLength = 0;
bool l_bIsValue = true;
bool bMinus = false;
if (*e_str == '+')
{
e_str++;
}
else
if (*e_str == '-')
{
bMinus = true;
e_str++;
}
double l_dbValue = 0.f;
int l_dotStart = -1;
int l_iLength = wcslen(e_str);
for( int i=0;i<l_iLength;++i )
{
if( e_str[i] == L'.' )
{
l_dotStart = i;
}
else
if( e_str[i] >= L'0' && e_str[i] <= L'9' )
{
l_dbValue = (l_dbValue*10) +(e_str[i]-L'0');
}
else
if( e_str[i] == L'e'||e_str[i] == L'E' )
{
int l_ie = e_str[i+2]-L'0';
for( int j=1;j<l_ie;++j )
l_dbValue /= 10;
}
else
{
break;
}
++l_iLegalValueLength;
}
if( l_dotStart != -1 )
{
float l_fDotOffset = 1.f;
for( int j=1;j<l_iLength-l_dotStart;++j )
l_fDotOffset*=10;
l_dbValue/=l_fDotOffset;
}
*e_pdValue = bMinus?-l_dbValue:l_dbValue;
return l_iLegalValueLength;
}
The lines 146, 180, 201 and 221 in ParserError.cpp (ParserError class constructors) are overwriting the message string with the token string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.