PPStartOfWordParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 24 Aug 2015 23:42:53 +0100
changeset 529 439c4057517f
parent 427 a7f5e6de19d2
permissions -rw-r--r--
PPCConfiguration refactoring [1/10]: renamed PPCArguments to PPCCompilationOptions Renamed PPCConfiguration>>#arguments/#arguments: to #options/#options:

"{ Package: 'stx:goodies/petitparser' }"

"{ NameSpace: Smalltalk }"

PPParser subclass:#PPStartOfWordParser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Parsers'
!

!PPStartOfWordParser methodsFor:'as yet unclassified'!

acceptsEpsilon
	^ true
!

parseOn: aPPContext
	aPPContext atEnd ifTrue: [  
		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
	].

	(aPPContext position == 0) ifTrue: [ 
		(aPPContext peek isAlphaNumeric) ifTrue: [ 
			^ #startOfWord
		] ifFalse: [ 
			^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
	 	]
	].

	aPPContext back.
	aPPContext peek isAlphaNumeric ifTrue: [
		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
	].
	aPPContext next.
	
	^ aPPContext peek isAlphaNumeric ifTrue: [ #startOfWord ] ifFalse: [ 
		PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
	]
	
! !