CompilerDoc.Tioga
Last Edited by: Spreitzer, May 22, 1984 5:57:10 pm PDT
Last Edited by: Swinehart, May 22, 1984 2:14:02 pm PDT
Last Edited by: Subhana, May 30, 1984 8:31:37 am PDT
Last Edited by: Bob Hagmann March 27, 1986 9:55:27 am PST
USING THE COMPILER
USING THE COMPILER
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
Using the Compiler
Release as [Indigo]<Cedar6.0>Documentation>CompilerDoc.Tioga

© Copyright 1984, 1985 Xerox Corporation. All rights reserved.
XEROXXerox Corporation
Palo Alto Research Center
3333 Coyote Hill Road
Palo Alto, California 94304

For Internal Xerox Use Only
What we're not talking about
This document does not describe the Cedar language. The Cedar language is poorly documented. You may find an overview in OverviewDoc.Tioga. When desperate, you might consult the Mesa 11.0 manual (available in hardcopy). Both Cedar and Mesa 11 evolved from Mesa 5. The Mesa 5 manual is abundantly available as a blue-and-white. Almost all of the changes since then have been additions, rather than revisions.
This document cites a number of other Cedar documents, usually in the form [see CommandToolDoc]. This is a shorthand citation for
[Indigo]<Cedar®>Documentation>CommandToolDoc.Tioga
You can usually look at such a document by typing "Openr CommandToolDoc.Tioga" to the command tool.
What we are talking about
We're talking about the Cedar compiler. Cedar is a modular language: a program can be composed of several compilation units. The compiler compiles compilation units one-at-a-time. The only communication between compilations is via the file system. A compilation takes as input: 1) a Cedar source (in a file named "Foo.Mesa", for some "Foo") and 2) compiled modules (in files named "Bar.BCD", for various "Bar"s). A compilation produces as output: 1) an object file (named "Foo.BCD", when the source is "Foo.Mesa"), and 2) logs of errors, warnings, and other administrivia.
Installing the Compiler
Use the command tool or the DF tool to BringOver the public part of Compiler.DF, from the release, into a directory that will be on your search path when you want to use it. [See CommandToolDoc for a complete description of the command tool, working directories, and search paths]. On public machines, you may expect that the current compiler has been fetched to the ///Commands/ subdirectory. But as an installation example, here's how you might install the Cedar6.0 version in a Commands subdirectory of your home directory:

