PPListParser.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPListParser.st	Thu Aug 18 20:56:17 2011 +0200
@@ -0,0 +1,62 @@
+"{ Package: 'squeak:petitparser' }"
+
+PPParser subclass:#PPListParser
+	instanceVariableNames:'parsers'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Parsers'
+!
+
+PPListParser comment:'Abstract parser that parses a list of things in some way (to be specified by the subclasses).
+Instance Variables:
+	parsers	<SequenceableCollection of: PPParser>	A sequence of other parsers to delegate to.'
+!
+
+
+!PPListParser class methodsFor:'instance creation'!
+
+with: aParser
+	^ self withAll: (Array with: aParser)
+!
+
+with: aFirstParser with: aSecondParser
+	^ self withAll: (Array with: aFirstParser with: aSecondParser)
+!
+
+withAll: aCollection
+	^ self basicNew setParsers: aCollection
+! !
+
+!PPListParser methodsFor:'accessing'!
+
+children
+	^ parsers
+! !
+
+!PPListParser methodsFor:'copying'!
+
+copyWith: aParser
+	^ self species withAll: (parsers copyWith: aParser)
+!
+
+postCopy
+	super postCopy.
+	parsers := parsers copy
+! !
+
+!PPListParser methodsFor:'initialization'!
+
+initialize
+	super initialize.
+	self setParsers: #()
+!
+
+setParsers: aCollection
+	parsers := aCollection asArray
+! !
+
+!PPListParser class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: PPListParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
+! !