forked from vsmenon/start
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial cut of start compiler and interpreter
- Loading branch information
Showing
32 changed files
with
5,314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
library start; | ||
|
||
import 'dart:io'; | ||
import 'package:args/args.dart'; | ||
|
||
import 'startc/startc.dart'; | ||
import 'starti/starti.dart'; | ||
|
||
ArgResults options() { | ||
final options = new Options(); | ||
final argv = options.arguments; | ||
|
||
final parser = new ArgParser(); | ||
parser.addFlag('debug', help: 'Print debugging info', defaultsTo: false); | ||
parser.addFlag('show', help: 'Print IR', defaultsTo: false); | ||
parser.addFlag('run', help: 'Execute code', defaultsTo: true); | ||
parser.addFlag('stats', help: 'Show stats', defaultsTo: false); | ||
return parser.parse(argv); | ||
} | ||
|
||
void main() | ||
{ | ||
final args = options(); | ||
if (args.rest.length != 1) | ||
throw 'Filename expected'; | ||
final filename = args.rest[0]; | ||
|
||
final file = new File(filename); | ||
final input = file.readAsStringSync(); | ||
final output = compile(input); | ||
if (args['show']) | ||
print(output); | ||
if (args['run']) { | ||
final stats = execute(output, debug: args['debug']); | ||
if (args['stats']) | ||
print('\n$stats'); | ||
} | ||
} |
Oops, something went wrong.