Skip to content

Commit

Permalink
Initial cut of start compiler and interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
vsmenon committed Mar 28, 2013
1 parent 8a57a44 commit 74c4ffa
Show file tree
Hide file tree
Showing 32 changed files with 5,314 additions and 0 deletions.
38 changes: 38 additions & 0 deletions bin/start.dart
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');
}
}
Loading

0 comments on commit 74c4ffa

Please sign in to comment.