Skip to content

Commit f8eebe0

Browse files
committed
Factor out samples to a separate directory
1 parent 447d4ad commit f8eebe0

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ all: compile.js
22
npm install
33
node lambda -h
44
node lambda -ce "S hello bye world"
5-
node lambda -d debug.mlc
6-
node lambda -pt fact.mlc
5+
node lambda -d samples/debug.mlc
6+
node lambda -pt samples/fact.mlc
77

88
compile.js: grammar.jison
99
npm install jison@0.4.15

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
const encode = require("./encoding");
44
const compile = require("./compile");
5+
const samples = require("./samples");
56
const inet = require("inet-lib");
6-
const fs = require("fs");
7-
const path = require("path");
87

98
const parser = new compile.Parser();
10-
const example = fs.readFileSync(path.join(__dirname, "fact.mlc"), "utf8");
119
let expanded;
1210

1311
function obj2mlc(obj)
@@ -112,6 +110,7 @@ run.debug = debug;
112110
run.debug0 = debug0;
113111
run.debug1 = debug1;
114112
run.mlc2in = mlc2in;
115-
run.example = example.replace(/\n*$/, "");
113+
run.example = samples.fact.replace(/\n*$/, "");
114+
run.samples = samples;
116115

117116
module.exports = run;

lambda.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const lambda = require(".");
66
const yargs = require("yargs");
7-
const path = require("path");
87
const fs = require("fs");
98

109
const opts = {
@@ -52,15 +51,13 @@ const argv = yargs
5251
.wrap(70)
5352
.argv;
5453

55-
const comb = fs.readFileSync(path.join(__dirname, "helper.txt"), "utf8");
56-
5754
let input = argv._[0];
5855

5956
if (!argv.expr)
6057
input = fs.readFileSync(input, "utf8");
6158

6259
if (argv.comb)
63-
input = comb.concat(input);
60+
input = lambda.samples.helper.concat(input);
6461

6562
if (argv.debug) {
6663
let eqn;
File renamed without changes.
File renamed without changes.
File renamed without changes.

samples/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
exports.debug = fs.readFileSync(path.join(__dirname, "debug.mlc"), "utf8");
5+
exports.fact = fs.readFileSync(path.join(__dirname, "fact.mlc"), "utf8");
6+
exports.helper = fs.readFileSync(path.join(__dirname, "helper.txt"), "utf8");

0 commit comments

Comments
 (0)