PPStartOfWordParser.st
changeset 427 a7f5e6de19d2
equal deleted inserted replaced
426:2a65c972b937 427:a7f5e6de19d2
       
     1 "{ Package: 'stx:goodies/petitparser' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPParser subclass:#PPStartOfWordParser
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitParser-Parsers'
       
    10 !
       
    11 
       
    12 !PPStartOfWordParser methodsFor:'as yet unclassified'!
       
    13 
       
    14 acceptsEpsilon
       
    15 	^ true
       
    16 !
       
    17 
       
    18 parseOn: aPPContext
       
    19 	aPPContext atEnd ifTrue: [  
       
    20 		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
       
    21 	].
       
    22 
       
    23 	(aPPContext position == 0) ifTrue: [ 
       
    24 		(aPPContext peek isAlphaNumeric) ifTrue: [ 
       
    25 			^ #startOfWord
       
    26 		] ifFalse: [ 
       
    27 			^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
       
    28 	 	]
       
    29 	].
       
    30 
       
    31 	aPPContext back.
       
    32 	aPPContext peek isAlphaNumeric ifTrue: [
       
    33 		^ PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
       
    34 	].
       
    35 	aPPContext next.
       
    36 	
       
    37 	^ aPPContext peek isAlphaNumeric ifTrue: [ #startOfWord ] ifFalse: [ 
       
    38 		PPFailure message: 'Start of word expected' context: aPPContext at: aPPContext position 
       
    39 	]
       
    40 	
       
    41 ! !
       
    42