mirror of
https://github.com/circlecell/jsonlint-mod.git
synced 2026-01-21 05:07:49 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6b98ca98d | |||
|
|
1810184186 |
@@ -123,10 +123,11 @@ parse: function parse(input) {
|
||||
}
|
||||
var errStr = '';
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
errStr = '第 '+(yylineno+1)+" 行解析出现错误:\n"+this.lexer.showPosition()
|
||||
+"\n期望是 "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
} else {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||
errStr = '第 '+(yylineno+1)+" 行解析出现错误: 不应该以 " +
|
||||
(symbol == 1 /*EOF*/ ? "作为结尾" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
}
|
||||
this.parseError(errStr,
|
||||
|
||||
@@ -483,11 +483,12 @@ parse: function parse(input) {
|
||||
}
|
||||
var errStr = '';
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
errStr = '第 '+(yylineno+1)+" 行解析出现错误:\n"+this.lexer.showPosition()
|
||||
+"\n期望是 "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
} else {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
errStr = '第 '+(yylineno+1)+" 行解析出现错误: 不应该以 " +
|
||||
(symbol == 1 /*EOF*/ ? "作为结尾" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
}
|
||||
this.parseError(errStr,
|
||||
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||
@@ -782,8 +783,12 @@ jsonlint.parse = function(input) {
|
||||
dougJSONParse(input);
|
||||
} catch(e) {
|
||||
if(/Duplicate key|Bad string|Unexpected/.test(e.message)) {
|
||||
var lineNumber = input.substring(0, e.at).split('\n').length;
|
||||
throw SyntaxError(e.message + ' on line ' + lineNumber);
|
||||
var linesUntilError = input.substring(0, e.at).split('\n');
|
||||
var line = linesUntilError.length;
|
||||
var col = linesUntilError[line - 1].length - 1;
|
||||
|
||||
this.parseError(e.message, {line: line, col: col, message: e.message.replace(/./, function(l) { return l.toLowerCase(); })});
|
||||
throw SyntaxError(e.message + ' on line ' + line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user