1 Commits

Author SHA1 Message Date
b6b98ca98d 错误提示汉化 2022-08-29 12:16:26 +08:00
2 changed files with 9 additions and 7 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});