SystemOrganization addCategory: #PetitCSV! PPCompositeParser subclass: #PPCommaSeparatedParser instanceVariableNames: 'row cell rows endOfLine' classVariableNames: '' poolDictionaries: '' category: 'PetitCSV'! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/10/2010 19:06'! cell ^ ($- asParser optional , #digit asParser plus , ($. asParser , #digit asParser plus) optional) token trim ==> [ :token | token value asNumber ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:04'! endOfLine ^ (#cr asParser , #lf asParser optional) / #lf asParser! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:14'! row ^ cell, ($, asParser token, cell ==> [:tokens | tokens last ]) star ==> [:tokens | (Array withAll: tokens last) copyWithFirst: tokens first ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:14'! rows ^ row , (endOfLine , row ==> [:tokens | tokens last ]) star ==> [:tokens | (Array withAll: tokens last) copyWithFirst: tokens first ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:05'! start ^ rows end! ! PPCompositeParserTest subclass: #PPCommaSeparatedParserTest instanceVariableNames: 'row cell rows' classVariableNames: '' poolDictionaries: '' category: 'PetitCSV'! !PPCommaSeparatedParserTest methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 14:55'! parserClass ^ PPCommaSeparatedParser! ! !PPCommaSeparatedParserTest methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:14'! testSingleLine self assert: '1 , 2, 3' is: #((1 2 3))! ! !PPCommaSeparatedParserTest methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:00'! testTwoLines self assert: '1 2' is: #((1) (2))! !