PPFailure.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
equal deleted inserted replaced
-1:000000000000 0:739fe9b7253e
       
     1 "{ Package: 'squeak:petitparser' }"
       
     2 
       
     3 Object subclass:#PPFailure
       
     4 	instanceVariableNames:'message position'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitParser-Core'
       
     8 !
       
     9 
       
    10 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.
       
    11 Instance Variables:
       
    12 	message	<String>	The error message of this failure.
       
    13 	position	<Integer>	The position of this failure in the input stream.
       
    14 '
       
    15 !
       
    16 
       
    17 
       
    18 !PPFailure class methodsFor:'instance creation'!
       
    19 
       
    20 message: aString at: anInteger
       
    21 	^ self basicNew initializeMessage: aString at: anInteger
       
    22 ! !
       
    23 
       
    24 !PPFailure methodsFor:'accessing'!
       
    25 
       
    26 message
       
    27 	"Answer a human readable error message of this parse failure."
       
    28 	
       
    29 	^ message
       
    30 !
       
    31 
       
    32 position
       
    33 	"Answer the position in the source string that caused this parse failure."
       
    34 
       
    35 	^ position
       
    36 ! !
       
    37 
       
    38 !PPFailure methodsFor:'initialization'!
       
    39 
       
    40 initializeMessage: aString at: anInteger
       
    41 	message := aString.
       
    42 	position := anInteger
       
    43 ! !
       
    44 
       
    45 !PPFailure methodsFor:'printing'!
       
    46 
       
    47 printOn: aStream
       
    48 	aStream nextPutAll: self message; nextPutAll: ' at '; print: position
       
    49 ! !
       
    50 
       
    51 !PPFailure methodsFor:'testing'!
       
    52 
       
    53 isPetitFailure
       
    54 	"I am the only class that should implement this method to return true."
       
    55 
       
    56 	^ true
       
    57 ! !
       
    58 
       
    59 !PPFailure class methodsFor:'documentation'!
       
    60 
       
    61 version_SVN
       
    62     ^ '$Id: PPFailure.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
       
    63 ! !