From 603bc09d0f6235379f9026b25a5f78bf490a6704 Mon Sep 17 00:00:00 2001 From: orbitalquark <70453897+orbitalquark@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:52:09 -0400 Subject: Increase the default LPeg stack size It is not clear how large this value should be. It appears to be a function of grammar complexity. For example, a problematic HTML file requires a value of 1329 to work, but removing either the 'attribute' rule or an embedded lexer reduces the limit. However, identifying which files trigger a stack overflow is not trivial. It does not appear to depend on file size. For example, the problematic HTML file is 125K, but a non-problematic HTML file of 500K works. --- lua/lexers/lexer.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lua/lexers/lexer.lua') diff --git a/lua/lexers/lexer.lua b/lua/lexers/lexer.lua index 12a1404..791e810 100644 --- a/lua/lexers/lexer.lua +++ b/lua/lexers/lexer.lua @@ -781,6 +781,8 @@ local lpeg = lpeg local P, R, S, V, B = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.B local Ct, Cc, Cp, Cmt, C = lpeg.Ct, lpeg.Cc, lpeg.Cp, lpeg.Cmt, lpeg.C +lpeg.setmaxstack(2048) -- the default of 400 is too low for complex grammars + --- Default tags. local default = { 'whitespace', 'comment', 'string', 'number', 'keyword', 'identifier', 'operator', 'error', -- cgit v1.2.3