author | Claus Gittinger <cg@exept.de> |
Tue, 21 Aug 2012 12:02:46 +0200 | |
changeset 14324 | 8cb871b96134 |
parent 14323 | fdf8a55d9414 |
child 14328 | 94db803c2ea9 |
permissions | -rw-r--r-- |
11965 | 1 |
"{ Package: 'stx:libbasic' }" |
2 |
||
3 |
ProgrammingLanguage subclass:#SmalltalkLanguage |
|
4 |
instanceVariableNames:'' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Kernel-Languages' |
|
8 |
! |
|
9 |
||
12100 | 10 |
!SmalltalkLanguage class methodsFor:'documentation'! |
11 |
||
12 |
documentation |
|
13 |
" |
|
14 |
provide info about which tools are to be used for smalltalk code |
|
15 |
" |
|
16 |
! ! |
|
11965 | 17 |
|
18 |
!SmalltalkLanguage methodsFor:'accessing'! |
|
19 |
||
20 |
name |
|
12098 | 21 |
"Answers a human-readable name of myself: |
22 |
'Smalltalk' for SmalltalkLanguage, |
|
23 |
'Ruby' for RubyLanguage |
|
24 |
..." |
|
11965 | 25 |
|
12502 | 26 |
^ 'Smalltalk' |
11965 | 27 |
|
28 |
"Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
29 |
! |
|
30 |
||
31 |
sourceFileSuffix |
|
12098 | 32 |
" |
33 |
Answers a default suffix for source files, i.e. |
|
34 |
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby' |
|
35 |
" |
|
11965 | 36 |
|
37 |
^'st' |
|
38 |
||
39 |
"Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
40 |
! ! |
|
41 |
||
42 |
!SmalltalkLanguage methodsFor:'accessing - classes'! |
|
43 |
||
13259 | 44 |
codeGeneratorClass |
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
45 |
"Answers a class that can generate code" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
46 |
|
13253
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
47 |
^ SmalltalkCodeGeneratorTool |
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
48 |
|
13259 | 49 |
"Created: / 30-01-2011 / 15:19:52 / cg" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
50 |
! |
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
51 |
|
11965 | 52 |
compilerClass |
12098 | 53 |
"Answer a class suitable for compiling a source code in 'my' language" |
11965 | 54 |
|
12098 | 55 |
^ Smalltalk::Compiler |
11965 | 56 |
|
57 |
"Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
58 |
! |
|
59 |
||
60 |
explainerClass |
|
12098 | 61 |
"Answers a class used by browser and debugger to |
62 |
show some hints about the code. It is OK to return |
|
63 |
nil, which means that there is no explainer for given language." |
|
11965 | 64 |
|
65 |
"return nil by default" |
|
12098 | 66 |
^ Smalltalk::Explainer |
11965 | 67 |
|
68 |
"Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
69 |
! |
|
70 |
||
12098 | 71 |
formatterClass |
72 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
73 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
74 |
||
75 |
^ Smalltalk::Parser |
|
76 |
! |
|
77 |
||
11965 | 78 |
parserClass |
12098 | 79 |
"Answer a class suitable for parsing a source codein 'my' language" |
11965 | 80 |
|
12098 | 81 |
^ Smalltalk::Parser |
11965 | 82 |
|
83 |
"Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
84 |
! |
|
85 |
||
86 |
sourceFileReaderClass |
|
12098 | 87 |
"Answers a class that can be used for reading & compiling source files" |
11965 | 88 |
|
89 |
^SmalltalkChunkFileSourceReader |
|
90 |
||
91 |
"Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
92 |
! |
|
93 |
||
94 |
sourceFileWriterClass |
|
12098 | 95 |
"Answers a class is used for source file writing (i.e. file-out)" |
11965 | 96 |
|
12107 | 97 |
^ SmalltalkChunkFileSourceWriter |
11965 | 98 |
|
99 |
"Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12098 | 100 |
! |
101 |
||
102 |
syntaxHighlighterClass |
|
103 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
104 |
this can be redefined in special classes, to highlight classes with |
|
105 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
106 |
||
107 |
^ Smalltalk::SyntaxHighlighter |
|
11965 | 108 |
! ! |
109 |
||
110 |
!SmalltalkLanguage methodsFor:'mimicry'! |
|
111 |
||
112 |
, anObject |
|
12098 | 113 |
"Emulates symbol behavior. This is sometimes required |
14069 | 114 |
as 'Smalltalk language' is used by legacy code to access |
115 |
the current language setting. |
|
116 |
Future versions should contain class Locale. |
|
11965 | 117 |
" |
12524 | 118 |
<resource: #obsolete> |
11965 | 119 |
|
12098 | 120 |
self breakPoint:#cg info:'should not be invoked'. |
12524 | 121 |
^ Language , anObject |
11965 | 122 |
|
123 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 124 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 125 |
! |
126 |
||
127 |
asSymbol |
|
12098 | 128 |
"Returns a language symbol. This is sometimes required |
129 |
as Smalltalk language is used by legacy code to access |
|
130 |
current language. Future versions should contain class |
|
131 |
Locale. |
|
11965 | 132 |
" |
12524 | 133 |
<resource: #obsolete> |
11965 | 134 |
|
12098 | 135 |
self breakPoint:#cg info:'should not be invoked'. |
12524 | 136 |
^ Language |
11965 | 137 |
|
138 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
139 |
! ! |
|
140 |
||
141 |
!SmalltalkLanguage methodsFor:'testing'! |
|
142 |
||
143 |
isSmalltalk |
|
12325 | 144 |
"true iff I represent the smalltalk language" |
11965 | 145 |
|
12325 | 146 |
^ true |
11965 | 147 |
|
148 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
149 |
! ! |
|
150 |
||
12150
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
151 |
!SmalltalkLanguage methodsFor:'utilities - source code'! |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
152 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
153 |
methodTemplate |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
154 |
"return a method definition template string" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
155 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
156 |
|s| |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
157 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
158 |
s := TextStream on:''. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
159 |
s nextPutAll: |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
160 |
'message selector and argument names |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
161 |
"comment stating purpose of this message" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
162 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
163 |
|temporaries| |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
164 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
165 |
statement. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
166 |
statement. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
167 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
168 |
" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
169 |
optional: comment giving example use |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
170 |
" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
171 |
'. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
172 |
s cr. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
173 |
s emphasis:(UserPreferences current commentEmphasisAndColor). |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
174 |
s nextPutAll: |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
175 |
'" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
176 |
change the above template into real code; |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
177 |
remove this comment. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
178 |
Then `accept'' either via the menu |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
179 |
or via the keyboard (usually CMD-A). |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
180 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
181 |
You do not need this template; you can also |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
182 |
select any existing methods code, change it, |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
183 |
and finally `accept''. The method will then be |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
184 |
installed under the selector as defined in the |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
185 |
actual text - no matter which method is selected |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
186 |
in the browser. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
187 |
|
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
188 |
Or clear this text, type in the method from scratch |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
189 |
and install it with `accept''. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
190 |
" |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
191 |
'. |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
192 |
^ s contents |
14323
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
193 |
! |
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
194 |
|
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
195 |
versionMethodTemplateForCVS |
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
196 |
"careful to avoid expansion by cvs here!!" |
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
197 |
|
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
198 |
^ ('version\ ^ ''$' , 'Header$''') withCRs |
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
199 |
|
fdf8a55d9414
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14069
diff
changeset
|
200 |
"Created: / 21-08-2012 / 11:52:27 / cg" |
12150
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
201 |
! ! |
fa89d3e7862d
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12107
diff
changeset
|
202 |
|
11965 | 203 |
!SmalltalkLanguage class methodsFor:'documentation'! |
204 |
||
205 |
version |
|
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
206 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.18 2012-08-21 10:02:46 cg Exp $' |
12047 | 207 |
! |
208 |
||
209 |
version_CVS |
|
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
210 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.18 2012-08-21 10:02:46 cg Exp $' |
12047 | 211 |
! |
212 |
||
213 |
version_SVN |
|
12180
e612aeccc282
update #version_SVN with § as keyword expansion character
fm
parents:
12150
diff
changeset
|
214 |
^'§Id: SmalltalkLanguage.st 10468 2009-08-22 08:34:50Z vranyj1 §' |
11965 | 215 |
! ! |