计算器的bin/calc.dart 可执行代码:
import 'dart:io';
import 'package:data_struct/stack/sample/calculator.dart'; void main() {
print('please input the expression:');
var ins = stdin.readLineSync();
while (ins != 'exit') {
try {
var r = calc(ins);
print('\n the result is: $r');
} on FormatException {
print('Format error!');
} on Exception catch (e) {
print('Unknown error: $e!');
} print('\nplease input the expression:');
ins = stdin.readLineSync();
}
}