Pascal To Smalltalk
Pascal To Smalltalk
Macintosh · PDF
| Filename | Pascal_to_Smalltalk_19850411.pdf |
|---|---|
| Size | 0.28 MB |
| Subsection | developer / MacApp |
| Downloads | 0 |
Contents
Pascal to Smalltalk
Barry Haynes
April 11, 1985
Current Status
A new class, PascalCodeParser has been created. lt is a subclass of Parser that
parses Pascal source code to produce a Smalltalk parse tree. From this parse tree,
Smalltalk source is created and each method is added to the Smalltalk class that
should include that method. Currently, the user must create the Smalltalk class
manually. All methods are automatically placed in a category called pascal
source. PascalCodeParser can now handle parsing procedures and functions
and converting Pascal formal parameters into Smalltalk keyword parameters. lt
converts simple local variables from Pascal to Smalltalk. Pascal expressions and
assignment statements are correctly converted into equivalent Smalltalk
statements. Handling function return results is also implemented.
At this point, we know the basic conversion mechanism works. All that is required
·to do complete conversion from Pascal to Smalltalk is Smalltalk methods and a
scheme for each of the parts of the Pascal railroad diagrams that have not yet been ·
implemented. The rest of this memo deals with these issues and problems that
must be resolved to finish the job.
lssues for the Rest of the Conversion
1. In general it is assumed the Object Pascal that is being translated has been
compiled, has no syntax errors and is correct, complete Object Pascal in every
way.
2.lt will be assumed that real numbers are not used in the Pascal that is being
translated.
·
3.Globals could be handled in the following way. For MacApp itself, global
variables and constants can be added as class variables to class TObject. For
the case of constants, code will be added to TObject initialize toset the constants
to the correct values. Fora particular application, globals and constants declared
in the interface and implementation of that application will be stored in a shared
pool shared by all classes of that application. The shared pool will be initialized
by the initialize method of whatever class the parser comes comes across first. lt
is generally assumed this will be a sub-class of TApplication.
4. There will be a symbol table that will remember needed information about
particular types and variables, like if it is an array or a PascalRecord. Variables
that require a PascalRecord will have code generated in either the appropriate
class initialize method or the local method, depending on where the Variable is
located, to create the PascalRecord.
5.Both the interface and implementation of MacApp or a specific application will
have to be parsed. This will allow the parser to know about the types of all
variables. The parser will need to know about global procedures as well as
methods that haven't yet been parsed. Only by parsing the interfaces first can
this information be obtained. Procedures that are global to MacApp will be
defined as class methods of TObject. Procedures that are global to a particular
application will be defined as class methods of the …
Showing first 3,000 characters of 12,551 total. Open the full document →