"platforms/reference/vscode:/vscode.git/clone" did not exist on "aa8264d07258f650b55afc49b3dd94d7db3543f4"
Commit 7844aa09 authored by peastman's avatar peastman
Browse files

Merge pull request #38 from peastman/master

Fixed a bug in expression parser
parents 7253aca3 7ba1a10c
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2009-2011 Stanford University and the Authors. *
* Portions copyright (c) 2009-2013 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -112,7 +112,7 @@ ParseToken Parser::getNextToken(const string& expression, int start) {
}
if ((c == 'e' || c == 'E') && !foundExp) {
foundExp = true;
if (pos < (int) expression.size()-1 && expression[pos+1] == '-')
if (pos < (int) expression.size()-1 && (expression[pos+1] == '-' || expression[pos+1] == '+'))
pos++;
continue;
}
......
......@@ -175,6 +175,7 @@ int main() {
verifyEvaluation("5*2", 10.0);
verifyEvaluation("2*3+4*5", 26.0);
verifyEvaluation("2^-3", 0.125);
verifyEvaluation("1e+2", 100.0);
verifyEvaluation("-x", 2.0, 3.0, -2.0);
verifyEvaluation("y^-x", 3.0, 2.0, 0.125);
verifyEvaluation("1/-x", 3.0, 2.0, -1.0/3.0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment