Bugfix in JavaScanner - correctly handle dot a the end of input.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 14 May 2014 16:36:12 +0100
changeset 3104 c4709bcca97a
parent 3103 a7d69709920f
child 3105 7cc116da75e8
Bugfix in JavaScanner - correctly handle dot a the end of input. Do not try to read past the stream end.
tools/JavaScanner.st
--- a/tools/JavaScanner.st	Wed May 14 00:07:29 2014 +0100
+++ b/tools/JavaScanner.st	Wed May 14 16:36:12 2014 +0100
@@ -471,24 +471,27 @@
     |nextChar nextChar2|
 
     nextChar := source nextPeek.
-    nextChar isDigit ifTrue:[
-        ^ self nextFractionalPart:0.
-    ].
-    nextChar == $. ifTrue:[
-        nextChar2 := source nextPeek.
-        nextChar2 == $. ifTrue:[
-            source next.
-            tokenType := #Ellipsis.
-            tokenValue := '...'.
-            ^tokenType.
-        ] ifFalse:[
-            source skip: -1.
+    (nextChar isNil and:[ source atEnd ]) ifFalse:[
+        nextChar isDigit ifTrue:[
+            ^ self nextFractionalPart:0.
+        ].
+        nextChar == $. ifTrue:[
+            nextChar2 := source nextPeek.
+            nextChar2 == $. ifTrue:[
+                source next.
+                tokenType := #Ellipsis.
+                tokenValue := '...'.
+                ^tokenType.
+            ] ifFalse:[
+                source skip: -1.
+            ].
         ].
     ].
     tokenType := tokenValue := $. .
     ^ tokenType
 
     "Created: / 15-03-2012 / 10:08:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-05-2014 / 16:12:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 nextFractionalPart:intValue