Fix nextToken() EOF error
This commit is contained in:
@@ -140,12 +140,17 @@ class Reader {
|
|||||||
public static final terminators = [")", "]", "}", '"', "/*", "\n", " "];
|
public static final terminators = [")", "]", "}", '"', "/*", "\n", " "];
|
||||||
|
|
||||||
public static function nextToken(stream:Stream, expect:String) {
|
public static function nextToken(stream:Stream, expect:String) {
|
||||||
var tok = stream.expect(expect, () -> stream.takeUntilOneOf(terminators));
|
switch (stream.takeUntilOneOf(terminators)) {
|
||||||
if (tok.length == 0) {
|
case Some(tok) if (tok.length > 0):
|
||||||
stream.error('Expected $expect');
|
return tok;
|
||||||
return null;
|
case None if (stream.content.length > 0):
|
||||||
|
var tok = stream.content;
|
||||||
|
stream.dropChars(stream.content.length);
|
||||||
|
return tok;
|
||||||
|
default:
|
||||||
|
stream.error('Expected $expect');
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return tok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function assertRead(stream:Stream, k:KissState):ReaderExp {
|
public static function assertRead(stream:Stream, k:KissState):ReaderExp {
|
||||||
|
|||||||
Reference in New Issue
Block a user