parsers/java/PPJavaWhitespaceParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 21 Apr 2015 14:57:16 +0100
changeset 435 3bc08fb90133
child 436 e1c44b571db9
permissions -rw-r--r--
Initial commit of PetitJava Name: PetitJava-JanKurs.160 Author: JanKurs Time: 19-12-2014, 01:00:18.354 PM UUID: 1cb1b46d-8c68-4751-9720-f0dd742f3e16

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

"{ NameSpace: Smalltalk }"

PPParser subclass:#PPJavaWhitespaceParser
	instanceVariableNames:'separator'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitJava-Core'
!

PPJavaWhitespaceParser comment:''
!

!PPJavaWhitespaceParser methodsFor:'as yet unclassified'!

acceptsEpsilon
	^ true
!

acceptsEpsilonOpenSet: set
	^ true
!

firstCharParser
	^ PPFailingParser new
!

firstCharSet
	^ PPCharSetPredicate on: [:e | false ] 
!

isNullable
	^ true
!

name
	^ 'java_ws'
!

parseOn: context
	
	| start |

	[ 
		| peekTwice |
		[ context atEnd not and: [ context peek isSeparator ] ]
			whileTrue: [ context next ].
		peekTwice := context peekTwice.	
	  	((peekTwice  first = $/) and: 
		[ (peekTwice second = $*) or: [peekTwice second = $/]])
	] whileTrue: [
		context next.
		start := context position.
		(context next = $*) 
			ifTrue: [ context upToAll: '*/' ]
			ifFalse: [ 
				| position |
				position := context position.
				context upToAnyOf: CharacterSet crlf].
	 ].
! !