selfhost: fix parser infinite loop + lexer token limit
- Parser_Parse: add beforePos safeguard to skip unrecognized tokens instead of looping forever when parserParseDecl returns null - Lexer: increase maxTokens 4096 -> 32768; add explicit break on limit - CLI: null-check ReadFile result before String_Eq - Nim CLI: add -O2 to cc invocation for faster self-hosted builds
This commit is contained in:
@@ -1195,12 +1195,17 @@ func Parser_Parse(tokens: *LexToken, tokenCount: int) -> *Module {
|
||||
discard parserAdvance(p);
|
||||
continue;
|
||||
}
|
||||
let beforePos: int = p.pos;
|
||||
let decl: *Decl = parserParseDecl(p);
|
||||
if decl != null as *Decl {
|
||||
decl.childDecl2 = mod.firstItem; // push front
|
||||
mod.firstItem = decl;
|
||||
mod.itemCount = mod.itemCount + 1;
|
||||
}
|
||||
// Infinite-loop safeguard: if no progress, skip token
|
||||
if p.pos == beforePos {
|
||||
discard parserAdvance(p);
|
||||
}
|
||||
}
|
||||
|
||||
return mod;
|
||||
|
||||
Reference in New Issue
Block a user