%
CD
///Users/YourName.pa/
% CD Commands
///Users/YourName.pa/Commands/
% BringOver -p [Cedar]<Cedar6.0>Top>Compiler.DF
Start: [Cedar]<Cedar6.0>Top>Compiler.DF
...
End: [Cedar]<Cedar6.0>Top>Compiler.DF
.. files acted upon
%
Some people find it convenient to add a button to their CommandTools for invoking the compiler. See CreateButtonDoc.Tioga for how to do this.
Put entries like the following in your user profile in CommandTool.BootCommands, CommandTool.NewUser, CommandTool.PerLogin, and CommandTool.PerCommandTool as appropiate: ``CreateButton Compile Compile $FileNameSelection$'' or ``EnsureButton Compile Compile $ShortFileNameSelection$''. Really check out the user proile and create button documentation.
Invoking the Compiler
The compiler is invoked by issuing a command in a CommandTool [see CommandToolDoc]. The compiler registers three commands (in the directory it was BroughtOver into): "Compile" "RCompile", and "ComplexCompile". (There are .Load files for all of these so you needn't worry about issuing a run command to get the commands registered.) The commands differ in that the latter offers to parse a more complicated command-line syntax (that offers a few esoteric features unavailable from the simple command). RCompile is just like Compile except that it prefers to do its compilation on a remote machine (this uses the ``Compute Server'' — see SummonerDoc.tioga).
The "Compile" and "RCompile" Commands
Syntax
(determined by looking at Interface.Mesa, a module in the compiler)
The simple compile command has a simple syntax:
% Compile fileOrSwitches1 fileOrSwitches2 . . . fileOrSwitchesN
where fileOrSwitches is a file name (default extension ".Mesa"), or some switch settings. This form accepts all Cedar file name syntaxes: absolute or relative, slashy or brackety. [See FSDoc for details.] Switch settings are introduced by a dash, and each switch (a letter) can be negated by preceeding it with a dash or tilde.
Semantics
The list of source files (default extension ".Mesa") is compiled in order. The result is an object file named "Root.BCD", where "Root" is the actual file name excluding directory specifications and extensions.
The switch settings are "sticky": they remain in force until countermanded (or the command line ends). Letters preceeded by a dash or tilde are negated; the others are positive. The default settings are given later.
If RCompile is used and a ``Compute Server Client'' is running and enabled on the local machine, then the compiler will attempt to run the compilation remotely. If this fails, it will run it locally. RCompile is the prefered mode of running compiles from lower powered workstations. RCompile.load uses much less VM, less of MDS and fewer GFI's, and is better to put in the checkpoint on lower powered workstations (you full boot and rollback quicker).
Examples
% Compile Foo -g~w Bar.Mesa
First, produce Foo.Mesa into Foo.BCD with all switches in their default settings. Then, compile Bar.Mesa into Bar.BCD, with all switches as usual, except that the "g" option is turned on, and the "w" option is turned off. An equivalent switch string would be "-g-w". Can you guess why tildes are the recommended way to indicate switch negation?
The "ComplexCompile" Command
Syntax
(from the compiler appendix of the "Mesa User's Handbook" Version 6.0 October 1980; ammended by experimentation in Cedar5.2)
The ComplexCompile syntax is also simple at the top level:
% ComplexCompile productionOrSwitches1 ... productionOrSwitchesN
where switches are just like the simple case, except that they are introduced with a slash, rather than a dash (but still negated with either a dash or tilde). A production lets you specify more details about the module compilation it commands:
ObjectFileName ← SourceFileName[Module1:FileName1, Module2:FileName2, ... ModuleN:FileNameN]/s1s2...sm
where all file names are "short": they have no directory parts (i.e., no slashes or right angle brackets). Each si is a switch setting: a letter, possibly preceeded by a dash or tilde. Any part may be omitted, except for the source file name.
Semantics
This version lets you specify more things. First, you can specify what name the object file is to have (default extension is ".BCD").
A Cedar module (e.g., Foo) may reference other modules (e.g., Bar and Baz). The compiler considers the text of Foo to represent a function from the compiled values of Bar and Baz to the compiled value of Foo. The ComplexCompile command lets you specify in the binding list what files contain the compiled values of Bar and Baz. Again, the default extension is ".BCD". You do not have to specify bindings for all module references; for those you don't specify, it uses "Modulei.BCD" as the file to find the compiled module in. This is what the simple Compile command does for all module references.
Finally, switches can be given locally to a compilation. When switches are given together with a compilation, those switch settings apply only to that compilation. Switches that appear without an accompanying module apply to all subsequent modules (on that command line).
Examples
% ComplexCompile /~aj ReadOldFormat ← ReadData[DataFormat: OldFormat]/n SymExtra[Table: LongTable]
First, turn off option "a" and turn on "j". Then, compile ReadData.Mesa into ReadOldFormat.BCD, adding the "n" option for this file only. Wherever ReadData.Mesa references "DataFormat", use the version from OldFormat.BCD. Then compile SymExtra.Mesa into SymExtra.BCD. Wherever SymExtra.Mesa references "Table", use LongTable.BCD.
Switches
From CompilerSequencer.Mesa, a module in the compiler, here are the meanings and defaults of the compiler switches:
DefaultSwitches: PUBLIC PROC RETURNS [CompilerOps.LetterSwitches] = {
RETURN [[
TRUE , -- A Address fault for NIL checks
TRUE , -- B Bounds checking
TRUE , -- C compile for Cedar (special FORK)
FALSE, -- D call Debugger on compiler error (FALSE => just log error)
TRUE , -- E fixed (big Eval stack)
TRUE , -- F Floating point microcode
TRUE , -- G TRUE => log goes to compiler.log, FALSE => use foo.errlog
FALSE, -- H TRUE => append to compiler.log, FALSE => write new compiler.log
FALSE, -- I unused
FALSE, -- J cross-Jumping optimization
FALSE, -- K unused
TRUE , -- L allocate space for code Links
TRUE , -- M reference counting Microcode
TRUE , -- N Nil pointer checking
FALSE, -- O unused
FALSE, -- P Pause after compilation with errors
FALSE, -- Q unused
FALSE, -- R unused
TRUE , -- S Sort (by static frequency) global vars & entry indexes
FALSE, -- T unused
FALSE, -- U uninitialized variable checking
FALSE, -- V unused
TRUE , -- W log Warning messages
FALSE, -- X unused
FALSE, -- Y complain about KFCB
FALSE -- Z unused
]]};
The Compiler and Directories
The compiler has not yet been adequately informed about directories. Note that the ComplexCompile form allows only directoryless file names. The simple form allows a directory part, but the compiler discards it for every use except naming the source file. Thus, if your CommandTool has working directory []<>A>, and you say
% Compile []<>B>Foo
the source will be looked for under []<>B>Foo.Mesa, the object will be put under []<>A>Foo.BCD, and modules referenced from Foo will be looked for under []<>A>M.BCD, for each module name M. Clearly, it is best to have everything in one directory --- the current working directory.
Logs
The compiler produces three kinds of "reporting" output. One is a very cursory progress report --- just enough to let you know something's happening, and how many errors and warnings there were. Another is a more detailed progress report, indicating things like time spent, size of input & output, and number of errors, for each compilation. Finally, there are the errors and warnings, if any, for each compilation.
The cursory progress report is printed in the CommandTool from which the compiler is invoked. The detailed progress report is put in a file named "Compiler.Log", in the working directory of the CommandTool from which the compiler is invoked. The errors and warnings may also be put in "Compiler.Log", or instead in "Foo.errlog" (where "Foo" is the root of the source file name). This is what the "g" option is about.
The Compiler and Tioga
The compiler will accept source files prepared with Tioga. It looks only at the ASCII aspects of the source file. Thus, it does not see node structure, looks, formats, or styles. And although this slightly contradicts the preceeding, comment nodes (those whose "Comment" property is TRUE) are ignored.
Before reading a source file, the compiler checks to see if the file is currently being edited or saved. If it is being edited, the compiler will ask you to save the file, and wait for this to happen before it proceeds. If the compiler finds the file in the process of being saved, it will wait untill the save completes before reading it. The waiting is done by polling once a second, and if things happen too quickly, the compiler may get confused.
If the "g" option is on, the compiler will open a Tioga Viewer on "Compiler.Log" if any of the compiles from a command line fail. If the "g" option is on, and all the compiles from a command line succeed, and there is a Tioga Viewer on "Compiler.Log", the compiler will destroy it.
If the "g" option is off, the compiler consults the "Compiler.ViewSeparateLogs" entry in your user profile to find out what to do about errors and warnings. In either case, it will create a Tioga Viewer on the source file. If Compiler.ViewSeparateLogs is FALSE, it will add a button (named "ErrorLog") at the right end of the top row of the menu of the Tioga Viewer on the source file. When clicked, that button will open a Tioga Viewer on the error log from that source file. Unfortunately, sometimes there is so much stuff already in the first row of the menu that the "ErrorLog" button is posted past the right boundary of the Viewer (and hence is invisible and un-clickable). If Compiler.ViewSeparateLogs is TRUE, the compiler will instead immediately (upon errors or warnings) open a Tioga Viewer on the error log, rather than posting a button to do it. In either case, when it successfully compiles a module (no errors or warnings), it removes an "ErrorLog" button (if it can find one) from the source Viewer's menu, and destroys all viewers on the error log, and deletes the error log file.
The Compiler and UserProfile
The compiler looks at a few entries in your user profile. Some UserProfile entries are just providing an automatic insertion of switches in all your compiler commands; others are more peculiar (generally dealing with Viewers). [See the compiler section of UserProfileDoc].
Here is reasonable compiler section for a Cedar6.0 user profile:
Compiler.IconicLogs: FALSE
Compiler.BlinkLogs: FALSE
Compiler.SeparateLogs: TRUE
Compiler.ViewSeparateLogs: TRUE
Compiler Bugs
This is not an exhaustive list of bugs.
If you compile and get (some kind of) fatal compiler error, it damages the compiler. It will not correctly compile statements with the CONDITION construct. Your only option is to rollback. If this happens to a compile done through the Compute Server, the remote machine must be rolledback. Obscure error messages will appear such as:
32768 has incorrect type, at Create[1551]:
d: MyData = NEW[MyDataObject];