From a7cd4a0ff28ae2d3a1fcf731bb778302297e12d8 Mon Sep 17 00:00:00 2001 From: lq8152 Date: Tue, 22 Oct 2019 00:22:05 +0800 Subject: [PATCH] Update SimpleLexer.java --- lab/craft/SimpleLexer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lab/craft/SimpleLexer.java b/lab/craft/SimpleLexer.java index 329e43b..c902593 100644 --- a/lab/craft/SimpleLexer.java +++ b/lab/craft/SimpleLexer.java @@ -273,6 +273,8 @@ public static void dump(SimpleTokenReader tokenReader){ while ((token= tokenReader.read())!=null){ System.out.println(token.getText()+"\t\t"+token.getType()); } + //此处应该重置pos,否则打印完以后,指针已到token流的末尾,后续如果继续调用TokenReader会导致错误。 + tokenReader.setPosition(0); } /** @@ -342,4 +344,4 @@ public void setPosition(int position) { } -} \ No newline at end of file +}