SystemOrganization addCategory: #PetitCSV! PPCompositeParser subclass: #PPCommaSeparatedParser instanceVariableNames: 'row cell rows endOfLine whitespace' classVariableNames: '' poolDictionaries: '' category: 'PetitCSV'! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'lr 6/11/2010 15:36'! cell ^ whitespace star , ($- asParser optional , #digit asParser plus , ($. asParser , #digit asParser plus) optional) token , whitespace star ==> [ :nodes | nodes second value asNumber ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'lr 6/11/2010 15:39'! endOfLine ^ #newline asParser token "(#cr asParser , #lf asParser optional) / #lf asParser"! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'lr 6/11/2010 15:38'! row ^ (cell delimitedBy: $, asParser token) ==> [ :nodes | nodes reject: [ :each | each class = PPToken ] ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'lr 6/11/2010 15:38'! rows ^ (row delimitedBy: endOfLine) ==> [ :nodes | nodes reject: [ :each | each class = PPToken ] ]! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'tg 6/11/2010 15:05'! start ^ rows end! ! !PPCommaSeparatedParser methodsFor: 'as yet unclassified' stamp: 'lr 6/12/2010 09:20'! whitespace ^ PPPredicateObjectParser anyOf: (Array with: Character space with: Character tab)! ! 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))! !