The Main Module
The main module of the compiler links all parts of the compiler together. The name of the
source program's file is assumed to be passed to the compiler as the first argument in the
command line. Thus the compiler should be called by the command
Cmp FileName
where
FileName is a file
name. This name is accessed by the compiler by means of the library function
Arg.
//
// File Cmp.rf
//
$use Dos StdIO;
$use CmpPrs CmpGen;
$func Main = e;
$func Compile e.FileName = ;
Main =
<Arg 1> :: e.FileName,
<Compile e.FileName>;
Compile e.FileName =
<Channel> :: s.Chl,
<OpenFile s.Chl e.FileName "r">,
<Parse s.Chl> :: t.AProgram,
<CloseChannel s.Chl>,
<GenCode t.AProgram> :: t.Code,
<WriteCode t.Code>;