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
8b544e9c
"openmmapi/include/NonbondedForce.h" did not exist on "dfe03fe9089f8d6f1fd6c2a6acae4392e5984f53"
Commit
8b544e9c
authored
Oct 18, 2011
by
Peter Eastman
Browse files
Recognize all whitespace characters in expressions, not just spaces
parent
73369ddd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
libraries/lepton/src/Parser.cpp
libraries/lepton/src/Parser.cpp
+8
-7
No files found.
libraries/lepton/src/Parser.cpp
View file @
8b544e9c
...
...
@@ -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 Stanford University and the Authors.
*
* Portions copyright (c) 2009
-2011
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -35,6 +35,7 @@
#include "lepton/ExpressionTreeNode.h"
#include "lepton/Operation.h"
#include "lepton/ParsedExpression.h"
#include <cctype>
#include <iostream>
using
namespace
Lepton
;
...
...
@@ -67,11 +68,11 @@ string Parser::trim(const string& expression) {
// Remove leading and trailing spaces.
int
start
,
end
;
for
(
start
=
0
;
start
<
(
int
)
expression
.
size
()
&&
expression
[
start
]
==
' '
;
start
++
)
for
(
start
=
0
;
start
<
(
int
)
expression
.
size
()
&&
isspace
(
expression
[
start
]
)
;
start
++
)
;
for
(
end
=
expression
.
size
()
-
1
;
end
>
start
&&
expression
[
end
]
==
' '
;
end
--
)
for
(
end
=
expression
.
size
()
-
1
;
end
>
start
&&
isspace
(
expression
[
end
]
)
;
end
--
)
;
if
(
start
==
end
&&
expression
[
end
]
==
' '
)
if
(
start
==
end
&&
isspace
(
expression
[
end
]
)
)
return
""
;
return
expression
.
substr
(
start
,
end
-
start
+
1
);
}
...
...
@@ -86,11 +87,11 @@ ParseToken Parser::getNextToken(const string& expression, int start) {
return
ParseToken
(
","
,
ParseToken
::
Comma
);
if
(
Operators
.
find
(
c
)
!=
string
::
npos
)
return
ParseToken
(
string
(
1
,
c
),
ParseToken
::
Operator
);
if
(
c
==
' '
)
{
if
(
isspace
(
c
)
)
{
// White space
for
(
int
pos
=
start
+
1
;
pos
<
(
int
)
expression
.
size
();
pos
++
)
{
if
(
expression
[
pos
]
!=
' '
)
if
(
!
isspace
(
expression
[
pos
]
)
)
return
ParseToken
(
expression
.
substr
(
start
,
pos
-
start
),
ParseToken
::
Whitespace
);
}
return
ParseToken
(
expression
.
substr
(
start
,
string
::
npos
),
ParseToken
::
Whitespace
);
...
...
@@ -126,7 +127,7 @@ ParseToken Parser::getNextToken(const string& expression, int start) {
c
=
expression
[
pos
];
if
(
c
==
'('
)
return
ParseToken
(
expression
.
substr
(
start
,
pos
-
start
+
1
),
ParseToken
::
Function
);
if
(
Operators
.
find
(
c
)
!=
string
::
npos
||
c
==
','
||
c
==
')'
||
c
==
' '
)
if
(
Operators
.
find
(
c
)
!=
string
::
npos
||
c
==
','
||
c
==
')'
||
isspace
(
c
)
)
return
ParseToken
(
expression
.
substr
(
start
,
pos
-
start
),
ParseToken
::
Variable
);
}
return
ParseToken
(
expression
.
substr
(
start
,
string
::
npos
),
ParseToken
::
Variable
);
...
...
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