eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ProgrammingLanguage':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ProgrammingLanguage


Inheritance:

   Object
   |
   +--ProgrammingLanguage
      |
      +--STXJavaScriptLanguage
      |
      +--SmalltalkLanguage

Package:
stx:libbasic
Category:
Kernel-Languages
Version:
rev: 1.60 date: 2023/01/26 14:27:18
user: cg
file: ProgrammingLanguage.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


provide info about which tools are to be used for code in
a programming language

copyright

COPYRIGHT (c) 2006 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

Signal constants
o  languageQuerySignal

accessing
o  all
Anwers a collection of all available languages

Usage example(s):

     ProgrammingLanguage all

o  allSortedByNameExcept: filterBlock
Anwers a collection of all available languages

Usage example(s):

     ProgrammingLanguage allSortedByNameExcept:#isSmalltalk

o  current
ProgrammingLanguage current

o  instance
return this language's singleton

enumerating
o  allDetect: aBlock ifNone: exceptionValue

o  allDo: aBlock
ProgrammingLanguage allDo:[:l | Transcript showCR:l ]

initialization
o  initialize
(comment from inherited method)
called only once - initialize signals

instance creation
o  forFile: aFilename
Answers a language for given source file. If none is found,
SmalltalkLanguage is returned (to provide backward compatibility)

o  forStream: aStream
Answers a language for given source stream. If none is found,
SmalltalkLanguage is returned (to provide backward compatibility)

o  named: aString
ProgrammingLanguage named: 'Smalltalk'
ProgrammingLanguage named: 'JavaScript'
ProgrammingLanguage named: 'Ruby'

o  named: aString ifNone: aBlock

private
o  instancesDetect: detectBlock ifNone: failBlock
detect a langauge instance for which detectBlock returns true;
failBlock otherwise

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.

testing
o  isAvailable: langName
ProgrammingLanguage isAvailable: 'Smalltalk'
ProgrammingLanguage isAvailable: 'Ruby'
ProgrammingLanguage isAvailable: 'Haskell'


Instance protocol:

accessing
o  id
Return a unique integer id of this language.
For languages built into the VM, it must be < 32.
This id is used as index to various structures used by runtime
(bytecode set ?).
cg: this ought to be better documented - I have no idea, where it is used

** This method must be redefined in concrete classes (subclassResponsibility) **

o  imports
To make it polymorph with NameSpace for
selector-namespace enabled systems

o  lookup

o  name
Answers a human-readable name of myself:
'Smalltalk' for SmalltalkLanguage,
'Ruby' for RubyLanguage
...
Here, a fallback using the class name is generated.

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  toolbox
( an extension from the stx:libtool package )
Answer a toolbox for receiver. A toolbox is used by language-agnostic tools (such as
class browser) to perform language-specific tasks (search for implementors,
build implementor menu and so on. If nil is returned, no toolbox available

accessing-classes
o  codeGeneratorClass
Answer a class suitable for generating code (such as getters, setters, etc.)
It is ok to return nil, which means that no code can be generated automagically

o  compilerClass
Answer a class suitable for compiling a source code in 'my' language.
If nil is returned, no compiler is available (eg. language is for editors only)

o  compilerClassForInteractiveTools
Answer a compiler class suitable for usage in interactive tools.
Such class may better integrate into the IDE and register for undo/redo
and/or do more checks and so on. Defaults to #compilerClass

o  compilerWithBreakpointSupportClass
Answer a class suitable for compiling a source code with breakpoints
in 'my' language. If there is none, return nil.

o  evaluatorClass
Answer a class suitable for evaluating a doIt in 'my' language

o  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.

o  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.

o  lookupClass

o  metaClass
will be used for new classes (in the class wizard);
a fallback here

o  parserClass
Answer a class suitable for parsing a source code in 'my' language

** This method must be redefined in concrete classes (subclassResponsibility) **

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

** This method must be redefined in concrete classes (subclassResponsibility) **

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

** This method must be redefined in concrete classes (subclassResponsibility) **

o  syntaxHighlighterClass
Answers a class used by browser and debugger to colorize code.
It is OK to return nil, which means that the code is shown as-is

o  toolboxClass
( an extension from the stx:libtool package )
Answer a 'toolbox class'. A toolbox is used by language-agnostic tools (such as
class browser) to perform language-specific tasks (search for implementors,
build implementor menu and so on. If nil is returned, no toolbox available

o  valuePrinterClass
Answers a class used by the workspace to print a value.
If nil, the regular printOn: method is called on the result object.
If provided, it should respond to printStringForPrintItOf:result

displaying
o  displayString
( an extension from the stx:libtool package )
(comment from inherited method)
return a string used when displaying the receiver in a view;
for example an Inspector. This is usually the same as printString,
but sometimes redefined for a better look.

Notice: displayString and displayOn: are for developers, debugging and inspectors,
whereas printString and printOn: are for the program to print data.

Note: the base method (used by the inspector) is #displayOn:.
So you should implement #displayOn: instead of #displayString in subclasses.

printing & storing
o  printOn: aStream
append a printed representation of the receiver to the argument, aStream

o  storeOn: aStream
ProgrammingLanguage instance storeString

SmalltalkLanguage instance storeString

queries
o  canBeCompiled
true if compilable in the browser

o  canReadSourceFile: aFilename
Answers true iff file contains source code in 'my' language

o  defaultSelectorNameSpacePrefix
no namespace by default"

o  supportsExtensionMethods
Answer true iff this language supports extension methods

source queries
o  bracketStrings
used for autoindent

o  commentStrings
EOL comment

o  methodDefinitionTemplateForSelector: aSelector
given a selector, return a prototype definition string

Usage example(s):

     SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo
     SmalltalkLanguage instance methodDefinitionTemplateForSelector:#+
     SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo:bar:baz:

o  methodDefinitionTemplateForSelector: arg1 andArgumentNames: arg2
raise an error: must be redefined in concrete subclass(es)

** This method must be redefined in concrete classes (subclassResponsibility) **

testing
o  isC
true iff this is the C language

o  isGroovy
true iff this is the Groovy language

o  isJava
true iff this is the Java language

o  isJavaLike
true if receiver is kind of Java language (based on Java)

o  isProgrammingLanguage
(comment from inherited method)
return true if the receiver is a programming language.
False is returned here - the method is only redefined in
ProgrammingLanguage.

o  isPython
true iff this is the python language

o  isRuby
true iff this is the ruby language

o  isSTXJavaScript
true iff this is the ST/X-javascript language

o  isSmalltalk
true iff this is the smalltalk language

utilities - file in/file out
o  fileIn: aFilenameOrString

o  fileInStream: aStream

utilities - source code
o  methodSourceForVersionMethodCVS: versionString

o  methodTemplate
return a method definition template string (or nil)

Usage example(s):

^ writerClass methodTemplate

o  methodTemplateForDocumentation
return a documentation method definition template string (or nil)

o  methodTemplateForPackageDocumentation
return a documentation method definition template string (or nil) for packages

o  methodTemplateForVersionMethodCVS

o  parenthesisSpecificationForEditor
return the dictionary which specifies which characters are opening,
which are closing and which are ignored characters w.r.t. parenthesis matching.
See comments in TextView on how this is used.

o  versionMethodTemplateForCVS
raise an error: must be redefined in concrete subclass(es)

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  writeComment: aStringOrStringCollection on: aStream
Utility method - writes a comment to a stream,
using proper syntax



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 14 Oct 2024 01:23:17 GMT