|
@@ -15,7 +15,6 @@ import Parser, { ParserError } from './parser';
|
15
|
15
|
// };
|
16
|
16
|
|
17
|
17
|
const rawArgs = minimist(process.argv.slice(2));
|
18
|
|
-
|
19
|
18
|
const args = {
|
20
|
19
|
eval: rawArgs.e || rawArgs.eval,
|
21
|
20
|
file: rawArgs.f || rawArgs.file,
|
|
@@ -37,19 +36,13 @@ const moss = (
|
37
|
36
|
): LexerError | ParserError | EnvError | string => {
|
38
|
37
|
const lexer = new Lexer(source, file);
|
39
|
38
|
const tokens = lexer.scan();
|
40
|
|
- if (tokens instanceof LexerError) {
|
41
|
|
- return tokens;
|
42
|
|
- } else {
|
43
|
|
- const parser = new Parser(tokens);
|
44
|
|
- const tree = parser.parse();
|
45
|
|
- // print(tree);
|
46
|
|
- if (tree instanceof ParserError) {
|
47
|
|
- return tree;
|
48
|
|
- } else {
|
49
|
|
- const compiler = new Compiler(tree, { prettyPrint: args.pretty });
|
50
|
|
- return compiler.compile();
|
51
|
|
- }
|
52
|
|
- }
|
|
39
|
+ if (tokens instanceof LexerError) return tokens;
|
|
40
|
+ const parser = new Parser(tokens);
|
|
41
|
+ const tree = parser.parse();
|
|
42
|
+ // print(tree);
|
|
43
|
+ if (tree instanceof ParserError) return tree;
|
|
44
|
+ const compiler = new Compiler(tree, { prettyPrint: args.pretty });
|
|
45
|
+ return compiler.compile();
|
53
|
46
|
};
|
54
|
47
|
|
55
|
48
|
const run = () => {
|