PPStartOfLogicalLineParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 12 May 2015 01:57:37 +0100
changeset 461 5986bf6d7d60
parent 427 a7f5e6de19d2
permissions -rw-r--r--
Portability: fixes for Smalltalk/X * Do not use #crShow: - not present in Smalltalk/X * Do not use Array class>>with:withAll: * do not use detect:ifFound:ifAbsent:

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