-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide an edit script to map cCode: 'func(...)''s to the new _: style.
- Loading branch information
1 parent
bdb4f47
commit 76ccea7
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Extension { #name : #String } | ||
|
||
{ #category : #'*Cog-script support' } | ||
String >> extractSelector [ | ||
"Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, | ||
in most cases it does what we want, and where it doesn't, we're none the worse for it. | ||
Unlike findSelector this doesn't require that the poutative selector has been interned." | ||
| sel possibleParens | | ||
sel := self withBlanksTrimmed. | ||
(sel includes: $:) ifTrue: | ||
[sel := sel copyReplaceAll: ':' with: ': '. "for the style (aa max:bb) with no space" | ||
sel := sel copyReplaceAll: '[:' with: '[ :'. "for the style ([:a) with no space" | ||
possibleParens := sel findTokens: Character separators. | ||
sel := self class streamContents: | ||
[:s | | level | | ||
level := 0. | ||
possibleParens do: | ||
[:token | | ||
(level = 0 and: [token endsWith: ':']) | ||
ifTrue: [s nextPutAll: token] | ||
ifFalse: [level := level | ||
+ (token occurrencesOf: $() - (token occurrencesOf: $)) | ||
+ (token occurrencesOf: $[) - (token occurrencesOf: $]) | ||
+ (token occurrencesOf: ${) - (token occurrencesOf: $})]]]]. | ||
sel isEmpty ifTrue: [^ nil]. | ||
^sel | ||
] |