[squeak-dev] The Inbox: Regex-Core-ct.66.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Aug 23 17:14:58 UTC 2021


As this version relates to minor refactoring already: Would there be any objections if I removed the license information from the class comments of the Regex package, or at least moved these notes to the bottom of the class comments? IMHO it pretty much leads the functionality of the annotation bar in code holder ad absurdum if you only can see that boring license text there:


[cid:338c462d-e72b-49d7-a160-5f645a53bd07]


This way it would read so much better:


[cid:59e25afa-0db2-4fbe-b678-13480f8e69ab]


I do not want to disregard Vassili's awesome work on this package. But we already see his name in the annotation bar of every original method and to be honest, I would prefer the package to read like Smalltalk code rather than like a legal text. :-)


[cid:9bee9fce-0d4c-4689-a573-83756209dad4]


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Montag, 23. August 2021 19:05:42
An: squeak-dev at lists.squeakfoundation.org
Betreff: [squeak-dev] The Inbox: Regex-Core-ct.66.mcz

A new version of Regex-Core was added to project The Inbox:
http://source.squeak.org/inbox/Regex-Core-ct.66.mcz

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

Name: Regex-Core-ct.66
Author: ct
Time: 23 August 2021, 7:05:38.221768 pm
UUID: 3ede3098-6d93-0049-bd36-5dd0461903d2
Ancestors: Regex-Core-mt.61

Adds convenience selectors for accessing subexpressions (#allSubexpressions and #subexpressionRanges:). The other changes contain some minor refactorings only.

=============== Diff against Regex-Core-mt.61 ===============

Item was added:
+ ----- Method: RxMatcher>>allSubexpressions (in category 'accessing') -----
+ allSubexpressions
+
+        ^ (1 to: self subexpressionCount) collect: [:index |
+                self subexpressions: index]!

Item was changed:
  ----- Method: RxMatcher>>hookBranchOf:onto: (in category 'private') -----
  hookBranchOf: regexNode onto: endMarker
+        "Private - Recurse down the chain of regexes starting at regexNode, compiling their branches and hooking their tails to the endMarker node."
-        "Private - Recurse down the chain of regexes starting at
-        regexNode, compiling their branches and hooking their tails
-        to the endMarker node."

+        | next rest |
+        next := (regexNode branch dispatchTo: self)
+                pointTailTo: endMarker;
+                yourself.
+        regexNode regex ifNil: [
+                "Avoid creating a branch without an alternative."
+                ^ next].
+
+        rest := self hookBranchOf: regexNode regex onto: endMarker.
+        ^ RxmBranch new
+                next: next;
+                alternative: rest;
+                yourself!
-        ^regexNode regex
-                ifNil: [ "Avoid creating a branch without an alternative."
-                        ^(regexNode branch dispatchTo: self)
-                                pointTailTo: endMarker;
-                                yourself ]
-                ifNotNil: [ :regex |
-                        | rest |
-                        rest := self hookBranchOf: regex onto: endMarker.
-                        ^RxmBranch new
-                                next: ((regexNode branch dispatchTo: self)
-                                        pointTailTo: endMarker;
-                                        yourself);
-                                alternative: rest;
-                                yourself ]
- !

Item was changed:
  ----- Method: RxMatcher>>subBeginning: (in category 'accessing') -----
  subBeginning: subIndex

         subIndex = 1 ifTrue: [
+                "beginning of root node"
+                ^ (markerPositions at: 1)
+                        ifNil: [#()]
+                        ifNotNil: [:mp | {mp}] ].
+
+        ^ markerPositions at: subIndex * 2 - 1!
-                (markerPositions at: 1)
-                        ifNil: [ ^#()]
-                        ifNotNil: [ :mp | ^{ mp } ] ].
-        ^markerPositions at: subIndex * 2 - 1!

Item was changed:
  ----- Method: RxMatcher>>subEnd: (in category 'accessing') -----
  subEnd: subIndex

         subIndex = 1 ifTrue: [
+                "end of root node"
+                ^ (markerPositions at: 2)
+                        ifNil: [#()]
+                        ifNotNil: [:mp | {mp}] ].
+
+        ^ markerPositions at: subIndex * 2!
-                (markerPositions at: 2)
-                        ifNil: [ ^#()]
-                        ifNotNil: [ :mp | ^{ mp } ] ].
-        ^markerPositions at: subIndex * 2!

Item was changed:
  ----- Method: RxMatcher>>subexpression: (in category 'accessing') -----
  subexpression: subIndex
         "Answer a string that matched the subexpression at the given index.
         If there are multiple matches, answer the last one.
         If there are no matches, answer nil.
         (NB: it used to answer an empty string but I think nil makes more sense)."

+        ^ (self subexpressions: subIndex)
+                ifNotEmpty: [:expressions | expressions last]
+                ifEmpty: [nil]!
-        | matches |
-        matches := self subexpressions: subIndex.
-        ^matches isEmpty ifTrue: [nil] ifFalse: [matches last]!

Item was added:
+ ----- Method: RxMatcher>>subexpressionRanges: (in category 'accessing') -----
+ subexpressionRanges: subIndex
+        "Answer an array of all match ranges of the subexpression at the given index."
+
+        ^ (self subBeginning: subIndex)
+                with: (self subEnd: subIndex)
+                collect: [:start :stop | start to: stop - 1]!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210823/03a3df7c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 4203 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210823/03a3df7c/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 4643 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210823/03a3df7c/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 25751 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210823/03a3df7c/attachment-0005.png>


More information about the Squeak-dev mailing list