author | Jan Vrany <jan.vrany@labware.com> |
Sat, 29 Oct 2022 01:05:05 +0100 | |
branch | jv |
changeset 25446 | 98fb817db6de |
parent 25413 | 565bf29e3a20 |
permissions | -rw-r--r-- |
21295 | 1 |
" |
2 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
23107 | 3 |
COPYRIGHT (c) 2009 Jan Vrany |
4 |
COPYRIGHT (c) 2011 Jan Vrany |
|
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
5 |
COPYRIGHT (c) 2021 LabWare |
21295 | 6 |
All Rights Reserved |
7 |
||
8 |
This software is furnished under a license and may be used |
|
9 |
only in accordance with the terms of that license and with the |
|
10 |
inclusion of the above copyright notice. This software may not |
|
11 |
be provided or otherwise made available to, or used by, any |
|
12 |
other person. No title to or ownership of the software is |
|
13 |
hereby transferred. |
|
14 |
" |
|
11965 | 15 |
"{ Package: 'stx:libbasic' }" |
16 |
||
17449 | 17 |
"{ NameSpace: Smalltalk }" |
18 |
||
11965 | 19 |
ProgrammingLanguage subclass:#SmalltalkLanguage |
20 |
instanceVariableNames:'' |
|
21 |
classVariableNames:'' |
|
22 |
poolDictionaries:'' |
|
23 |
category:'Kernel-Languages' |
|
24 |
! |
|
25 |
||
12100 | 26 |
!SmalltalkLanguage class methodsFor:'documentation'! |
27 |
||
21295 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
23107 | 31 |
COPYRIGHT (c) 2009 Jan Vrany |
32 |
COPYRIGHT (c) 2011 Jan Vrany |
|
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
33 |
COPYRIGHT (c) 2021 LabWare |
21295 | 34 |
All Rights Reserved |
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
44 |
||
12100 | 45 |
documentation |
46 |
" |
|
47 |
provide info about which tools are to be used for smalltalk code |
|
48 |
" |
|
49 |
! ! |
|
11965 | 50 |
|
51 |
!SmalltalkLanguage methodsFor:'accessing'! |
|
52 |
||
53 |
name |
|
12098 | 54 |
"Answers a human-readable name of myself: |
55 |
'Smalltalk' for SmalltalkLanguage, |
|
56 |
'Ruby' for RubyLanguage |
|
57 |
..." |
|
11965 | 58 |
|
12502 | 59 |
^ 'Smalltalk' |
11965 | 60 |
|
61 |
"Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
62 |
! |
|
63 |
||
64 |
sourceFileSuffix |
|
12098 | 65 |
" |
66 |
Answers a default suffix for source files, i.e. |
|
67 |
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby' |
|
68 |
" |
|
11965 | 69 |
|
70 |
^'st' |
|
71 |
||
72 |
"Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
73 |
! ! |
|
74 |
||
17449 | 75 |
!SmalltalkLanguage methodsFor:'accessing-classes'! |
11965 | 76 |
|
13259 | 77 |
codeGeneratorClass |
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
78 |
"Answers a class that can generate code" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
79 |
|
13253
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
80 |
^ SmalltalkCodeGeneratorTool |
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
81 |
|
13259 | 82 |
"Created: / 30-01-2011 / 15:19:52 / cg" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
83 |
! |
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
84 |
|
11965 | 85 |
compilerClass |
12098 | 86 |
"Answer a class suitable for compiling a source code in 'my' language" |
11965 | 87 |
|
18874 | 88 |
^ Smalltalk at:#Compiler |
11965 | 89 |
|
90 |
"Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
91 |
! |
|
92 |
||
15538 | 93 |
compilerWithBreakpointSupportClass |
94 |
"Answer a class suitable for compiling a source code with breakpoints |
|
95 |
in 'my' language" |
|
96 |
||
18874 | 97 |
^ ByteCodeCompilerWithBreakpointSupport |
15538 | 98 |
|
99 |
"Created: / 22-07-2013 / 15:46:12 / cg" |
|
100 |
! |
|
101 |
||
11965 | 102 |
explainerClass |
12098 | 103 |
"Answers a class used by browser and debugger to |
104 |
show some hints about the code. It is OK to return |
|
105 |
nil, which means that there is no explainer for given language." |
|
11965 | 106 |
|
107 |
"return nil by default" |
|
18874 | 108 |
^ Explainer |
11965 | 109 |
|
110 |
"Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
111 |
! |
|
112 |
||
12098 | 113 |
formatterClass |
114 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
115 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
116 |
||
18874 | 117 |
^ Parser |
12098 | 118 |
! |
119 |
||
11965 | 120 |
parserClass |
19985 | 121 |
"Answer a class suitable for parsing a source code in 'my' language" |
11965 | 122 |
|
18874 | 123 |
^ Parser |
11965 | 124 |
|
125 |
"Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
126 |
! |
|
127 |
||
128 |
sourceFileReaderClass |
|
12098 | 129 |
"Answers a class that can be used for reading & compiling source files" |
11965 | 130 |
|
131 |
^SmalltalkChunkFileSourceReader |
|
132 |
||
133 |
"Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
134 |
! |
|
135 |
||
136 |
sourceFileWriterClass |
|
12098 | 137 |
"Answers a class is used for source file writing (i.e. file-out)" |
11965 | 138 |
|
12107 | 139 |
^ SmalltalkChunkFileSourceWriter |
11965 | 140 |
|
141 |
"Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12098 | 142 |
! |
143 |
||
144 |
syntaxHighlighterClass |
|
145 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
146 |
this can be redefined in special classes, to highlight classes with |
|
147 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
148 |
||
18874 | 149 |
^ SyntaxHighlighter |
11965 | 150 |
! ! |
151 |
||
152 |
!SmalltalkLanguage methodsFor:'mimicry'! |
|
153 |
||
154 |
, anObject |
|
12098 | 155 |
"Emulates symbol behavior. This is sometimes required |
14069 | 156 |
as 'Smalltalk language' is used by legacy code to access |
157 |
the current language setting. |
|
158 |
Future versions should contain class Locale. |
|
18925 | 159 |
cg: this is crab, who needs this? |
11965 | 160 |
" |
12524 | 161 |
<resource: #obsolete> |
11965 | 162 |
|
15898 | 163 |
self obsoleteMethodWarning. |
18925 | 164 |
^ Smalltalk language , anObject |
11965 | 165 |
|
166 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 167 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 168 |
! |
169 |
||
170 |
asSymbol |
|
12098 | 171 |
"Returns a language symbol. This is sometimes required |
172 |
as Smalltalk language is used by legacy code to access |
|
173 |
current language. Future versions should contain class |
|
174 |
Locale. |
|
18925 | 175 |
cg: this is crab, who needs this? |
11965 | 176 |
" |
12524 | 177 |
<resource: #obsolete> |
11965 | 178 |
|
15898 | 179 |
self obsoleteMethodWarning. |
18925 | 180 |
^ Smalltalk language |
11965 | 181 |
|
182 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
183 |
! ! |
|
184 |
||
14374 | 185 |
!SmalltalkLanguage methodsFor:'source queries'! |
186 |
||
16420 | 187 |
commentStrings |
188 |
^ #( |
|
189 |
'"/' "/ EOL comment |
|
190 |
('"' '"') "/ normal comment |
|
191 |
) |
|
192 |
! |
|
193 |
||
14374 | 194 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
195 |
"given a selector, return a prototype definition string" |
|
196 |
||
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
197 |
| spaceAfterKeyword | |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
198 |
|
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
199 |
spaceAfterKeyword := (Smalltalk includesKey: #RBFormatter) |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
200 |
ifTrue: [ (Smalltalk at: #RBFormatter) spaceAfterKeywordSelector ] |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
201 |
ifFalse:[ false "Smalltalk/X default" ]. |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
202 |
|
19973 | 203 |
(aSelector numArgs > 0 and:[aSelector numArgs = argNames size]) ifTrue:[ |
19893 | 204 |
aSelector isKeywordSelector ifTrue:[ |
19855 | 205 |
^ Text streamContents:[:stream | |
14374 | 206 |
aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
207 |
stream bold; nextPutAll:eachKeyword; normal. |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
208 |
spaceAfterKeyword ifTrue: [ |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
209 |
stream space. |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
210 |
]. |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
211 |
stream nextPutAll:eachArgName; space. |
14374 | 212 |
]. |
213 |
stream backStep. "remove the last space" |
|
214 |
]. |
|
215 |
]. |
|
19855 | 216 |
^ aSelector allBold , ' ' , (argNames at:1) |
14374 | 217 |
]. |
19855 | 218 |
^ aSelector allBold |
14374 | 219 |
|
220 |
" |
|
221 |
SmalltalkLanguage instance |
|
222 |
methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
|
223 |
SmalltalkLanguage instance |
|
224 |
methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
|
225 |
SmalltalkLanguage instance |
|
226 |
methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
227 |
" |
|
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
228 |
|
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
229 |
"Modified: / 05-05-2021 / 10:38:23 / Jan Vrany <jan.vrany@labware.com>" |
14374 | 230 |
! ! |
231 |
||
11965 | 232 |
!SmalltalkLanguage methodsFor:'testing'! |
233 |
||
234 |
isSmalltalk |
|
12325 | 235 |
"true iff I represent the smalltalk language" |
11965 | 236 |
|
12325 | 237 |
^ true |
11965 | 238 |
|
239 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
240 |
! ! |
|
241 |
||
242 |
!SmalltalkLanguage class methodsFor:'documentation'! |
|
243 |
||
244 |
version |
|
18874 | 245 |
^ '$Header$' |
12047 | 246 |
! |
247 |
||
248 |
version_CVS |
|
18874 | 249 |
^ '$Header$' |
12047 | 250 |
! |
251 |
||
25413
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
252 |
version_HG |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
253 |
|
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
254 |
^ '$Changeset: <not expanded> $' |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
255 |
! |
565bf29e3a20
Honour formatter settings in `SmalltalkLanguage >> #methodDefinitionTemplate...`
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
256 |
|
12047 | 257 |
version_SVN |
18874 | 258 |
^'$Id$' |
11965 | 259 |
! ! |
15538 | 260 |