Skip to content

Commit

Permalink
Multiple "dots" in numbers should create multiple floating point numbers
Browse files Browse the repository at this point in the history
>> 0.17583681.41125407852.0 // HoldForm // FullForm

HoldForm(Times(Times(0.17583681, 0.41125407852), 0.0))
  • Loading branch information
axkr committed Dec 14, 2019
1 parent db9943b commit 189f03a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ protected void getNextToken() throws SyntaxError {
fToken = TT_DIGIT; fToken = TT_DIGIT;
return; return;
} }
if (fCurrentChar == '.') {
if (Character.isDigit(charAtPosition())) {
fToken = TT_DIGIT;
return;
}
}
if (fCurrentChar == '(') { if (fCurrentChar == '(') {
if (isValidPosition()) { if (isValidPosition()) {
if (charAtPosition() == '*') { if (charAtPosition() == '*') {
Expand Down Expand Up @@ -697,23 +703,23 @@ protected void getNextToken() throws SyntaxError {
fToken = TT_OPERATOR; fToken = TT_OPERATOR;
return; return;
} }
if (fCurrentChar == '.') { // if (fCurrentChar == '.') {
if (isValidPosition()) { // if (isValidPosition()) {
if (Character.isDigit(fCurrentChar)) { // if (Character.isDigit(fCurrentChar)) {
// don't increment fCurrentPosition (see // // don't increment fCurrentPosition (see
// getNumberString()) // // getNumberString())
fToken = TT_DIGIT; // floating-point number // fToken = TT_DIGIT; // floating-point number
break; // break;
} // }
} // }
break; // break;
} else { // } else {
if (Characters.CharacterNamesMap.containsKey(String.valueOf(fCurrentChar))) { if (Characters.CharacterNamesMap.containsKey(String.valueOf(fCurrentChar))) {
fToken = TT_IDENTIFIER; fToken = TT_IDENTIFIER;
return; return;
}
throwSyntaxError("unexpected character: '" + fCurrentChar + "'");
} }
throwSyntaxError("unexpected character: '" + fCurrentChar + "'");
// }
} }


if (fToken == TT_EOF) { if (fToken == TT_EOF) {
Expand Down Expand Up @@ -816,7 +822,8 @@ protected Object[] getNumberString() {
numFormat = Integer.parseInt( numFormat = Integer.parseInt(
new String(fInputString, startPosition, fCurrentPosition - startPosition - 1)); new String(fInputString, startPosition, fCurrentPosition - startPosition - 1));
if (numFormat <= 0 || numFormat > 36) { if (numFormat <= 0 || numFormat > 36) {
throwSyntaxError("Base " + numFormat + "^^... is invalid. Only bases between 1 and 36 are allowed"); throwSyntaxError(
"Base " + numFormat + "^^... is invalid. Only bases between 1 and 36 are allowed");
} }
fCurrentPosition++; fCurrentPosition++;
startPosition = fCurrentPosition; startPosition = fCurrentPosition;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4809,6 +4809,9 @@ public void testDo() {
} }


public void testDot() { public void testDot() {
check("0.17583681.41125407852.0 // HoldForm // FullForm", //
"HoldForm(Times(Times(0.17583681, 0.41125407852), 0.0))");

check("Dot({a,b,c})", // check("Dot({a,b,c})", //
"{a,b,c}"); "{a,b,c}");
check("Dot({{1, 2}, {3, 4}, {5, 6}})", // check("Dot({{1, 2}, {3, 4}, {5, 6}})", //
Expand Down

0 comments on commit 189f03a

Please sign in to comment.