PPFailure.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 May 2012 00:03:13 +0200
changeset 30 6d6315787d46
parent 4 90de244a7fa2
child 45 ca9fad0faa21
permissions -rw-r--r--
Checkin from browser

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

Object subclass:#PPFailure
	instanceVariableNames:'message position'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitParser-Core'
!

PPFailure comment:'The failure object in PetitParser. It is the only class that responds to #isPetitFailure with true. It contains an error message and a position of the occurrence of the failure.
Instance Variables:
	message <String>        The error message of this failure.
	position        <Integer>       The position of this failure in the input stream.
'
!


!PPFailure class methodsFor:'instance creation'!

message: aString at: anInteger
	^ self basicNew initializeMessage: aString at: anInteger
! !

!PPFailure methodsFor:'accessing'!

message
	"Answer a human readable error message of this parse failure."

	^ message
!

position
	"Answer the position in the source string that caused this parse failure."

	^ position
! !

!PPFailure methodsFor:'initialization'!

initializeMessage: aString at: anInteger
	message := aString.
	position := anInteger
! !

!PPFailure methodsFor:'printing'!

printOn: aStream
	aStream nextPutAll: self message; nextPutAll: ' at '; print: position
! !

!PPFailure methodsFor:'testing'!

isPetitFailure
	"I am the only class that should implement this method to return true."

	^ true
! !

!PPFailure class methodsFor:'documentation'!

version_SVN
    ^ '$Id: PPFailure.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
! !