2 Commits

Author SHA1 Message Date
b6b98ca98d 错误提示汉化 2022-08-29 12:16:26 +08:00
Andrey Gubanov
1810184186 add updated web version 2020-09-16 15:53:58 +03:00
2 changed files with 15 additions and 9 deletions

View File

@@ -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,

View File

@@ -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);
}
}