Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
c698141a
Commit
c698141a
authored
Jul 03, 2013
by
peastman
Browse files
Expression parser tolerates a + in front of an exponent
parent
73f7c14e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
libraries/lepton/src/Parser.cpp
libraries/lepton/src/Parser.cpp
+2
-2
tests/TestParser.cpp
tests/TestParser.cpp
+1
-0
No files found.
libraries/lepton/src/Parser.cpp
View file @
c698141a
...
...
@@ -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-201
1
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
3
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
;
}
...
...
tests/TestParser.cpp
View file @
c698141a
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment