-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompiler.os
executable file
·55 lines (44 loc) · 1002 Bytes
/
Compiler.os
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/local/bin/slang
// library imports
import libParam.ParameterHandler;
import System.String;
import System.StringIterator;
// project imports
import Consts;
import CodeEmitter;
import Line;
import Parser;
public int Main( int argc, string args ) modify {
var debug = false;
var params = new ParameterHandler( argc, args );
// Handle parameters
// {
if ( params.contains( "debug" ) ) {
debug = true;
params.remove( "debug" );
}
if ( params.contains( "version" ) ) {
print( APPNAME + " " + VERSION );
return 0;
}
if ( params.empty() ) {
print( "not enought parameters provided!" );
return -1;
}
// }
try {
Parser parser = new Parser();
var emitter = new CodeEmitter( parser.parseFile( params[ 0 ].Key, debug ) );
return emitter.run( debug );
}
catch ( string e ) {
print( "Exception: " + e );
}
catch ( IException e ) {
print( typeid( e ) + ": " + e.what() );
}
catch {
print( "Exception: caught unknown exception!" );
}
return -1;
}