parsers/java/PPJavaWhitespaceParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 23 Nov 2015 11:14:30 +0100
changeset 551 00ebb1b85f53
parent 454 a9cd5ea7cc36
permissions -rw-r--r--
Fixed CI scripts on Windows For an unknown reason, unzip on Windows reports status code 50 (presumably "the disk is (or was) full during extraction.") even if there's plenty of space. To workaround this, simply ignore status code 50 on Windows. Sigh.

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

"{ NameSpace: Smalltalk }"

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


!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: String crlf].
         ].

    "Modified: / 10-05-2015 / 07:57:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !