Fixed GroovyScanner w.r.t ''' multiline comments.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 12 May 2014 17:34:16 +0100
changeset 3101 446b34b9a386
parent 3100 cf2d8949d5a5
child 3102 c0d467b37565
Fixed GroovyScanner w.r.t ''' multiline comments.
tools/GroovyScanner.st
tools/JavaScanner.st
tools/JavaScannerBase.st
tools/JavaSourceHighlighter.st
tools/Make.proto
tools/bc.mak
--- a/tools/GroovyScanner.st	Mon May 05 10:10:14 2014 +0100
+++ b/tools/GroovyScanner.st	Mon May 12 17:34:16 2014 +0100
@@ -8,6 +8,13 @@
 !
 
 
+!GroovyScanner methodsFor:'error reporting'!
+
+warnPossibleIncompatibility:aString position:smallInteger1 to:smallInteger2
+
+    "Created: / 12-05-2014 / 16:23:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GroovyScanner methodsFor:'reading next token'!
 
 nextString:delimiter character:ignored
@@ -28,6 +35,13 @@
             nextChar := source next.
         ].
     ].
+    (delimiter == $' and:[nextChar == $']) ifTrue:[
+        source peek == $' ifTrue:[
+            inTrippleQuoteString := true.
+            nextChar := source next.
+            nextChar := source next.
+        ].
+    ]. 
 
     [inString] whileTrue:[
         nextChar isNil ifTrue:[
@@ -47,17 +61,17 @@
                 (nextChar == delimiter) ifTrue:[
                     inTrippleQuoteString ifTrue:[
                         nextChar := source next.
-                        nextChar == $" ifTrue:[
-                            "/ OK, two $" found...
+                        nextChar == delimiter ifTrue:[
+                            "/ OK, two $"/$' found...
                             nextChar := source next.
-                            nextChar == $" ifTrue:[
+                            nextChar == delimiter ifTrue:[
                                 inString := false.
                             ] ifFalse:[
-                                s nextPut:$".
-                                s nextPut:$".
+                                s nextPut:delimiter.
+                                s nextPut:delimiter.
                             ].
                         ] ifFalse:[
-                            s nextPut:$".
+                            s nextPut:delimiter.
                         ].
                     ] ifFalse:[
                         (source peekOrNil == delimiter) ifTrue:[
@@ -81,6 +95,23 @@
     ^ tokenType
 
     "Created: / 18-10-2013 / 12:54:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-05-2014 / 16:56:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+nextToken
+    "Refefined here to support hash-bang"
+
+    source position < 1 ifTrue:[ 
+        source peek == $# ifTrue:[ 
+            source next.
+            source peek == $!! ifTrue:[ 
+                source nextLine.
+            ].
+        ].
+    ].
+    ^ super nextToken
+
+    "Created: / 12-05-2014 / 16:21:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GroovyScanner class methodsFor:'documentation'!
--- a/tools/JavaScanner.st	Mon May 05 10:10:14 2014 +0100
+++ b/tools/JavaScanner.st	Mon May 12 17:34:16 2014 +0100
@@ -917,6 +917,8 @@
     Verbose == true ifTrue:[
         Transcript 
             show:'JavaScanner nextToken => ';
+            show: tokenLineNr printString;
+            show: ' | ';
             show: t storeString;
             show: ' | ';
             showCR: tokenValue.
@@ -925,7 +927,7 @@
 
     "Created: / 14-05-1998 / 15:48:04 / cg"
     "Modified: / 16-05-1998 / 19:12:29 / cg"
-    "Modified: / 17-03-2012 / 17:35:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-05-2014 / 16:29:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 skipComment
--- a/tools/JavaScannerBase.st	Mon May 05 10:10:14 2014 +0100
+++ b/tools/JavaScannerBase.st	Mon May 12 17:34:16 2014 +0100
@@ -15,7 +15,8 @@
 	instanceVariableNames:'typeArray actionArray source lineNr tokenType tokenStartPosition
 		tokenEndPosition tokenLineNr numberRadix numberScale hereChar
 		peekChar peekChar2 requestor saveComments tokenValue
-		scaledMantissaValue parserFlags comments'
+		scaledMantissaValue parserFlags comments reportNewLine
+		reportComments'
 	classVariableNames:'Warnings'
 	poolDictionaries:''
 	category:'Languages-Java-Parser'
@@ -314,6 +315,19 @@
     parserFlags := something.
 !
 
+reportNewLine
+    ^ reportNewLine
+!
+
+reportNewLine:aBoolean
+    "When set to true, a #NewLine token is generated for each new line character.
+     If false, new line is treaded as whitespace"
+
+    reportNewLine := aBoolean.
+
+    "Modified (comment): / 12-05-2014 / 14:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 saveComments:aBoolean
     "toggle to turn on/off comment remembering"
 
@@ -598,8 +612,10 @@
         actionArray := self class actionArray
     ].
     typeArray := self class typeArray.
+    reportNewLine := false.
+    reportComments := false.
 
-    "Modified: / 14-03-2012 / 22:35:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-05-2014 / 14:51:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 initializeFor:aStringOrStream
@@ -726,6 +742,12 @@
                 hereChar == (Character cr) ifTrue:[
                     lineNr := lineNr + 1.
                     source next.
+                    reportNewLine ifTrue:[ 
+                        tokenType := #NewLine.
+                        tokenValue := Character cr.
+                        tokenStartPosition := tokenEndPosition := source position - 1.
+                        ^ tokenType
+                    ].
                 ] ifFalse:[
                     hereChar == (Character return) ifTrue:[
                         source next.
@@ -770,6 +792,8 @@
             ^ #Error
         ]
     ].
+
+    "Modified: / 12-05-2014 / 14:53:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 skipComment
--- a/tools/JavaSourceHighlighter.st	Mon May 05 10:10:14 2014 +0100
+++ b/tools/JavaSourceHighlighter.st	Mon May 12 17:34:16 2014 +0100
@@ -782,7 +782,6 @@
     "Modified: / 17-09-2013 / 01:33:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaSourceHighlighter::Indexer methodsFor:'accessing'!
 
 index
@@ -959,7 +958,6 @@
     "Modified: / 11-09-2013 / 01:45:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-
 !JavaSourceHighlighter::Marker methodsFor:'accessing'!
 
 highlighter:aJavaSourceHighlighter
--- a/tools/Make.proto	Mon May 05 10:10:14 2014 +0100
+++ b/tools/Make.proto	Mon May 12 17:34:16 2014 +0100
@@ -140,9 +140,10 @@
 	cd ../../libcomp && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libui && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+	cd ../../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+	cd ../../goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+	cd ../../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../ && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
-	cd ../../libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
-	cd ../../libwidg && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libwidg2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libtool && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 
--- a/tools/bc.mak	Mon May 05 10:10:14 2014 +0100
+++ b/tools/bc.mak	Mon May 12 17:34:16 2014 +0100
@@ -57,9 +57,10 @@
 	pushd ..\..\libcomp & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libui & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+	pushd ..\..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+	pushd ..\..\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+	pushd ..\..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd .. & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
-	pushd ..\..\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
-	pushd ..\..\libwidg & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libwidg2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libtool & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "