PPFailure.st
changeset 377 6112a403a52d
parent 45 ca9fad0faa21
child 642 77d5fddb6462
equal deleted inserted replaced
376:a2656b27cace 377:6112a403a52d
     1 "{ Package: 'stx:goodies/petitparser' }"
     1 "{ Package: 'stx:goodies/petitparser' }"
     2 
     2 
     3 Object subclass:#PPFailure
     3 Object subclass:#PPFailure
     4 	instanceVariableNames:'message position'
     4 	instanceVariableNames:'message context position'
     5 	classVariableNames:''
     5 	classVariableNames:''
     6 	poolDictionaries:''
     6 	poolDictionaries:''
     7 	category:'PetitParser-Core'
     7 	category:'PetitParser-Core'
     8 !
     8 !
     9 
     9 
    10 
    10 
    11 !PPFailure class methodsFor:'instance creation'!
    11 !PPFailure class methodsFor:'instance creation'!
    12 
    12 
       
    13 message: aString
       
    14 	^ self basicNew initializeMessage: aString 
       
    15 !
       
    16 
    13 message: aString at: anInteger
    17 message: aString at: anInteger
       
    18 	"One should not use this method if the furthest failure is supposed to be reported correctly"
    14 	^ self basicNew initializeMessage: aString at: anInteger
    19 	^ self basicNew initializeMessage: aString at: anInteger
       
    20 !
       
    21 
       
    22 message: aString context: aPPContext
       
    23 	^ self basicNew initializeMessage: aString context: aPPContext
       
    24 !
       
    25 
       
    26 message: aString context: aPPContext at: position
       
    27 	^ self basicNew initializeMessage: aString context: aPPContext position: position
    15 ! !
    28 ! !
    16 
    29 
    17 !PPFailure methodsFor:'accessing'!
    30 !PPFailure methodsFor:'accessing'!
    18 
    31 
    19 message
    32 message
    28 	^ position
    41 	^ position
    29 ! !
    42 ! !
    30 
    43 
    31 !PPFailure methodsFor:'initialization'!
    44 !PPFailure methodsFor:'initialization'!
    32 
    45 
       
    46 initializeMessage: aString	
       
    47 	message := aString.
       
    48 !
       
    49 
    33 initializeMessage: aString at: anInteger
    50 initializeMessage: aString at: anInteger
       
    51 	"One should not use this method if the furthest failure is supposed to be reported correctly"
    34 	message := aString.
    52 	message := aString.
    35 	position := anInteger
    53 	position := anInteger.
       
    54 !
       
    55 
       
    56 initializeMessage: aString context: aPPContext
       
    57 	self initializeMessage: aString context:  aPPContext position: aPPContext position
       
    58 !
       
    59 
       
    60 initializeMessage: aString context: aPPContext position: anInteger
       
    61 	message := aString.
       
    62 	context := aPPContext.
       
    63 	position := anInteger.
       
    64 	
       
    65 	"record the furthest failure encountered while parsing the input stream "
       
    66 	aPPContext noteFailure: self.	
    36 ! !
    67 ! !
    37 
    68 
    38 !PPFailure methodsFor:'printing'!
    69 !PPFailure methodsFor:'printing'!
    39 
    70 
    40 printOn: aStream
    71 printOn: aStream
    41 	aStream nextPutAll: self message; nextPutAll: ' at '; print: position
    72 	aStream nextPutAll: self message; nextPutAll: ' at '; print: self position
    42 ! !
    73 ! !
    43 
    74 
    44 !PPFailure methodsFor:'testing'!
    75 !PPFailure methodsFor:'testing'!
    45 
    76 
    46 isPetitFailure
    77 isPetitFailure
    60 !
    91 !
    61 
    92 
    62 version_SVN
    93 version_SVN
    63     ^ '§Id: PPFailure.st 2 2010-12-17 18:44:23Z vranyj1 §'
    94     ^ '§Id: PPFailure.st 2 2010-12-17 18:44:23Z vranyj1 §'
    64 ! !
    95 ! !
       
    96