Skip to content

Commit 3718bf4

Browse files
committed
fixed wrong float format detection
1 parent f2ff19c commit 3718bf4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/com/igormaznitsa/prologparser/tokenizer/Tokenizer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ TokenizerResult readNextToken() {
655655
getLastTokenPos());
656656
} else {
657657
// it is float
658+
if (!Character.isDigit(strBuffer.getLastChar())) {
659+
throw new PrologParserException("Unexpected end of float: " + strBuffer.toString(), this.prevLine, this.prevPos);
660+
}
658661
return this.tokenizerResultPool.find().setData(
659662
makeTermFromString(strBuffer.toString(), radix, quoting, state),
660663
state,

src/test/java/com/igormaznitsa/prologparser/IntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,7 @@ public void testConformity() {
11901190
assertThrows(PrologParserException.class, () -> parseEd("/**/ write_canonical(f f).").next());
11911191
assertThrows(PrologParserException.class, () -> parseEd("writeq(0'f').", DefaultParserContext.of(FLAG_BLOCK_COMMENTS, Op.make(100, XF, "f"))).next());
11921192

1193-
1194-
// assertThrows(PrologParserException.class, () -> parseEd("/**/ X = 1.e.", DefaultParserContext.of(FLAG_BLOCK_COMMENTS, Op.make(100, XF, "f"))).next());
1193+
assertThrows(PrologParserException.class, () -> parseEd("/**/ X = 1.e.", DefaultParserContext.of(FLAG_BLOCK_COMMENTS, Op.make(100, XF, "f"))).next());
11951194
assertThrows(PrologParserException.class, () -> parseEd("/**/ writeq(1 .2).").next());
11961195
// assertThrows(PrologParserException.class, () -> parseEd("X = 2'1.").next());
11971196
assertThrows(PrologParserException.class, () -> parseEd("is 0'mod'1.").next());

0 commit comments

Comments
 (0)