iwjd / muparser

Automatically exported from code.google.com/p/muparser
Other
0 stars 0 forks source link

ParserTokenReader::ExtractOperatorToken incorrectly uses ValidInfixOprtChars() #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 highperf...@gmail.com on 28 Sep 2014 at 6:37

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed. But ";" and "," were deilberately left out in the character list anyway. 
The comma already does what you want. 

Original comment by ib...@gmx.info on 2 Oct 2014 at 1:31

GoogleCodeExporter commented 9 years ago

Original comment by ib...@gmx.info on 2 Oct 2014 at 1:31