tools/JavaTokenParser.st
author vranyj1
Mon, 03 Dec 2012 22:09:19 +0000
branchdevelopment
changeset 1859 4d42d0099c74
parent 1818 2e5ed72e7dfd
child 1879 7d232ff32dde
permissions -rw-r--r--
Ignore tests in MemberVisibilityTests (package-private methods not yet supported)

"{ Package: 'stx:libjava/tools' }"

PPParser subclass:#JavaTokenParser
	instanceVariableNames:'tokenType'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Parser'
!


!JavaTokenParser class methodsFor:'instance creation'!

for: tokenType

    ^self new tokenType: tokenType

    "Created: / 14-03-2012 / 23:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTokenParser methodsFor:'accessing'!

tokenType
    ^ tokenType
!

tokenType:something
    tokenType := something.
! !

!JavaTokenParser methodsFor:'parsing'!

parseOn:aJavaScanner
    "Parse aStream with the receiving parser and answer the parse-result or an instance of PPFailure. 
    Override this method in subclasses to specify custom parse behavior. Do not call this method from outside, 
    instead use #parse:."

    | pos |

    pos := aJavaScanner position.

    ^(aJavaScanner nextToken = tokenType) ifTrue:[
        aJavaScanner token
    ] ifFalse:[
        aJavaScanner position: pos.
        PPFailure message: (tokenType printString , ' token expected (got ', aJavaScanner tokenType , ' {',(aJavaScanner tokenValue ? '<nil>') printString,'})') at: aJavaScanner position
    ]

    "Modified: / 17-03-2012 / 13:34:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTokenParser class methodsFor:'documentation'!

version_SVN
    ^ '$Id$'
! !