Cleaned up JavaScript processing

I'm slowly trying to make the JavaScript processing and the WikiText
processing use the same conventions
This commit is contained in:
Jeremy Ruston 2012-01-04 18:31:19 +00:00
parent 5eeb45cd79
commit 3ff1d9a76c
9 changed files with 196 additions and 175 deletions

29
js/JavaScriptParser.js Normal file
View file

@ -0,0 +1,29 @@
/*\
title: js/JavaScriptParser.js
JavaScript processing
\*/
(function(){
/*jslint node: true */
"use strict";
var JavaScriptParseTree = require("./JavaScriptParseTree.js").JavaScriptParseTree,
pegjs = require("pegjs");
var JavaScriptParser = function(parserText) {
this.parser = pegjs.buildParser(parserText);
};
JavaScriptParser.prototype.parse = function(code) {
return new JavaScriptParseTree(this.parser.parse(code),this);
};
JavaScriptParser.prototype.createTree = function(tree) {
return new JavaScriptParseTree(tree,this);
};
exports.JavaScriptParser = JavaScriptParser;
})();