mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-01-01 14:52:08 -08:00
Replace pegs parser with Esprima
It preserves comments and text positions, enabling us to do syntax highlighting. Hopefully.
This commit is contained in:
parent
470b622bb1
commit
f6338d9109
68 changed files with 109553 additions and 8077 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue