tools/JavaScanner.st
changeset 2678 c865275e48a7
parent 2396 fadc6d7a2f5b
child 2731 13f5be2bf83b
--- a/tools/JavaScanner.st	Fri Aug 16 19:52:36 2013 +0200
+++ b/tools/JavaScanner.st	Fri Sep 06 02:45:44 2013 +0200
@@ -90,7 +90,6 @@
     "Created: / 13.5.1998 / 14:54:06 / cg"
 ! !
 
-
 !JavaScanner class methodsFor:'initialization'!
 
 setupActions
@@ -231,7 +230,6 @@
     "Modified: / 15-03-2012 / 22:47:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner methodsFor:'accessing'!
 
 token
@@ -240,14 +238,14 @@
     ^Token new
         type: tokenType;
         value: tokenValue;
-        startPosition: tokenStartPosition;
-        endPosition: tokenEndPosition;
+        startPosition: tokenStartPosition + 1;
+        endPosition: tokenEndPosition + 1;
         yourself
 
     "Created: / 17-03-2012 / 13:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-08-2013 / 20:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner methodsFor:'converting'!
 
 asPetitStream
@@ -257,7 +255,6 @@
     "Created: / 14-03-2012 / 22:51:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner methodsFor:'error handling'!
 
 errorMessagePrefix
@@ -268,7 +265,6 @@
     ^ 'Java Warning:'
 ! !
 
-
 !JavaScanner methodsFor:'initialization'!
 
 initialize
@@ -278,9 +274,11 @@
 
     allowDegeneratedMantissa := true.     "/ something like 123.
     keywordTable := self class keywordTable.
+    saveComments := true.
+
+    "Modified: / 30-08-2013 / 02:48:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner methodsFor:'private'!
 
 checkForKeyword:string
@@ -315,7 +313,6 @@
     "Created: / 17-03-2012 / 17:39:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner methodsFor:'reading next token'!
 
 characterEscape:char
@@ -863,50 +860,50 @@
     inString := true.
 
     [inString] whileTrue:[
-	nextChar isNil ifTrue:[
-	    self syntaxError:'unexpected end-of-input in String'
-		    position:pos to:(source position - 1).
-	    tokenValue := nil.
-	    tokenType := #EOF.
-	    ^ tokenType
-	].
-	nextChar == $\ ifTrue:[
-	    nextChar := source next.
-	    nextChar := self characterEscape:nextChar.
-	] ifFalse:[
-	    (nextChar == Character cr) ifTrue:[
-		lineNr := lineNr + 1
-	    ] ifFalse:[
-		(nextChar == delimiter) ifTrue:[
-		    (source peekOrNil == delimiter) ifTrue:[
-			source next
-		    ] ifFalse:[
-			inString := false
-		    ]
-		].
-	    ].
-	].
-	inString ifTrue:[
-	    s nextPut:nextChar.
-	    nextChar := source next
-	]
+        nextChar isNil ifTrue:[
+            self syntaxError:'unexpected end-of-input in String'
+                    position:pos + 1 to:(source position).
+            tokenValue := nil.
+            tokenType := #EOF.
+            ^ tokenType
+        ].
+        nextChar == $\ ifTrue:[
+            nextChar := source next.
+            nextChar := self characterEscape:nextChar.
+        ] ifFalse:[
+            (nextChar == Character cr) ifTrue:[
+                lineNr := lineNr + 1
+            ] ifFalse:[
+                (nextChar == delimiter) ifTrue:[
+                    (source peekOrNil == delimiter) ifTrue:[
+                        source next
+                    ] ifFalse:[
+                        inString := false
+                    ]
+                ].
+            ].
+        ].
+        inString ifTrue:[
+            s nextPut:nextChar.
+            nextChar := source next
+        ]
     ].
 
     tokenValue := s contents.
     isCharacter ifTrue:[
-	tokenValue size ~~ 1 ifTrue:[
-	    self syntaxError:'bad (multi-)character constant'
-		    position:pos to:(source position - 1).
-	].
-	tokenValue := tokenValue at:1.
-	tokenType := #Character.
+        tokenValue size ~~ 1 ifTrue:[
+            self syntaxError:'bad (multi-)character constant'
+                    position:pos to:(source position - 1).
+        ].
+        tokenValue := tokenValue at:1.
+        tokenType := #Character.
     ] ifFalse:[
-	tokenType := #String.
+        tokenType := #String.
     ].
     ^ tokenType
 
-    "Created: / 16.5.1998 / 19:53:05 / cg"
-    "Modified: / 16.5.1998 / 19:57:16 / cg"
+    "Created: / 16-05-1998 / 19:53:05 / cg"
+    "Modified: / 04-08-2013 / 00:57:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 nextToken
@@ -932,37 +929,38 @@
 !
 
 skipComment
-    |commentStream commentType startPos|
+    |startPos|
 
     startPos := source position.
     source next.
     hereChar := source peekOrNil.
 
     [
-	[hereChar notNil and:[hereChar ~~ $*]] whileTrue:[
-	    hereChar == (Character cr) ifTrue:[
-		lineNr := lineNr + 1.
-	    ].
-	    hereChar := source nextPeek
-	].
+        [hereChar notNil and:[hereChar ~~ $*]] whileTrue:[
+            hereChar == (Character cr) ifTrue:[
+                lineNr := lineNr + 1.
+            ].
+            hereChar := source nextPeek
+        ].
     ] doUntil:[
-	hereChar := source nextPeek.
-	hereChar isNil or:[hereChar == $/].
+        hereChar := source nextPeek.
+        hereChar isNil or:[hereChar == $/].
     ].
 
     "skip final /"
     source next.
 
     hereChar isNil ifTrue:[
-	self warning:'unclosed comment' position:startPos to:(source position)
+        self warning:'unclosed comment' position:startPos - 2" '/*' already eaten" to:(source position)
     ].
 
-"/    saveComments ifTrue:[
-"/        self endComment:(commentStream contents) type:commentType.
-"/    ].
+    saveComments ifTrue:[
+        self addComment: (startPos - 2" '/*' already eaten" to: source position - 1)
+    ].
     ^ nil. "/ force nextToken again
 
-    "Modified: / 31.3.1998 / 23:45:26 / cg"
+    "Modified: / 31-03-1998 / 23:45:26 / cg"
+    "Modified: / 30-08-2013 / 02:51:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 skipEOLComment
@@ -978,7 +976,6 @@
     "Modified: / 16.5.1998 / 19:15:42 / cg"
 ! !
 
-
 !JavaScanner methodsFor:'stream api'!
 
 atEnd
@@ -1040,7 +1037,6 @@
     "Modified: / 14-03-2012 / 22:46:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner::Token class methodsFor:'documentation'!
 
 version_HG
@@ -1052,7 +1048,6 @@
     ^ '§Id§'
 ! !
 
-
 !JavaScanner::Token methodsFor:'accessing'!
 
 endPosition
@@ -1071,6 +1066,12 @@
     startPosition := something.
 !
 
+stopPosition
+    ^ endPosition
+
+    "Created: / 04-04-2013 / 00:32:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 type
     ^ type
 !
@@ -1087,7 +1088,6 @@
     value := something.
 ! !
 
-
 !JavaScanner::Token methodsFor:'printing & storing'!
 
 printOn:aStream
@@ -1106,11 +1106,10 @@
     "Modified: / 11-01-2013 / 12:32:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaScanner class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libjava/tools/JavaScanner.st,v 1.2 2013-02-25 11:15:35 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libjava/tools/JavaScanner.st,v 1.3 2013-09-06 00:45:28 vrany Exp $'
 !
 
 version_HG