2011-12-21 16:54:51 +00:00
|
|
|
/*\
|
|
|
|
title: js/Sandbox.js
|
|
|
|
|
|
|
|
Execute a fragment of JavaScript in a sandbox
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2011-12-21 17:21:28 +00:00
|
|
|
/*jslint evil: true, node: true */
|
2011-12-21 16:54:51 +00:00
|
|
|
"use strict";
|
|
|
|
|
2011-12-28 22:07:17 +00:00
|
|
|
var pegjs = require("pegjs");
|
2011-12-21 16:54:51 +00:00
|
|
|
|
2011-12-28 22:07:17 +00:00
|
|
|
var Sandbox = function(parserText) {
|
|
|
|
this.parser = pegjs.buildParser(parserText);
|
|
|
|
};
|
|
|
|
|
2012-01-03 11:08:41 +00:00
|
|
|
Sandbox.prototype.parse = function(code) {
|
|
|
|
return this.parser.parse(code);
|
2012-01-03 11:38:15 +00:00
|
|
|
};
|
2012-01-03 11:08:41 +00:00
|
|
|
|
2011-12-28 22:07:17 +00:00
|
|
|
exports.Sandbox = Sandbox;
|
2011-12-21 16:54:51 +00:00
|
|
|
|
|
|
|
})();
|