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 +}