parsers/java/PPJavaWhitespaceParser.st
changeset 435 3bc08fb90133
child 436 e1c44b571db9
equal deleted inserted replaced
434:840942b96eea 435:3bc08fb90133
       
     1 "{ Package: 'stx:goodies/petitparser/parsers/java' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPParser subclass:#PPJavaWhitespaceParser
       
     6 	instanceVariableNames:'separator'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitJava-Core'
       
    10 !
       
    11 
       
    12 PPJavaWhitespaceParser comment:''
       
    13 !
       
    14 
       
    15 !PPJavaWhitespaceParser methodsFor:'as yet unclassified'!
       
    16 
       
    17 acceptsEpsilon
       
    18 	^ true
       
    19 !
       
    20 
       
    21 acceptsEpsilonOpenSet: set
       
    22 	^ true
       
    23 !
       
    24 
       
    25 firstCharParser
       
    26 	^ PPFailingParser new
       
    27 !
       
    28 
       
    29 firstCharSet
       
    30 	^ PPCharSetPredicate on: [:e | false ] 
       
    31 !
       
    32 
       
    33 isNullable
       
    34 	^ true
       
    35 !
       
    36 
       
    37 name
       
    38 	^ 'java_ws'
       
    39 !
       
    40 
       
    41 parseOn: context
       
    42 	
       
    43 	| start |
       
    44 
       
    45 	[ 
       
    46 		| peekTwice |
       
    47 		[ context atEnd not and: [ context peek isSeparator ] ]
       
    48 			whileTrue: [ context next ].
       
    49 		peekTwice := context peekTwice.	
       
    50 	  	((peekTwice  first = $/) and: 
       
    51 		[ (peekTwice second = $*) or: [peekTwice second = $/]])
       
    52 	] whileTrue: [
       
    53 		context next.
       
    54 		start := context position.
       
    55 		(context next = $*) 
       
    56 			ifTrue: [ context upToAll: '*/' ]
       
    57 			ifFalse: [ 
       
    58 				| position |
       
    59 				position := context position.
       
    60 				context upToAnyOf: CharacterSet crlf].
       
    61 	 ].
       
    62 ! !
       
    63