Improved error handling.

git-svn-id: https://shellinabox.googlecode.com/svn/trunk@107 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac 2009-04-01 19:51:14 +00:00
parent 15e4d5990f
commit c1e181ec98
2 changed files with 14 additions and 6 deletions

View file

@ -173,10 +173,11 @@ Demo.prototype.error = function(msg) {
}
this.vt100((this.cursorX != 0 ? '\r\n' : '') + '\u0007? ' + msg +
(this.currentLineIndex >= 0 ?
' in line ' + this.program[this.currentLineIndex].lineNumber() :
' in line ' + this.program[this.evalLineIndex].lineNumber() :
'') + '\r\n');
this.gotoState(2 /* STATE_PROMPT */);
this.currentLineIndex = -1;
this.evalLineIndex = -1;
return undefined;
};
@ -203,6 +204,7 @@ Demo.prototype.doPrompt = function() {
this.keys = '';
this.line = '';
this.currentLineIndex = -1;
this.evalLineIndex = -1;
this.vt100((this.cursorX != 0 ? '\r\n' : '') + '> ');
this.gotoState(3 /* STATE_READLINE */);
return false;
@ -272,6 +274,7 @@ Demo.prototype.doCommand = function() {
}
} else {
this.currentLineIndex = -1;
this.evalLineIndex = -1;
this.tokens = tokens;
this.gotoState(5 /* STATE_EVAL */);
}
@ -420,7 +423,8 @@ Demo.prototype.doPrint = function() {
};
Demo.prototype.doExec = function() {
this.tokens = this.program[this.currentLineIndex++].tokens();
this.evalLineIndex = this.currentLineIndex++;
this.tokens = this.program[this.evalLineIndex].tokens();
this.tokens.reset();
this.doEval();
if (this.currentLineIndex < 0) {
@ -547,7 +551,7 @@ Demo.prototype.term = function() {
Demo.prototype.factor = function() {
var token = this.tokens.nextToken();
if (!token) {
return token;
return this.error();
}
var value = undefined;

View file

@ -173,10 +173,11 @@ Demo.prototype.error = function(msg) {
}
this.vt100((this.cursorX != 0 ? '\r\n' : '') + '\u0007? ' + msg +
(this.currentLineIndex >= 0 ?
' in line ' + this.program[this.currentLineIndex].lineNumber() :
' in line ' + this.program[this.evalLineIndex].lineNumber() :
'') + '\r\n');
this.gotoState(STATE_PROMPT);
this.currentLineIndex = -1;
this.evalLineIndex = -1;
return undefined;
};
@ -203,6 +204,7 @@ Demo.prototype.doPrompt = function() {
this.keys = '';
this.line = '';
this.currentLineIndex = -1;
this.evalLineIndex = -1;
this.vt100((this.cursorX != 0 ? '\r\n' : '') + '> ');
this.gotoState(STATE_READLINE);
return false;
@ -272,6 +274,7 @@ Demo.prototype.doCommand = function() {
}
} else {
this.currentLineIndex = -1;
this.evalLineIndex = -1;
this.tokens = tokens;
this.gotoState(STATE_EVAL);
}
@ -420,7 +423,8 @@ Demo.prototype.doPrint = function() {
};
Demo.prototype.doExec = function() {
this.tokens = this.program[this.currentLineIndex++].tokens();
this.evalLineIndex = this.currentLineIndex++;
this.tokens = this.program[this.evalLineIndex].tokens();
this.tokens.reset();
this.doEval();
if (this.currentLineIndex < 0) {
@ -547,7 +551,7 @@ Demo.prototype.term = function() {
Demo.prototype.factor = function() {
var token = this.tokens.nextToken();
if (!token) {
return token;
return this.error();
}
var value = undefined;