author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 2015 13:42:28 +0200 | |
changeset 18449 | 48c31fe80359 |
parent 17450 | 04a2f19e5410 |
child 18120 | e3a375d5f6a8 |
child 18874 | 10019643078f |
permissions | -rw-r--r-- |
11965 | 1 |
"{ Package: 'stx:libbasic' }" |
2 |
||
17449 | 3 |
"{ NameSpace: Smalltalk }" |
4 |
||
11965 | 5 |
ProgrammingLanguage subclass:#SmalltalkLanguage |
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Kernel-Languages' |
|
10 |
! |
|
11 |
||
12100 | 12 |
!SmalltalkLanguage class methodsFor:'documentation'! |
13 |
||
14 |
documentation |
|
15 |
" |
|
16 |
provide info about which tools are to be used for smalltalk code |
|
17 |
" |
|
18 |
! ! |
|
11965 | 19 |
|
20 |
!SmalltalkLanguage methodsFor:'accessing'! |
|
21 |
||
22 |
name |
|
12098 | 23 |
"Answers a human-readable name of myself: |
24 |
'Smalltalk' for SmalltalkLanguage, |
|
25 |
'Ruby' for RubyLanguage |
|
26 |
..." |
|
11965 | 27 |
|
12502 | 28 |
^ 'Smalltalk' |
11965 | 29 |
|
30 |
"Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
31 |
! |
|
32 |
||
33 |
sourceFileSuffix |
|
12098 | 34 |
" |
35 |
Answers a default suffix for source files, i.e. |
|
36 |
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby' |
|
37 |
" |
|
11965 | 38 |
|
39 |
^'st' |
|
40 |
||
41 |
"Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
42 |
! ! |
|
43 |
||
17449 | 44 |
!SmalltalkLanguage methodsFor:'accessing-classes'! |
11965 | 45 |
|
13259 | 46 |
codeGeneratorClass |
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
47 |
"Answers a class that can generate code" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
48 |
|
13253
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
49 |
^ SmalltalkCodeGeneratorTool |
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
50 |
|
13259 | 51 |
"Created: / 30-01-2011 / 15:19:52 / cg" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
52 |
! |
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
53 |
|
11965 | 54 |
compilerClass |
12098 | 55 |
"Answer a class suitable for compiling a source code in 'my' language" |
11965 | 56 |
|
12098 | 57 |
^ Smalltalk::Compiler |
11965 | 58 |
|
59 |
"Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
60 |
! |
|
61 |
||
15538 | 62 |
compilerWithBreakpointSupportClass |
63 |
"Answer a class suitable for compiling a source code with breakpoints |
|
64 |
in 'my' language" |
|
65 |
||
66 |
^ Smalltalk::ByteCodeCompilerWithBreakpointSupport |
|
67 |
||
68 |
"Created: / 22-07-2013 / 15:46:12 / cg" |
|
69 |
! |
|
70 |
||
11965 | 71 |
explainerClass |
12098 | 72 |
"Answers a class used by browser and debugger to |
73 |
show some hints about the code. It is OK to return |
|
74 |
nil, which means that there is no explainer for given language." |
|
11965 | 75 |
|
76 |
"return nil by default" |
|
12098 | 77 |
^ Smalltalk::Explainer |
11965 | 78 |
|
79 |
"Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
80 |
! |
|
81 |
||
12098 | 82 |
formatterClass |
83 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
84 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
85 |
||
86 |
^ Smalltalk::Parser |
|
87 |
! |
|
88 |
||
11965 | 89 |
parserClass |
12098 | 90 |
"Answer a class suitable for parsing a source codein 'my' language" |
11965 | 91 |
|
12098 | 92 |
^ Smalltalk::Parser |
11965 | 93 |
|
94 |
"Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
95 |
! |
|
96 |
||
97 |
sourceFileReaderClass |
|
12098 | 98 |
"Answers a class that can be used for reading & compiling source files" |
11965 | 99 |
|
100 |
^SmalltalkChunkFileSourceReader |
|
101 |
||
102 |
"Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
103 |
! |
|
104 |
||
105 |
sourceFileWriterClass |
|
12098 | 106 |
"Answers a class is used for source file writing (i.e. file-out)" |
11965 | 107 |
|
12107 | 108 |
^ SmalltalkChunkFileSourceWriter |
11965 | 109 |
|
110 |
"Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12098 | 111 |
! |
112 |
||
113 |
syntaxHighlighterClass |
|
114 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
115 |
this can be redefined in special classes, to highlight classes with |
|
116 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
117 |
||
118 |
^ Smalltalk::SyntaxHighlighter |
|
11965 | 119 |
! ! |
120 |
||
121 |
!SmalltalkLanguage methodsFor:'mimicry'! |
|
122 |
||
123 |
, anObject |
|
12098 | 124 |
"Emulates symbol behavior. This is sometimes required |
14069 | 125 |
as 'Smalltalk language' is used by legacy code to access |
126 |
the current language setting. |
|
127 |
Future versions should contain class Locale. |
|
11965 | 128 |
" |
12524 | 129 |
<resource: #obsolete> |
11965 | 130 |
|
15898 | 131 |
self obsoleteMethodWarning. |
12524 | 132 |
^ Language , anObject |
11965 | 133 |
|
134 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 135 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 136 |
! |
137 |
||
138 |
asSymbol |
|
12098 | 139 |
"Returns a language symbol. This is sometimes required |
140 |
as Smalltalk language is used by legacy code to access |
|
141 |
current language. Future versions should contain class |
|
142 |
Locale. |
|
11965 | 143 |
" |
12524 | 144 |
<resource: #obsolete> |
11965 | 145 |
|
15898 | 146 |
self obsoleteMethodWarning. |
12524 | 147 |
^ Language |
11965 | 148 |
|
149 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
150 |
! ! |
|
151 |
||
14374 | 152 |
!SmalltalkLanguage methodsFor:'source queries'! |
153 |
||
16420 | 154 |
commentStrings |
155 |
^ #( |
|
156 |
'"/' "/ EOL comment |
|
157 |
('"' '"') "/ normal comment |
|
158 |
) |
|
159 |
! |
|
160 |
||
14374 | 161 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
162 |
"given a selector, return a prototype definition string" |
|
163 |
||
164 |
aSelector numArgs > 0 ifTrue:[ |
|
165 |
aSelector isKeyword ifTrue:[ |
|
166 |
^ String streamContents:[:stream | |
|
167 |
aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
|
168 |
stream nextPutAll:eachKeyword; nextPutAll:eachArgName; space. |
|
169 |
]. |
|
170 |
stream backStep. "remove the last space" |
|
171 |
]. |
|
172 |
]. |
|
173 |
^ aSelector , ' ' , (argNames at:1) |
|
174 |
]. |
|
175 |
^ aSelector |
|
176 |
||
177 |
" |
|
178 |
SmalltalkLanguage instance |
|
179 |
methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
|
180 |
SmalltalkLanguage instance |
|
181 |
methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
|
182 |
SmalltalkLanguage instance |
|
183 |
methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
184 |
" |
|
185 |
! ! |
|
186 |
||
11965 | 187 |
!SmalltalkLanguage methodsFor:'testing'! |
188 |
||
189 |
isSmalltalk |
|
12325 | 190 |
"true iff I represent the smalltalk language" |
11965 | 191 |
|
12325 | 192 |
^ true |
11965 | 193 |
|
194 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
195 |
! ! |
|
196 |
||
197 |
!SmalltalkLanguage class methodsFor:'documentation'! |
|
198 |
||
199 |
version |
|
17450 | 200 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.25 2015-02-08 03:40:46 cg Exp $' |
12047 | 201 |
! |
202 |
||
203 |
version_CVS |
|
17450 | 204 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.25 2015-02-08 03:40:46 cg Exp $' |
12047 | 205 |
! |
206 |
||
207 |
version_SVN |
|
17450 | 208 |
^'$Id: SmalltalkLanguage.st,v 1.25 2015-02-08 03:40:46 cg Exp $' |
11965 | 209 |
! ! |
15538 | 210 |