PPStartOfLogicalLineParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 13 Apr 2015 22:00:44 +0100
changeset 427 a7f5e6de19d2
permissions -rw-r--r--
Merged JK's version from Monticello Name: PetitParser-JanKurs.275 Author: JanKurs Time: 31-03-2015, 05:51:24.398 PM UUID: 9ab3be24-8393-4794-a7e6-e318f3195673 Name: PetitTests-JanKurs.73 Author: JanKurs Time: 21-02-2015, 01:10:13.115 PM UUID: de4f77e3-2d07-476b-855e-69f845edfc7c

"{ 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 ].
	]
! !