Skip to content

Commit

Permalink
remove marks due to complexity of newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 4, 2019
1 parent 459389a commit adf54c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
11 changes: 3 additions & 8 deletions packages/moon/dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,14 @@
var parseError = tree;

do {
parseErrors += "".concat(parseError.message, "\n");
var tokenStrings = "";
var marks = ""; // Collect the tokens responsible for the error as well as the
parseErrors += "".concat(parseError.message, "\n"); // Collect the tokens responsible for the error as well as the
// surrounding tokens.

for (var i = Math.max(0, parseError.start - 1); i < Math.min(parseError.end + 1, tokens.length); i++) {
var currentTokenString = tokenString(tokens[i]);
tokenStrings += currentTokenString; // If the token was directly responsible for the error, mark it.

marks += (i >= parseError.start && i < parseError.end ? "^" : " ").repeat(currentTokenString.length);
parseErrors += tokenString(tokens[i]);
}

parseErrors += "".concat(tokenStrings, "\n").concat(marks, "\n\n");
parseErrors += "\n\n";
} while ((parseError = parseError.next) !== undefined);

error("Parser failed to process the view.\n\n".concat(parseErrors));
Expand Down
2 changes: 1 addition & 1 deletion packages/moon/dist/moon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions packages/moon/src/compiler/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,29 +187,17 @@ export function parse(tokens) {
do {
parseErrors += `${parseError.message}\n`;

let tokenStrings = "";
let marks = "";

// Collect the tokens responsible for the error as well as the
// surrounding tokens.
for (
let i = Math.max(0, parseError.start - 1);
i < Math.min(parseError.end + 1, tokens.length);
i++
) {
const currentTokenString = tokenString(tokens[i]);

tokenStrings += currentTokenString;

// If the token was directly responsible for the error, mark it.
marks += (
(i >= parseError.start && i < parseError.end) ?
"^" :
" "
).repeat(currentTokenString.length);
parseErrors += tokenString(tokens[i]);
}

parseErrors += `${tokenStrings}\n${marks}\n\n`;
parseErrors += "\n\n";
} while ((parseError = parseError.next) !== undefined);

error(`Parser failed to process the view.\n\n${parseErrors}`);
Expand Down

0 comments on commit adf54c6

Please sign in to comment.