author | Claus Gittinger <cg@exept.de> |
Mon, 13 Jun 2016 14:27:54 +0200 | |
changeset 19985 | 19f838cc0bd5 |
parent 19973 | 7b5b9cf27f64 |
child 20079 | 8d884971c2ed |
child 21295 | a6f5e53be7f3 |
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 |
|
18874 | 57 |
^ Smalltalk at:#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 |
||
18874 | 66 |
^ ByteCodeCompilerWithBreakpointSupport |
15538 | 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" |
|
18874 | 77 |
^ 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 |
||
18874 | 86 |
^ Parser |
12098 | 87 |
! |
88 |
||
11965 | 89 |
parserClass |
19985 | 90 |
"Answer a class suitable for parsing a source code in 'my' language" |
11965 | 91 |
|
18874 | 92 |
^ 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 |
||
18874 | 118 |
^ 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. |
|
18925 | 128 |
cg: this is crab, who needs this? |
11965 | 129 |
" |
12524 | 130 |
<resource: #obsolete> |
11965 | 131 |
|
15898 | 132 |
self obsoleteMethodWarning. |
18925 | 133 |
^ Smalltalk language , anObject |
11965 | 134 |
|
135 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 136 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 137 |
! |
138 |
||
139 |
asSymbol |
|
12098 | 140 |
"Returns a language symbol. This is sometimes required |
141 |
as Smalltalk language is used by legacy code to access |
|
142 |
current language. Future versions should contain class |
|
143 |
Locale. |
|
18925 | 144 |
cg: this is crab, who needs this? |
11965 | 145 |
" |
12524 | 146 |
<resource: #obsolete> |
11965 | 147 |
|
15898 | 148 |
self obsoleteMethodWarning. |
18925 | 149 |
^ Smalltalk language |
11965 | 150 |
|
151 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
152 |
! ! |
|
153 |
||
14374 | 154 |
!SmalltalkLanguage methodsFor:'source queries'! |
155 |
||
16420 | 156 |
commentStrings |
157 |
^ #( |
|
158 |
'"/' "/ EOL comment |
|
159 |
('"' '"') "/ normal comment |
|
160 |
) |
|
161 |
! |
|
162 |
||
14374 | 163 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
164 |
"given a selector, return a prototype definition string" |
|
165 |
||
19973 | 166 |
(aSelector numArgs > 0 and:[aSelector numArgs = argNames size]) ifTrue:[ |
19893 | 167 |
aSelector isKeywordSelector ifTrue:[ |
19855 | 168 |
^ Text streamContents:[:stream | |
14374 | 169 |
aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
19855 | 170 |
stream bold; nextPutAll:eachKeyword; normal; nextPutAll:eachArgName; space. |
14374 | 171 |
]. |
172 |
stream backStep. "remove the last space" |
|
173 |
]. |
|
174 |
]. |
|
19855 | 175 |
^ aSelector allBold , ' ' , (argNames at:1) |
14374 | 176 |
]. |
19855 | 177 |
^ aSelector allBold |
14374 | 178 |
|
179 |
" |
|
180 |
SmalltalkLanguage instance |
|
181 |
methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
|
182 |
SmalltalkLanguage instance |
|
183 |
methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
|
184 |
SmalltalkLanguage instance |
|
185 |
methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
186 |
" |
|
187 |
! ! |
|
188 |
||
11965 | 189 |
!SmalltalkLanguage methodsFor:'testing'! |
190 |
||
191 |
isSmalltalk |
|
12325 | 192 |
"true iff I represent the smalltalk language" |
11965 | 193 |
|
12325 | 194 |
^ true |
11965 | 195 |
|
196 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
197 |
! ! |
|
198 |
||
199 |
!SmalltalkLanguage class methodsFor:'documentation'! |
|
200 |
||
201 |
version |
|
18874 | 202 |
^ '$Header$' |
12047 | 203 |
! |
204 |
||
205 |
version_CVS |
|
18874 | 206 |
^ '$Header$' |
12047 | 207 |
! |
208 |
||
209 |
version_SVN |
|
18874 | 210 |
^'$Id$' |
11965 | 211 |
! ! |
15538 | 212 |