home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sa104os2.zip
/
SATHR104.ZIP
/
SATHER
/
COMPILER
/
CS.SA
< prev
next >
Wrap
Text File
|
1994-12-10
|
3KB
|
87 lines
-- Copyright (C) International Computer Science Institute, 1994. COPYRIGHT --
-- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
-- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in --
-- the file "Doc/License" of the Sather distribution. The license is also --
-- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA. --
--------> Please email comments to "sather-bugs@icsi.berkeley.edu". <----------
class CS is
-- The 1.0 compiler.
main(a:ARRAY{STR}):INT is
-- Compile a program. The the first command line arguments should
-- be the name of the class with `main' in it. The rest should be
-- the names of the source files to look at.
p:PROG:=PROG::create;
-- Handle the command line options and SATHER_COMMANDS
p.options.interpret(a);
if p.options.force_all or ~p.options.force_routines.is_empty then
p.err("-force options not implemented");
end;
if ~p.options.externals.is_empty then
p.err("-external option not implemented");
end;
if p.options.verbose then #OUT + p.options.str +"\n\n"; end;
p.create_back_end;
if p.options.verbose then #OUT + "Parsing...\n"; end;
loop
fn::=p.options.sather_files.elt!;
if ~p.options.known_files.test(fn) then
p.prog_parse.parse(fn);
end;
end;
if p.err_seen then return 1 end;
if p.options.only_parse then return 0; end;
if p.options.verbose then #OUT + "Finding types...\n"; end;
p.do_find_types_phase;
if p.err_seen then return 2 end;
if p.options.verbose then #OUT + "Constructing type graph...\n"; end;
p.do_type_graph_phase;
if p.err_seen then return 3 end;
if p.options.verbose then #OUT + "Checking conformance...\n"; end;
p.do_ifc_conformance_phase;
if p.err_seen then return 4 end;
if p.options.verbose then #OUT + "Finding main...\n"; end;
p.do_get_main_phase(p.options.main_class);
if p.err_seen then return 5 end;
if ~p.options.only_check then
if p.options.verbose then #OUT + "Generating structs...\n"; end;
p.back_end.init;
if p.err_seen then return 6 end;
end;
if p.options.verbose then #OUT + "Type check and generate...\n"; end;
p.do_am_generate_phase;
if p.err_seen then return 7 end;
if ~p.options.only_check then
if p.options.verbose then #OUT + "Cleaning up...\n"; end;
p.finalize_back_end;
if p.err_seen then return 8 end;
end;
if p.options.only_reachable then return 0; end;
if p.options.verbose then #OUT + "Checking unreachable code...\n"; end;
p.do_am_check_phase;
if p.err_seen then return 9 end;
if p.options.verbose then #OUT + "Compilation complete.\n"; end;
return 0;
end;
end;
-------------------------------------------------------------------