Standardized reader nextToken() error
This commit is contained in:
@@ -5,6 +5,7 @@ import kiss.Stream;
|
|||||||
import kiss.Kiss;
|
import kiss.Kiss;
|
||||||
|
|
||||||
using kiss.Reader;
|
using kiss.Reader;
|
||||||
|
using kiss.Stream;
|
||||||
|
|
||||||
typedef ReaderExp = {
|
typedef ReaderExp = {
|
||||||
pos:Position,
|
pos:Position,
|
||||||
@@ -96,7 +97,9 @@ class Reader {
|
|||||||
public static function nextToken(stream:Stream, expect:String) {
|
public static function nextToken(stream:Stream, expect:String) {
|
||||||
var tok = stream.expect(expect, () -> stream.takeUntilOneOf(terminators));
|
var tok = stream.expect(expect, () -> stream.takeUntilOneOf(terminators));
|
||||||
if (tok.length == 0) {
|
if (tok.length == 0) {
|
||||||
throw 'Expected token $expect at ${stream.position()}';
|
Sys.println('Kiss reader error!');
|
||||||
|
Sys.println(stream.position().toPrint() + ': Expected $expect');
|
||||||
|
Sys.exit(1);
|
||||||
}
|
}
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user