parsers/smalltalk/PPSmalltalkWhitespaceParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 20 Apr 2015 13:24:27 +0100
changeset 433 6fcdf4d2c32c
parent 421 7e08b31e0dae
permissions -rw-r--r--
Skip Java benchmarks on Smalltalk/X ...as Java parser is not yet supported.

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

PPParser subclass:#PPSmalltalkWhitespaceParser
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitSmalltalk-Core'
!



!PPSmalltalkWhitespaceParser methodsFor:'analysis'!

isNullable
	^ true
! !

!PPSmalltalkWhitespaceParser methodsFor:'initialization'!

initialize
	super initialize.
! !

!PPSmalltalkWhitespaceParser methodsFor:'parsing'!

name
	^ 'smalltalk_ws'
!

parseOn: aPPContext
        "Skip any leading whitespace"
        [ [aPPContext atEnd not and: [  aPPContext uncheckedPeek isSeparator ] ]
                whileTrue: [ aPPContext next ].

        "Check for comment"
         aPPContext atEnd not and: [ aPPContext uncheckedPeek = $" ] ] whileTrue: [
                aPPContext next.
                "Check for Smalltalk/X EOL comment"
                aPPContext uncheckedPeek == $/ ifTrue:[
                    | c |
                    aPPContext next.
                    [ aPPContext atEnd not 
                        and:[ (c := aPPContext uncheckedPeek) ~~ (Character codePoint: 15r0A) 
                        and: [ c ~~ (Character codePoint: 15r0D) ] ] ] whileTrue:[ 
                            aPPContext next.
                        ].
                    (c == (Character codePoint: 15r0D) and:[ aPPContext atEnd not and:[ aPPContext uncheckedPeek == (Character codePoint: 15r0A) ] ] ) ifTrue:[ 
                        aPPContext next
                    ].
                ] ifFalse:[ 
                    aPPContext upTo: $".
                ]
        ].

    "Modified: / 21-11-2014 / 10:10:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!PPSmalltalkWhitespaceParser class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !