File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11all : compile.js
22 npm install
3- node lambda debug.mlc > | output.tmp
4- tail output.tmp
5- time -p node lambda
3+ node lambda -d debug.mlc
4+ time -p node lambda fact.mlc
65
76compile.js : grammar.jison
87@@ -11,5 +10,5 @@ compile.js: grammar.jison
1110 mv $@ .tmp $@
1211
1312clean :
14- -rm -f * .tmp stats.json
13+ -rm -f * .tmp
1514 -rm -fr node_modules
Original file line number Diff line number Diff line change 11This package implements the pure untyped lambda calculus using
2- interaction nets, providing both CLI and API described below .
2+ interaction nets, providing both CLI and API.
33
44# CLI
55
66This package provides a ` lambda ` command with the following interface:
77
88```
9- Usage: lambda [file]
9+ Usage: lambda [options] <file.mlc>
1010
1111Options:
12+ --debug, -d Enable step-by-step evaluation [boolean]
13+ --stats, -s Save statistics to a file [string]
1214 --help, -h Show help [boolean]
1315 --version, -v Show version number [boolean]
1416
@@ -24,7 +26,7 @@ The last term in the input is the term whose normal form is to be found.
2426For developing and testing purposes, the package also exports
2527two additional functions ` .prepare(term) ` and ` .debug() ` .
2628The ` .debug() ` function applies a single reduction step to
27- the interaction net compiled by the previous ` .prepare(src, fmt ) `
29+ the interaction net compiled by the previous ` .prepare() `
2830call and returns a human-readable string representation of
2931the current interaction net state.
3032
Original file line number Diff line number Diff line change @@ -4,8 +4,23 @@ var lambda = require(".");
44var yargs = require ( "yargs" ) ;
55var fs = require ( "fs" ) ;
66
7+ var opts = {
8+ debug : {
9+ alias : "d" ,
10+ desc : "Enable step-by-step evaluation" ,
11+ boolean : true
12+ } ,
13+ stats : {
14+ alias : "s" ,
15+ desc : "Save statistics to a file" ,
16+ string : true
17+ }
18+ } ;
19+
720var argv = yargs
8- . usage ( "Usage: $0 [file]" )
21+ . usage ( "Usage: $0 [options] <file.mlc>" )
22+ . options ( opts )
23+ . demandCommand ( 1 )
924 . help ( )
1025 . alias ( "help" , "h" )
1126 . version ( )
@@ -14,23 +29,23 @@ var argv = yargs
1429 . wrap ( 70 )
1530 . argv ;
1631
17- var file = argv . _ [ 0 ] ;
32+ var input = fs . readFileSync ( argv . _ [ 0 ] , "utf8" ) ;
1833
19- if ( file ) {
20- var input = fs . readFileSync ( file , "utf8" ) ;
34+ if ( argv . debug ) {
2135 var eqn ;
2236
2337 lambda . prepare ( input ) ;
2438
2539 while ( eqn = lambda . debug1 ( ) )
2640 console . log ( eqn ) ;
2741} else {
28- var output = lambda ( lambda . example ) ;
42+ var output = lambda ( input ) ;
2943 var stats = JSON . stringify ( output . stats , null , "\t" ) ;
3044
3145 console . log ( output . term ) ;
3246 console . info ( "%s(%s)" , output . total , output . beta ) ;
3347 console . log ( output . nf ) ;
3448
35- fs . writeFileSync ( "stats.json" , stats + "\n" ) ;
49+ if ( argv . stats )
50+ fs . writeFileSync ( argv . stats , stats + "\n" ) ;
3651}
Original file line number Diff line number Diff line change 44 "repository" : " codedot/lambda" ,
55 "name" : " @alexo/lambda" ,
66 "bin" : " ./lambda.js" ,
7- "version" : " 0.0.1 " ,
7+ "version" : " 0.0.2 " ,
88 "license" : " MIT" ,
99 "dependencies" : {
1010 "inet-lib" : " 0.2.0" ,
You can’t perform that action at this time.
0 commit comments