Smalltalk grammar updated to allow for Smalltalk/X EOL comments
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 07 Nov 2014 02:14:26 +0000
changeset 417 3c0a91182e65
parent 416 b0fd54ee0412
child 418 b3080b20b14c
Smalltalk grammar updated to allow for Smalltalk/X EOL comments
parsers/smalltalk/PPSmalltalkGrammar.st
parsers/smalltalk/PPSmalltalkToken.st
parsers/smalltalk/PPSmalltalkTokenParser.st
parsers/smalltalk/PPSmalltalkWhitespaceParser.st
parsers/smalltalk/smalltalk.rc
parsers/smalltalk/tests/PPSmalltalkClassesTests.st
parsers/smalltalk/tests/PPSmalltalkGrammarTests.st
parsers/smalltalk/tests/PPSmalltalkParserTests.st
parsers/smalltalk/tests/tests.rc
--- a/parsers/smalltalk/PPSmalltalkGrammar.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/PPSmalltalkGrammar.st	Fri Nov 07 02:14:26 2014 +0000
@@ -48,6 +48,7 @@
 	^ (Scanner respondsTo: #allowUnderscoreAsAssignment) and: [ Scanner allowUnderscoreAsAssignment ]
 ! !
 
+
 !PPSmalltalkGrammar methodsFor:'accessing'!
 
 start
--- a/parsers/smalltalk/PPSmalltalkToken.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/PPSmalltalkToken.st	Fri Nov 07 02:14:26 2014 +0000
@@ -7,6 +7,7 @@
 	category:'PetitSmalltalk-Core'
 !
 
+
 !PPSmalltalkToken methodsFor:'accessing'!
 
 comments
@@ -23,3 +24,10 @@
 	^ self size
 ! !
 
+!PPSmalltalkToken class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/parsers/smalltalk/PPSmalltalkTokenParser.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/PPSmalltalkTokenParser.st	Fri Nov 07 02:14:26 2014 +0000
@@ -17,6 +17,7 @@
 	SeparatorPredicate := PPCharSetPredicate on: [ :char | char isSeparator ]
 ! !
 
+
 !PPSmalltalkTokenParser methodsFor:'parsing'!
 
 parseComments: anArray on: aPPContext
--- a/parsers/smalltalk/PPSmalltalkWhitespaceParser.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/PPSmalltalkWhitespaceParser.st	Fri Nov 07 02:14:26 2014 +0000
@@ -8,6 +8,7 @@
 !
 
 
+
 !PPSmalltalkWhitespaceParser methodsFor:'analysis'!
 
 isNullable
@@ -24,13 +25,31 @@
 !PPSmalltalkWhitespaceParser methodsFor:'parsing'!
 
 parseOn: aPPContext
-	[ [aPPContext atEnd not and: [ separator value: aPPContext uncheckedPeek ] ]
-		whileTrue: [ aPPContext next ].
-		
-	 aPPContext atEnd not and: [ aPPContext uncheckedPeek = $" ] ] whileTrue: [
-		aPPContext next.
-		aPPContext upTo: $".
-	].
+        "Skip any leading whitespace"
+        [ [aPPContext atEnd not and: [ separator value: aPPContext uncheckedPeek ] ]
+                whileTrue: [ aPPContext next ].
+
+        "Check for comment"
+         aPPContext atEnd not and: [ aPPContext uncheckedPeek = $" ] ] whileTrue: [
+                aPPContext next.
+                "Check for Smalltalk/X EOL comment"
+                aPPContext uncheckedPeek == $/ ifTrue:[
+                    | c |
+                    aPPContext next.
+                    [ aPPContext atEnd not 
+                        and:[ (c := aPPContext uncheckedPeek) ~~ (Character codePoint: 15r0A) 
+                        and: [ c ~~ (Character codePoint: 15r0D) ] ] ] whileTrue:[ 
+                            aPPContext next.
+                        ].
+                    (c == (Character codePoint: 15r0D) and:[ aPPContext atEnd not and:[ aPPContext uncheckedPeek == (Character codePoint: 15r0A) ] ] ) ifTrue:[ 
+                        aPPContext next
+                    ].
+                ] ifFalse:[ 
+                    aPPContext upTo: $".
+                ]
+        ].
+
+    "Modified: / 07-11-2014 / 01:18:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PPSmalltalkWhitespaceParser class methodsFor:'documentation'!
--- a/parsers/smalltalk/smalltalk.rc	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/smalltalk.rc	Fri Nov 07 02:14:26 2014 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2014\nCopyright eXept Software AG 1998-2014\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.4.0\0"
-      VALUE "ProductDate", "Sun, 26 Oct 2014 00:05:08 GMT\0"
+      VALUE "ProductDate", "Fri, 07 Nov 2014 02:08:51 GMT\0"
     END
 
   END
--- a/parsers/smalltalk/tests/PPSmalltalkClassesTests.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/tests/PPSmalltalkClassesTests.st	Fri Nov 07 02:14:26 2014 +0000
@@ -10,6 +10,7 @@
 PPSmalltalkClassesTests comment:'Evalaute the following code to verify the complete image.'
 !
 
+
 !PPSmalltalkClassesTests class methodsFor:'accessing'!
 
 packageNamesUnderTest
@@ -201,3 +202,10 @@
 	self should: [ self parserClass parseMethod: 'do 1 +' ] raise: Error
 ! !
 
+!PPSmalltalkClassesTests class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/parsers/smalltalk/tests/PPSmalltalkGrammarTests.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/tests/PPSmalltalkGrammarTests.st	Fri Nov 07 02:14:26 2014 +0000
@@ -112,6 +112,52 @@
 		rule: #expression
 !
 
+testComment6a
+        "Tests Smalltalk/X EOL comments"
+        self 
+                parse: '1+2"/ xxxxx'
+                rule: #expression.
+
+    "Created: / 07-11-2014 / 01:50:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6b
+        "Tests Smalltalk/X EOL comments"
+        self 
+                parse: '1"/ xxxxx
+                        +2 "/yyyy'
+                rule: #expression.
+
+    "Created: / 07-11-2014 / 01:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6c
+        "Tests Smalltalk/X EOL comments"
+        self 
+                parse: ('1"/ xxxxx', (Character codePoint: 13) asString, ' + 1')
+                rule: #expression.
+
+    "Created: / 07-11-2014 / 01:51:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6d
+        "Tests Smalltalk/X EOL comments"
+        self 
+                parse: ('1"/ xxxxx', (Character codePoint: 10) asString, ' + 1')
+                rule: #expression.
+
+    "Created: / 07-11-2014 / 01:51:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6e
+        "Tests Smalltalk/X EOL comments"
+        self 
+                parse: ('1"/ xxxxx', (Character codePoint: 13) asString, (Character codePoint: 10) asString, ' + 1')
+                rule: #expression.
+
+    "Created: / 07-11-2014 / 01:51:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 testCompleteness
 	"This test asserts that all subclasses override all test methods."
 	
--- a/parsers/smalltalk/tests/PPSmalltalkParserTests.st	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/tests/PPSmalltalkParserTests.st	Fri Nov 07 02:14:26 2014 +0000
@@ -184,6 +184,56 @@
 	self assert: result arguments first isValue
 !
 
+testComment6a
+        super testComment6a.
+        self assert: result isMessage.
+        self assert: result receiver isValue.
+        self assert: result selector equals: #+.
+        self assert: result arguments first isValue
+
+    "Created: / 07-11-2014 / 01:53:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6b
+        super testComment6b.
+        self assert: result isMessage.
+        self assert: result receiver isValue.
+        self assert: result selector equals: #+.
+        self assert: result arguments first isValue
+
+    "Created: / 07-11-2014 / 01:53:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6c
+        super testComment6c.
+        self assert: result isMessage.
+        self assert: result receiver isValue.
+        self assert: result selector equals: #+.
+        self assert: result arguments first isValue
+
+    "Created: / 07-11-2014 / 01:53:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6d
+        super testComment6d.
+        self assert: result isMessage.
+        self assert: result receiver isValue.
+        self assert: result selector equals: #+.
+        self assert: result arguments first isValue
+
+    "Created: / 07-11-2014 / 01:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testComment6e
+        super testComment6e.
+        self assert: result isMessage.
+        self assert: result receiver isValue.
+        self assert: result selector equals: #+.
+        self assert: result arguments first isValue
+
+    "Created: / 07-11-2014 / 01:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 testMethod1
 	super testMethod1.
 	self assert: result isMethod.
--- a/parsers/smalltalk/tests/tests.rc	Thu Nov 06 02:22:56 2014 +0000
+++ b/parsers/smalltalk/tests/tests.rc	Fri Nov 07 02:14:26 2014 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2014\nCopyright eXept Software AG 1998-2014\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.4.0\0"
-      VALUE "ProductDate", "Sun, 26 Oct 2014 00:05:09 GMT\0"
+      VALUE "ProductDate", "Fri, 07 Nov 2014 02:08:52 GMT\0"
     END
 
   END