compiler/PPCContextMemento.st
changeset 422 116d2b2af905
parent 414 0eaf09920532
child 438 20598d7ce9fa
equal deleted inserted replaced
421:7e08b31e0dae 422:116d2b2af905
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
     2 
     4 
     3 Object subclass:#PPCContextMemento
     5 Object subclass:#PPCContextMemento
     4 	instanceVariableNames:'position properties'
     6 	instanceVariableNames:'position properties'
     5 	classVariableNames:''
     7 	classVariableNames:''
     6 	poolDictionaries:''
     8 	poolDictionaries:''
    41 	^ self propertyAt: aKey ifAbsent: [ self error: 'Property not found' ]
    43 	^ self propertyAt: aKey ifAbsent: [ self error: 'Property not found' ]
    42 !
    44 !
    43 
    45 
    44 propertyAt: aKey ifAbsent: aBlock
    46 propertyAt: aKey ifAbsent: aBlock
    45         "Answer the property value associated with aKey or, if aKey isn't found, answer the result of evaluating aBlock."
    47         "Answer the property value associated with aKey or, if aKey isn't found, answer the result of evaluating aBlock."
    46 
    48         
    47         properties isNil
    49         properties isNil
    48                 ifTrue: [ ^ aBlock value ]
    50                 ifTrue: [ ^ aBlock value ]
    49                 ifFalse: [ 
    51                 ifFalse: [ 
    50                         (properties includesKey: aKey) ifTrue: [ 
    52                         (properties includesKey: aKey) ifTrue: [ 
    51                                 ^ (properties at: aKey) copy
    53                                 ^ (properties at: aKey) copy
    52                         ].
    54                         ].
    53                         ^ aBlock value
    55                         ^ aBlock value
    54                 ]
    56                 ]
    55 
    57 
    56     "Created: / 26-10-2014 / 01:23:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    58     "Modified: / 15-04-2015 / 11:19:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    57 !
    59 !
    58 
    60 
    59 propertyAt: aKey ifAbsentPut: aBlock
    61 propertyAt: aKey ifAbsentPut: aBlock
    60 	"Answer the property associated with aKey or, if aKey isn't found store the result of evaluating aBlock as new value."
    62 	"Answer the property associated with aKey or, if aKey isn't found store the result of evaluating aBlock as new value."
    61 	
    63