-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatchToken.cls
96 lines (76 loc) · 2.61 KB
/
MatchToken.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"Filed out from Dolphin Smalltalk 7"!
Object subclass: #MatchToken
instanceVariableNames: 'string start stop'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
MatchToken guid: (GUID fromString: '{ac4831ee-87bf-4c98-a3e7-3d962ed2e1a4}')!
MatchToken comment: ''!
!MatchToken categoriesForClass!Unclassified! !
!MatchToken methodsFor!
asString
^string copyFrom: start to: stop!
at: i
^string at: i!
beginsWith: aMatchToken
self length >= aMatchToken length ifFalse: [^false].
aMatchToken start to: aMatchToken stop do: [:i | | char |
char := aMatchToken at: i.
((self at: start + i - 1) = char or: [char isQuestionMark]) ifFalse: [^false]].
^true
!
endsWith: aMatchToken
| end |
self length >= aMatchToken length ifFalse: [^false].
end := aMatchToken stop.
end to: aMatchToken start by: -1 do: [:i | | char |
char := aMatchToken at: i.
((self at: stop - end + i) = char or: [char isQuestionMark]) ifFalse: [^false]].
^true!
indexOf: aMatchToken
^string indexOfString: aMatchToken asString from: start to: stop!
length
^stop - start + 1!
matchFirstAfterStartOn: aMatchAlgorithm
aMatchAlgorithm matchFirstTokenAfterStar!
matchFirstOn: aMatchAlgorithm
aMatchAlgorithm matchFirstToken!
matchLastOn: aMatchAlgorithm
aMatchAlgorithm matchLastToken!
printOn: aStream
start to: stop do: [:i | aStream nextPut: (string at: i)]!
start
^start!
start: anInteger
start := anInteger!
stop
^stop!
stop: anInteger
stop := anInteger!
string
^string!
string: aString
string := aString! !
!MatchToken categoriesFor: #asString!converting!public! !
!MatchToken categoriesFor: #at:!accessing!public! !
!MatchToken categoriesFor: #beginsWith:!inquiries!public! !
!MatchToken categoriesFor: #endsWith:!inquiries!public! !
!MatchToken categoriesFor: #indexOf:!inquiries!public! !
!MatchToken categoriesFor: #length!inquiries!public! !
!MatchToken categoriesFor: #matchFirstAfterStartOn:!double dispatching!public! !
!MatchToken categoriesFor: #matchFirstOn:!double dispatching!public! !
!MatchToken categoriesFor: #matchLastOn:!double dispatching!public! !
!MatchToken categoriesFor: #printOn:!printing!public! !
!MatchToken categoriesFor: #start!accessing!public! !
!MatchToken categoriesFor: #start:!accessing!public! !
!MatchToken categoriesFor: #stop!accessing!public! !
!MatchToken categoriesFor: #stop:!accessing!public! !
!MatchToken categoriesFor: #string!accessing!public! !
!MatchToken categoriesFor: #string:!accessing!public! !
!MatchToken class methodsFor!
on: aString from: start to: stop
^self new
string: aString;
start: start;
stop: stop! !
!MatchToken class categoriesFor: #on:from:to:!public! !