# HG changeset patch # User Jan Vrany # Date 1415326466 0 # Node ID 3c0a91182e65e54b4906af02c77dda554910af50 # Parent b0fd54ee0412cab99e8e24106592c2f7e7d1e981 Smalltalk grammar updated to allow for Smalltalk/X EOL comments diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/PPSmalltalkGrammar.st --- 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 diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/PPSmalltalkToken.st --- 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: $' +! ! + diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/PPSmalltalkTokenParser.st --- 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 diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/PPSmalltalkWhitespaceParser.st --- 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 " ! ! !PPSmalltalkWhitespaceParser class methodsFor:'documentation'! diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/smalltalk.rc --- 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 diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/tests/PPSmalltalkClassesTests.st --- 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: $' +! ! + diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/tests/PPSmalltalkGrammarTests.st --- 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 " +! + +testComment6b + "Tests Smalltalk/X EOL comments" + self + parse: '1"/ xxxxx + +2 "/yyyy' + rule: #expression. + + "Created: / 07-11-2014 / 01:50:59 / Jan Vrany " +! + +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 " +! + +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 " +! + +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 " +! + testCompleteness "This test asserts that all subclasses override all test methods." diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/tests/PPSmalltalkParserTests.st --- 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 " +! + +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 " +! + +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 " +! + +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 " +! + +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 " +! + testMethod1 super testMethod1. self assert: result isMethod. diff -r b0fd54ee0412 -r 3c0a91182e65 parsers/smalltalk/tests/tests.rc --- 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