!3 bug: 允许文件直接以 EOF 结束 <code>end module</code>

Merge pull request !3 from Luke/bugfix/fix-module-space-line-can-not-compile
This commit is contained in:
Luke 2025-06-09 13:14:37 +00:00 committed by Gitee
commit ff488ae595
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 2 additions and 3 deletions

View File

@ -17,7 +17,7 @@ public record ParserEngine(ParserContext ctx) {
List<String> errs = new ArrayList<>(); List<String> errs = new ArrayList<>();
TokenStream ts = ctx.getTokens(); TokenStream ts = ctx.getTokens();
while (ts.isAtEnd()) { // 取反 while (ts.isAtEnd()) {
// 跳过空行 // 跳过空行
if (ts.peek().getType() == TokenType.NEWLINE) { if (ts.peek().getType() == TokenType.NEWLINE) {
ts.next(); ts.next();

View File

@ -88,9 +88,8 @@ public class ModuleParser implements TopLevelParser {
// 确保模块体以 "end module" 结束 // 确保模块体以 "end module" 结束
ts.expect("end"); ts.expect("end");
ts.expect("module"); ts.expect("module");
ts.expectType(TokenType.NEWLINE);
// 构建并返回完整的模块语法树节点 // 构建并返回完整的模块语法树节点
return new ModuleNode(name, imports, functions); return new ModuleNode(name, imports, functions);
} }
} }