home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
compiler
/
pascal2
/
pascal.man
< prev
next >
Wrap
Text File
|
1993-11-08
|
15KB
|
301 lines
PASCAL compiler, ALPHA 1.a release for OS/2
Eindhoven, 8 november 1993
NOTE: IMPORTANT.
This compiler does not include an assembler, but it does require one.
This second release can either use:
Microsoft MASM or
Borland TASM for OS/2
And currently The MASM part is very picky.
It only generates code for MASM 6.0A (note the A !!)
I had severe problems when using the regular MASM 6.0, The major
reason was wrong address/offset calculations.
I haven't tried it with MASM 5.x, since I don't have it.
If you can't get it to run with MASM 6.0, go and yell at MS to make
MASM 6.0A more freely available. So people can buy it.
Or buy Borlands TASM, which unfortunately is included in a rather large
package.
Or way for PASCAL for OS/2 to generate GNU/AS code.
COMMAND
pc [options] <filename>.<ext>
pas [options] <filename>.<ext>
DESCRIPTION
This is the temporary manual page for
the pascal compiler frontend,
the pascal compiler.
In general it should be sufficient to use the compiler in the following
way:
'pc file.pas'
This creates a file 'file.exe' which can be executed.
The PASCAL 'version' implemented is as close to the standard level(0)
as possible. There are a few extentions, a few ommisions, plenty of
bugs, and some not yet implemented areas.
Currently is it not possible to create seperate modules without
changing the intermediate assembler file. If object-modules need to be
made, then make a program of every module, with an empty main program
body. Create the assembly files, from which the '$Pmain'-routine should
be deleted. This file can then be assembled.
There is currently no supported way to use variables which are declared
in other modules. For procedures and routines is the attribute
'EXTERNAL' available.
Eg.: 'Procedure SomeWhereElse(i;integer); EXTERNAL'
The actual code is transformed in several steps:
1) The user code is passed through the preprocessor.
Currently is this the C-preprocessor, which complains
about unterminated strings ' in PASCAL comments.
You'll have to change your comments.
2) Then 'pas' is used to transform the resulting PASCAL into
assembly. Currently Microsoft MASM/ML is the only
assembly language supported.
3) The assembly code is used to create the objectcode for
the module.
4) Which is linked together with the PASCAL library, p.lib,
and creates a the resulting executable.
To watch these steps, just add the -v switch to the pc command.
OPTIONS for pc
-v* Show command the frontend executes.
-Dname
-Dname=def Set definitions for the preprocessor.
-Uname Instruct the preprocessor to undefine 'name'.
-S Generate an assembly file and terminate
-c Generate an object file, but do not link.
-E Only run the preprocessor on the file, and write results to
standard ouput.
-o <file> Specify the file in which the result should be
written.
-h Runtime help information.
-x Generate a crossreference in <filename>.xrf
-m Generate MASM typical code and possibly use MASM.
-t Generate TASM typical code and possibly use TASM.
OPTIONS for pas
-v* Switch verbosity one level higher.
-h Runtime help information.
-x Generate a crossreference in <filename>.xrf
-d Debugging options.
bEePprsTt
r List the tokens found by the scanner
p Show which rules are matched in the parser
i dump the identifier table to <filename>.ids
t/T* dump the AST/defs tree (or more Tree)
to <filename>.tre for AST trees
to <filename>.syt for defs-trees
s write a trace of the semantic evaluation to <filename>.sem
P Dump the environment as it is Predefined
e/E* List the environments on numerous ocassions
* indicates that a switch know levels, multiple time specification
of the switch indicates "more" of that switch
Capitalisations of those switches increments the debuggin level
with five lowercase's.
DEBUGGING
Not much attention has (yet) been given to debugging and creating
debugging information. I debug the programs on assembly language level
using IBM's IPMD.
You don't want to do this, unless you're familiar with the 386-code,
since no PASCAL code is included. And it can be mind boggling to find
out what is going on.
EXTENTIONS
Several extenstions have been implemented to make life a little easier.
Comments: A comment started by one version of the comments
starter, has to be terminated by the matching comment
close combination. They cannot be nested.
Thus the following are complete comments:
{(**)}, (*{}*). (*}*) {*)}
Not correct are:
{*), (*}, (*{*), {(*} or {(*{}*)}
Identifiers: Identifiers can contain '_' and '$' as valid characters.
if '_' of '$' is used a starting character then the
second character has to be one from the
set ['a'..'z','A'..'Z'].
Declaraton order The declaration order of constants, types,
variables and routines is not required. These
declaration blocks can be repeated multiple times in
any order. The only restriction is that only
pointer-type definitions can refer to types yet to be
declared.
EXTERNAL Net to the 'FORWARD' directive for routines, is the
'EXTERNAL' directive available as an indication to the
compiler/assembler that code for this routine is to be
found elsewhere.
CASE-statement The CASE-statement has be expanded with a default
clause. Both OTHERWISE and ELSE are recognised as
default selectors. This is the grammar for the
extention:
statement9a = 'CASE' expression 'OF' case_list case_default case_end.
case_default = <
/* And these 2 are definitly not in the ISO standard.
*/
/* A Microsoft extention */
case_default1 = 'OTHERWISE' statement .
case_default1a = ';' 'OTHERWISE' statement .
/* A Turbo Pascal extention
/* Hopefully it does not conflict with the regular treatment of an
/* If-Then-Else statement.
*/
case_default2 = 'ELSE' statement .
>.
MinInt Next to the constant MaxInt (2147483647) is also the
constant MinInt (-2147483648) available.
Assign To be able to interact with the filesystem, it is
possible to use the procedure
ASSIGN(Var f: anyfile, s :string),
an associate an external filename with an internal file.
OMMISIONS
PACKED The keyword 'PACKED' is allow in declaration but is
ignored. Using it does not give any allocation
advantages. The accompanying routines 'PACK' and
'UNPACK' are not implemented. They are recognised by
the scanner/parser.
CONFORMANT ARRAY Conformant array are not include with a PASCAL
level(0) implementation.
NOT YET IMPLEMENTED
REAL The major ommision to this release is the lack of
floating point. The compiler recognises floating point
PASCAL, but is not able to generate any floating point
code. This will be one of the first next items to be
fixed.
ROUTINES as parameters.
The standard allows routines to passed a parameters to
other routines. Again the parser recognises it, but
during semantic analysis, strange things could happen.
BUGS
To many to report here. That is why this version is an ALPHA release.
There are several flaws in the code generation. And although many case
have been tested in isolation, complex situations can cause wrong code
to be generated.
Please report these to the author, so that they can be fixed.
(Or at least mentioned in the buglist)
The compiler is sometimes able to recognise the fact that it is in an
inconsistent state. Or worse, it could even dump core :-(
Then usually strange looking text is written to the screen.
This output, your input, and possibly the core dump, can be of help to
me. Prefably stripped to the smallest code-chunk which still exhibits
the behaviour.
On several places in the runtime library are tests on the outcome of
systemcalls. If they fail, a message with that regard is printed on
'stderr'.
During execution, traps can occur. Usually this means that either
pointers or array accesses have been outside the current allowed space.
Eg:
core dumped
SYS1808:
The process has stopped. The software diagnostic
code (exception code) is 0005.
These could be compiler errors, but lately I haven't found many of
those that showed in this blunt way. Usually/un fortunately compiler
errors show more 'secretly'.
DEFAULTS
Default stack size is set to 128 Kb, which can be modified in
passtart.asm.
Default heap size is set to 1 Mb, but can be changed by recompiling the
'heaplib.pas' code which is part of the runtime environment.
ENVIRONMENT
PASCAL for OS/2 was generated using Cocktail compiler tools,
and compiled using the EMX/GCC. So the runtime environment for the
compiler has to include the EMX runtime environment. In 'emxrt.zip' is
documentation available on how to install the EMX-run time system.
The PASCAL compiler itself only uses two environment variables:
TMP The location for intermediate files.
PAS_INC This path will be included in the seachpath for
the preprocessor.
But the linker can use others as well:
LIB The path used by LINK386 for libraries.
PAS_LIB The path where additional libraries can be found
for the linker. (currently ignored)
RUNTIME LIBRARY
The source for the runtime library is included in the package. It is
the part which is least severly tested. I has several problem areas in
it, but for most average programming it should work.
One is always free to go through the runtime library code and modify it
to fit ones own requirements. If these changes are usefull to others as
well I'd be more than willing to include them in a new release.
The area with most problems in INPUT from an interactive file (eg.:
input), since different pascal compilers have different kind of
behaviour. TurboPascal nowhere nearly complies with the standard, and
as such is it currently hard to mimic it's behaviour.
[ Unless ofcourse, you are of the opinion that TurboPascal is the
standard :-( ]
FILES
.pas pascal source files
.inc assembler or pascal include files
.i pascal preprocessed files
.asm assembler sources
.obj MASM/ML result files
.lib Library files
/tmp/pc???? Temporary files
AUTHOR
Willem Jan Withagen. phone: +31-(0)40-473401
Eindhoven University of Technology fax: +31-(0)40-474702
Room 10.35 Email: wjw@eb.ele.tue.nl
PO Box 513
5600 MB Eindhoven
The Netherlands
ORIGINAL SOURCE
The most current release of this compiler should always be available
from:
ftp.eb.ele.tue.nl:/pub/src/pascal/pasos2.zip
SEE ALSO
Kathleen Jensen and Niklaus Wirth.
Pascal User and Reference Manual
Springer Verlag, second edition, 1974.
British Standards Institution.
Specification fo computer programming language PASCAL, 1984.
ISO 7185 / BS 6192.
Willem Jan Withagen
A flexible frontend for a PASCAL compiler
Technical report Eindhoven University of technology
ftp: ftp.eb.ele.tue.nl:/pub/src/pascal/frontend.*