Add SourceLocation to encapsulate Token/ParseNode debug information. (#904)

* Add SourceLocation to encapsulate Token/ParseNode debug information.

* Specify concrete Token text type as it captures type mismatches.

* Responded to comments.
This commit is contained in:
Ashish Myles
2017-09-25 14:29:41 -04:00
committed by Kevin Barabash
parent f10ea4cbeb
commit 59bed2ad08
7 changed files with 68 additions and 44 deletions

View File

@@ -61,10 +61,8 @@ const stripPositions = function(expr) {
if (typeof expr !== "object" || expr === null) {
return expr;
}
if (expr.lexer && typeof expr.start === "number") {
delete expr.lexer;
delete expr.start;
delete expr.end;
if (expr.loc && expr.loc.lexer && typeof expr.loc.start === "number") {
delete expr.loc;
}
Object.keys(expr).forEach(function(key) {
stripPositions(expr[key]);