PPStartOfLogicalLineParser.st
changeset 427 a7f5e6de19d2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPStartOfLogicalLineParser.st	Mon Apr 13 22:00:44 2015 +0100
@@ -0,0 +1,34 @@
+"{ Package: 'stx:goodies/petitparser' }"
+
+"{ NameSpace: Smalltalk }"
+
+PPParser subclass:#PPStartOfLogicalLineParser
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Parsers'
+!
+
+!PPStartOfLogicalLineParser methodsFor:'as yet unclassified'!
+
+isBlank: character
+	^ (character == Character space or: [character == Character tab])
+!
+
+parseOn: aPPContext
+	aPPContext peek isAlphaNumeric ifFalse: [ 
+		^ PPFailure message: 'Start of logical line expected' context: aPPContext 
+	].
+
+	aPPContext isStartOfLine ifTrue: [ ^ #startOfLogicalLine ].
+	
+	
+	[ aPPContext position ~= 0 ] whileTrue: [  
+		aPPContext back.
+		(self isBlank: aPPContext peek) ifFalse: [ 
+			^ PPFailure message: 'Start of logical line expected' context: aPPContext
+		].
+		aPPContext isStartOfLine ifTrue: [ ^ #startOfLogicalLine ].
+	]
+! !
+