coffee, dart, elixir, elm: detect unclosed strings.
[jackhill/mal.git] / dart / step1_read_print.dart
1 import 'dart:io';
2
3 import 'printer.dart' as printer;
4 import 'reader.dart' as reader;
5 import 'types.dart';
6
7 MalType READ(String x) => reader.read_str(x);
8
9 MalType EVAL(MalType x) => x;
10
11 String PRINT(MalType x) => printer.pr_str(x);
12
13 String rep(String x) {
14 return PRINT(EVAL(READ(x)));
15 }
16
17 const prompt = 'user> ';
18 main() {
19 while (true) {
20 stdout.write(prompt);
21 var input = stdin.readLineSync();
22 if (input == null) return;
23 var output;
24 try {
25 output = rep(input);
26 } on reader.ParseException catch (e) {
27 stdout.writeln("Error: '${e.message}'");
28 continue;
29 } on reader.NoInputException {
30 continue;
31 }
32 stdout.writeln(output);
33 }
34 }