[squeak-dev] The Trunk: Regex-Core-ul.52.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 19 23:03:25 UTC 2016


Levente Uzonyi uploaded a new version of Regex-Core to project The Trunk:
http://source.squeak.org/trunk/Regex-Core-ul.52.mcz

==================== Summary ====================

Name: Regex-Core-ul.52
Author: ul
Time: 20 May 2016, 1:02:48.025069 am
UUID: 25d06172-cbd2-4454-a5e7-0dcfc27525b4
Ancestors: Regex-Core-pre.51

RxmLink changes:
- implemented #copyChain, #copyUsing: and #postCopyUsing: to create a copy of the matcher chain without creating duplicates of links being referenced from more than one place
- implemented missing #postCopy methods
- removed unused variables from subclasses

- use #copyChain instead of #veryDeepCopy in RxMatcher >> #makeQuantified:min:max: to avoid unnecessary duplication of non-link objects

=============== Diff against Regex-Core-pre.51 ===============

Item was changed:
  ----- Method: RxMatcher>>makeQuantified:min:max: (in category 'private') -----
  makeQuantified: anRxmLink min: min max: max 
  	"Perform recursive poor-man's transformation of the {<min>,<max>} quantifiers."
  	| aMatcher |
  	
  	"<atom>{,<max>}       ==>  (<atom>{1,<max>})?"
  	min = 0 ifTrue: [ 
  		^ self makeOptional: (self makeQuantified: anRxmLink min: 1 max: max) ].
  	
  	"<atom>{<min>,}       ==>  <atom>{<min>-1, <min>-1}<atom>+"
  	max ifNil: [
+ 		^ (self makeQuantified: anRxmLink min: 1 max: min-1) pointTailTo: (self makePlus: anRxmLink copyChain) ].
- 		^ (self makeQuantified: anRxmLink min: 1 max: min-1) pointTailTo: (self makePlus: anRxmLink veryDeepCopy) ].
  	
  	"<atom>{<max>,<max>}  ==>  <atom><atom> ... <atom>"
  	min = max 
  		ifTrue: [ 
+ 			aMatcher := anRxmLink copyChain.
+ 			(min-1) timesRepeat: [ aMatcher pointTailTo: anRxmLink copyChain ].
- 			aMatcher := anRxmLink veryDeepCopy.
- 			(min-1) timesRepeat: [ aMatcher pointTailTo: anRxmLink veryDeepCopy ].
  			^ aMatcher ].
  
  	"<atom>{<min>,<max>}  ==>  <atom>{<min>,<min>}(<atom>{1,<max>-1})?"
+ 	aMatcher := self makeOptional: anRxmLink copyChain.
- 	aMatcher := self makeOptional: anRxmLink veryDeepCopy.
  	(max - min - 1) timesRepeat: [ 
+ 		 aMatcher := self makeOptional: (anRxmLink copyChain pointTailTo: aMatcher) ].
- 		 aMatcher := self makeOptional: (anRxmLink veryDeepCopy pointTailTo: aMatcher) ].
  	^ (self makeQuantified: anRxmLink min: min max: min) pointTailTo: aMatcher!

Item was added:
+ ----- Method: RxmBranch>>postCopyUsing: (in category 'copying') -----
+ postCopyUsing: anIdentityDictionary
+ 
+ 	super postCopyUsing: anIdentityDictionary.
+ 	alternative ifNotNil: [
+ 		alternative := alternative copyUsing: anIdentityDictionary ]!

Item was added:
+ ----- Method: RxmLink>>copyChain (in category 'copying') -----
+ copyChain
+ 	"Create a full copy of all the links in this chain, including branches, while letting them share and reuse non-link objects as much as possible."
+ 
+ 	^self copyUsing: IdentityDictionary new!

Item was added:
+ ----- Method: RxmLink>>copyUsing: (in category 'copying') -----
+ copyUsing: anIdentityDictionary
+ 	"Copy the receiver if it's not present in the argument dictionary, or just return the previously made copy. The rest of the object graph will be copied by #postCopyUsing:."
+ 
+ 	^anIdentityDictionary 
+ 		at: self
+ 		ifAbsent: [
+ 			"It may be tempting to use #at:ifAbsentPut: instead, but the argument block must not modify the receiver, so that wouldn't work."
+ 			anIdentityDictionary
+ 				at: self
+ 				put: (self shallowCopy
+ 					postCopyUsing: anIdentityDictionary;
+ 					yourself) ]!

Item was added:
+ ----- Method: RxmLink>>postCopyUsing: (in category 'copying') -----
+ postCopyUsing: anIdentityDictionary
+ 	"Copy the rest of the chain the same way as it's done in #copyUsing:."
+ 
+ 	next ifNotNil: [
+ 		next := next copyUsing: anIdentityDictionary ]!

Item was changed:
  RxmLink subclass: #RxmLookahead
+ 	instanceVariableNames: 'lookahead'
- 	instanceVariableNames: 'lookahead positive'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Regex-Core'!
  
  !RxmLookahead commentStamp: '<historical>' prior: 0!
  Instance holds onto a lookead which matches but does not consume anything.
  
  Instance variables:
  	predicate		<RxmLink>!

Item was removed:
- ----- Method: RxmLookahead>>initialize (in category 'initialization') -----
- initialize
- 	super initialize.
- 	positive := true.!

Item was added:
+ ----- Method: RxmLookahead>>postCopy (in category 'copying') -----
+ postCopy
+ 
+ 	super postCopy.
+ 	lookahead := lookahead copy!

Item was added:
+ ----- Method: RxmLookahead>>postCopyUsing: (in category 'copying') -----
+ postCopyUsing: anIdentityDictionary
+ 
+ 	super postCopyUsing: anIdentityDictionary.
+ 	lookahead := lookahead copyUsing: anIdentityDictionary!

Item was changed:
  RxmLink subclass: #RxmSubstring
+ 	instanceVariableNames: 'sampleStream ignoreCase'
- 	instanceVariableNames: 'sampleStream caseSensitive ignoreCase'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Regex-Core'!
  
  !RxmSubstring commentStamp: 'Tbn 11/12/2010 23:14' prior: 0!
  -- Regular Expression Matcher v 1.1 (C) 1996, 1999 Vassili Bykov
  --
  Instance holds onto a string and matches exactly this string, and exactly once.
  
  Instance variables:
  	string 	<String>!

Item was added:
+ ----- Method: RxmSubstring>>postCopy (in category 'copying') -----
+ postCopy
+ 
+ 	super postCopy.
+ 	sampleStream := sampleStream copy!

Item was added:
+ ----- Method: RxmSubstring>>postCopyUsing: (in category 'copying') -----
+ postCopyUsing: anIdentityDictionary
+ 
+ 	super postCopyUsing: anIdentityDictionary.
+ 	sampleStream := sampleStream copy!



More information about the Squeak-dev mailing list