mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-02-23 18:39:50 +00:00
Replace pegs parser with Esprima
It preserves comments and text positions, enabling us to do syntax highlighting. Hopefully.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user