SmalltalkLanguage.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 24 Oct 2009 16:48:19 +0100
branchjv
changeset 17732 a1892eeca6c0
parent 17729 4187f74d2df8
child 17734 406b1590afe8
permissions -rw-r--r--
trunk merged into jv branch

"{ Package: 'stx:libbasic' }"

ProgrammingLanguage subclass:#SmalltalkLanguage
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Languages'
!

!SmalltalkLanguage class methodsFor:'documentation'!

documentation
"
    provide info about which tools are to be used for smalltalk code
"
! !

!SmalltalkLanguage methodsFor:'accessing'!

name
    "Answers a human-readable name of myself:
     'Smalltalk' for SmalltalkLanguage,
     'Ruby' for RubyLanguage
     ..."

    ^'Smalltalk'

    "Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileSuffix
    "
     Answers a default suffix for source files, i.e.
     'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby'
    "

    ^'st'

    "Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage methodsFor:'accessing - classes'!

compilerClass
    "Answer a class suitable for compiling a source code in 'my' language"

    ^ Smalltalk::Compiler

    "Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

explainerClass
    "Answers a class used by browser and debugger to
     show some hints about the code. It is OK to return
     nil, which means that there is no explainer for given language."

    "return nil by default"
    ^ Smalltalk::Explainer

    "Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

formatterClass
    "Answer a class suitable for prettyPrinting (indenting) code in 'my' language.
     It is ok to return nil, which means that the browser will not be able to prettyprint."

    ^ Smalltalk::Parser
!

parserClass
    "Answer a class suitable for parsing a source codein 'my' language"

    ^ Smalltalk::Parser

    "Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileReaderClass
    "Answers a class that can be used for reading & compiling source files"

    ^SmalltalkChunkFileSourceReader

    "Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileWriterClass
    "Answers a class is used for source file writing (i.e. file-out)"

    ^ SmalltalkChunkFileSourceWriter

    "Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

syntaxHighlighterClass
    "return the class to use for syntaxHighlighting (prettyPrinting) this class -
     this can be redefined in special classes, to highlight classes with
     Lisp, Prolog, ASN1, Basic :-) or whatever syntax."

    ^ Smalltalk::SyntaxHighlighter
! !

!SmalltalkLanguage methodsFor:'mimicry'!

, anObject
    "Emulates symbol behavior. This is sometimes required
     as Smalltalk language is used by legacy code to access
     current language. Future versions should contain class
     Locale.
    "

    self breakPoint:#cg info:'should not be invoked'.
    ^Language , anObject

    "Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

asSymbol
    "Returns a language symbol. This is sometimes required
     as Smalltalk language is used by legacy code to access
     current language. Future versions should contain class
     Locale.
    "

    self breakPoint:#cg info:'should not be invoked'.
    ^Language

    "Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage methodsFor:'testing'!

isSmalltalk

    ^true

    "Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage methodsFor:'utilities - source code'!

methodTemplate
    "return a method definition template string"

    |s|

    s := TextStream on:''.
    s nextPutAll:
'message selector and argument names
    "comment stating purpose of this message"

    |temporaries|

    statement.
    statement.

    "
     optional: comment giving example use
    "
'.
    s cr.
    s emphasis:(UserPreferences current commentEmphasisAndColor).
    s nextPutAll:
'"
 change the above template into real code;
 remove this comment.
 Then `accept'' either via the menu 
 or via the keyboard (usually CMD-A).

 You do not need this template; you can also
 select any existing methods code, change it,
 and finally `accept''. The method will then be
 installed under the selector as defined in the
 actual text - no matter which method is selected
 in the browser.

 Or clear this text, type in the method from scratch
 and install it with `accept''.
"
'.
    ^ s contents
! !

!SmalltalkLanguage class methodsFor:'documentation'!

version
    ^ '$Id: SmalltalkLanguage.st 10473 2009-10-24 15:48:19Z vranyj1 $'
!

version_CVS
    ^ '§Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.9 2009/10/08 11:59:18 fm Exp §'
!

version_SVN
    ^ '$Id: SmalltalkLanguage.st 10473 2009-10-24 15:48:19Z vranyj1 $'
! !