Replace pegs parser with Esprima

It preserves comments and text positions, enabling us to do syntax
highlighting. Hopefully.
This commit is contained in:
Jeremy Ruston 2012-03-01 22:47:31 +00:00
parent 470b622bb1
commit f6338d9109
68 changed files with 109553 additions and 8077 deletions

View file

@ -10,16 +10,15 @@ Parses JavaScript source code into a parse tree using PEGJS
"use strict";
var JavaScriptParseTree = require("./JavaScriptParseTree.js").JavaScriptParseTree,
pegjs = require("pegjs");
esprima = require("esprima");
// Initialise the parser
var JavaScriptParser = function(parserText) {
this.parser = pegjs.buildParser(parserText);
var JavaScriptParser = function() {
};
// Parse a string of JavaScript code and return the parse tree
JavaScriptParser.prototype.parse = function(code) {
return new JavaScriptParseTree(this.parser.parse(code),this);
return new JavaScriptParseTree(esprima.parse(code));
};
// Create a parse tree object from a raw tree