-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
302 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var fs = require('fs'); | ||
|
||
var pegjs = require('pegjs'); | ||
|
||
var text = fs.readFileSync("bm.scm", "utf8"); | ||
|
||
var request = require('request'); | ||
|
||
var Benchmark = require('benchmark'); | ||
|
||
var suite = new Benchmark.Suite; | ||
|
||
suite | ||
.on('cycle', function(event, bench) { | ||
console.log(String(bench)); | ||
}) | ||
.on('complete', function() { | ||
console.log('Fastest is ' + this.filter('fastest').pluck('name')); | ||
}); | ||
|
||
var load = require("./load") | ||
|
||
load(function (par, name) { | ||
suite.add(name, function () { | ||
par(text); | ||
}); | ||
}, function () { | ||
suite.run(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(+ 1 2 f ( | ||
x y | ||
;; a comment | ||
z | ||
'(1 2 3) | ||
;; great | ||
) g ( 1 | ||
2 | ||
atome | ||
just | ||
kidding | ||
;;more comm | ||
;;and more | ||
|
||
)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var request = require('request'); | ||
var fs = require('fs'); | ||
var pegjs = require('pegjs'); | ||
|
||
//load | ||
module.exports = function (single, all) { | ||
var i, n; | ||
|
||
var flag = 0; | ||
|
||
var flagcb = function () { | ||
if (flag < 1) { | ||
all(); | ||
} | ||
}; | ||
|
||
var makeParU = function (url, name) { | ||
name = name || url.split("/")[3] | ||
flag += 1; | ||
request(url, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
var scheem = pegjs.buildParser(body); | ||
|
||
var par = function (str, start) { | ||
try { | ||
return scheem.parse(str, start); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
}; | ||
//console.log(name, "loaded"); | ||
single(par, name); | ||
} else { | ||
console.log("Error in fetching", url, error); | ||
} | ||
flag -= 1; | ||
flagcb(); | ||
}); | ||
}; | ||
|
||
var urls = fs.readFileSync("repos.txt", "utf8").split("\n"); | ||
var u; | ||
n = urls.length; | ||
for (i = 0; i < n; i += 1){ | ||
u = urls[i].trim(); | ||
if (!u || u[0] === "!") { | ||
continue; | ||
} | ||
console.log(u) | ||
makeParU(u); | ||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
https://raw.github.com/jostylr/nathansuniversity/master/scheem/scheem.pegjs | ||
https://raw.github.com/McLeopold/PL101/master/scheem/scheem.peg | ||
https://raw.github.com/arcanis/trivia.nathan-s-university/master/scheem/lib/grammar.peg | ||
!https://raw.github.com/tdieb/PL101/master/scheem/scheem.peg | ||
!https://raw.github.com/danielparks/nu-pl101-scheem/master/scheem.peg | ||
!https://raw.github.com/p07r0457/NU_Compiler_Class/master/my.peg | ||
!https://raw.github.com/schettino72/PL101/master/scheem.peg | ||
https://raw.github.com/tsiivola/NathansUniversity/master/scheem/scheem.peg | ||
https://raw.github.com/manvel7650/JavascriptLanguage/master/scheme/scheme.peg | ||
!https://raw.github.com/fbs/nathan-pl101/master/peg/scheem/parser.pegjs | ||
https://raw.github.com/joekarl/NathansUniversityRepo/master/scheem/Scheem.peg | ||
!https://raw.github.com/Bogdanp/PL101/master/Scheem/Scheem.peg | ||
!https://raw.github.com/DominionSpy/pl101/master/lesson3-part1/scheem.peg | ||
https://raw.github.com/QWRp/PL101/master/scheem/scheem.peg | ||
!https://raw.github.com/chrisvest/nathansuni-js-lang/master/scheem/scheem.peg | ||
!https://raw.github.com/adamipc/pl101/master/scheem/scheem.peg | ||
!https://raw.github.com/lmpessoa-pl101/pl101/master/scheem/scheem.peg | ||
https://raw.github.com/SameDifference/pl101/master/peg/peg.js | ||
https://raw.github.com/aheaume/PL101/master/scheem/scheem.pegjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/*globals module, require, console, exports*/ | ||
|
||
var fs = require('fs'); | ||
var nu = require('nodeunit'); | ||
var load = require('./load'); | ||
|
||
var pegjs = require('pegjs'); | ||
|
||
var ref = fs.readFileSync("bm.scm", "utf8"); | ||
|
||
var parserTests = { | ||
basics: function (test) { | ||
var par = this.par; | ||
test.expect(6); | ||
test.equal(par(""), undefined, "don't parse empty string"); | ||
test.deepEqual(par("@"), "@", "single char @"); | ||
test.deepEqual(par("atom"), "atom", "word"); | ||
test.deepEqual(par("(a b c)"), ["a", "b", "c"], "abc"); | ||
test.deepEqual(par("(+ x 3)"), ["+", "x", "3"], "parse (+ x 3)"); | ||
test.deepEqual(par("(+ 1 (f x 3 y))"), ["+", "1", ["f", "x", "3", "y"]], "parse (+ 1 (f x 3 y))"); | ||
test.done(); | ||
} | ||
, space : function (test) { | ||
var par = this.par; | ||
test.expect(6); | ||
test.equal(par(" "), undefined, "don't parse white space only string"); | ||
test.deepEqual(par(" @"), "@", " @"); | ||
test.deepEqual(par("atom "), "atom", "atom "); | ||
test.deepEqual(par(" ( a b c ) "), ["a", "b", "c"], " ( a b c ) "); | ||
test.deepEqual(par("(+ \t x \n 3)"), ["+", "x", "3"], "parse (+ \t x \n 3)"); | ||
test.deepEqual(par("(+ 1 \n \t (f x 3 y) \n)"), ["+", "1", ["f", "x", "3", "y"]], "(+ 1 \n \t (f x 3 y) \n)"); | ||
test.done(); | ||
} | ||
, quote : function (test) { | ||
var par = this.par; | ||
test.expect(3); | ||
test.deepEqual(par("'x"), ["quote", "x"], "'x"); | ||
test.deepEqual(par("'(1 2 3)"), ["quote", ["1", "2", "3"]]); | ||
test.deepEqual(par("(+ '1 \n \t (f x 3 y) \n)"), ["+", ["quote", "1"], ["f", "x", "3", "y"]], "(+ '1 \n \t (f x 3 y) \n)"); | ||
test.done(); | ||
} | ||
, comments : function (test) { | ||
var par = this.par; | ||
test.expect(3); | ||
test.equal(par(";; this is a comment"), undefined, "don't parse comment only"); | ||
test.deepEqual(par(";; first comment\nx"), "x", ";; first comment\n x"); | ||
test.deepEqual(par("x\n;; later comment"), "x", "x\n;; later comment"); | ||
test.done(); | ||
} | ||
, reference : function (test) { | ||
var par = this.par; | ||
test.expect(1); | ||
test.deepEqual(par(ref), ["+", "1", "2", "f", ["x", "y", "z", ["quote", ["1", "2", "3"]]], "g", ["1", "2", "atome", "just", "kidding"]], "reference one"); | ||
test.done(); | ||
} | ||
|
||
}; | ||
|
||
var clone = function (obj) { | ||
var ret = {}; | ||
var key; | ||
for (key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
ret[key] = obj[key]; | ||
} | ||
} | ||
return ret; | ||
}; | ||
|
||
|
||
var tests = {}; | ||
|
||
load(function (par, name) { | ||
var t = tests[name] = clone(parserTests); | ||
|
||
t.setUp = function (cb) { | ||
this.par = par; | ||
cb(); | ||
}; | ||
|
||
try{ | ||
nu.runSuite(name, t, {}, function (a, b) { | ||
var i | ||
, count = 0 | ||
, failed = 0 | ||
, n = b.length | ||
; | ||
|
||
for (i = 0; i < n; i += 1 ){ | ||
count += 1; | ||
if (b[i].failed() ) { | ||
failed += 1; | ||
//console.log(name, b[i].error); | ||
} | ||
} | ||
if (failed > 0) { | ||
console.log(name, failed, "failed out of", count ); | ||
} | ||
}); | ||
} catch (e) { | ||
console.log(name, "error"); | ||
} | ||
}, function () { | ||
; | ||
}); | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters