SystemOrganization addCategory: #'TextLint-Tests'! SystemOrganization addCategory: #'TextLint-Model'! PPCompositeParser subclass: #TLTextParser instanceVariableNames: 'document paragraph sentence word' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:27'! document ^ (paragraph delimitedBy: #newline asParser token) ==> [ :nodes | TLDocument withAll: (nodes reject: [ :each | each class = PPToken ]) ]! ! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:31'! paragraph ^ (sentence delimitedBy: $. asParser token) ==> [ :nodes | TLParagraph withAll: (nodes reject: [ :each | each class = PPToken ]) ]! ! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:29'! sentence ^ word plus ==> [ :nodes | TLSentence withAll: nodes ]! ! !TLTextParser methodsFor: 'accessing' stamp: 'lr 3/31/2010 10:59'! start ^ document end! ! !TLTextParser methodsFor: 'productions' stamp: 'lr 3/31/2010 11:29'! word ^ #word asParser plus token ==> [ :node | TLWord with: node ]! ! Object subclass: #TLDocument instanceVariableNames: 'paragraphs' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLDocument class methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:15'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLDocument methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:16'! initializeWithAll: aCollection paragraphs := aCollection! ! !TLDocument methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:22'! paragraphs ^paragraphs ! ! !TLDocument methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:24'! sentences ^ self paragraphs gather: [ :each | each sentences ]! ! !TLDocument methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:24'! words ^self sentences gather: [ :each | each words ]! ! Object subclass: #TLParagraph instanceVariableNames: 'sentences' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLParagraph class methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:16'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLParagraph methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:17'! initializeWithAll: aCollection sentences := aCollection! ! !TLParagraph methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:32'! sentences ^sentences! ! Object subclass: #TLSentence instanceVariableNames: 'words' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLSentence class methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:17'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLSentence methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:17'! initializeWithAll: aCollection words := aCollection! ! !TLSentence methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:20'! words ^ words! ! Object subclass: #TLWord instanceVariableNames: 'token' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Model'! !TLWord class methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:18'! with: aToken ^self new initializeWith: aToken! ! !TLWord class methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:17'! withAll: aCollection ^self new initializeWithAll: aCollection! ! !TLWord methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:18'! initializeWith: aToken token := aToken! ! !TLWord methodsFor: 'accessing' stamp: 'lr 3/31/2010 11:21'! token ^ token! ! TestCase subclass: #TLTextParserTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Tests'! !TLTextParserTest methodsFor: 'as yet unclassified' stamp: 'lr 3/31/2010 11:30'! test | aParser aDocument | aParser := TLTextParser new. aDocument := aParser parse: 'text1 text2.'. self deny: aDocument isPetitFailure. self assert: aDocument paragraphs size = 1. self assert: aDocument sentences size = 1. self assert: aDocument words size = 2.! !