aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/lexer.lua
diff options
context:
space:
mode:
authororbitalquark <70453897+orbitalquark@users.noreply.github.com>2024-09-12 21:52:09 -0400
committerRandy Palamar <randy@rnpnr.xyz>2025-01-04 12:20:21 -0700
commit603bc09d0f6235379f9026b25a5f78bf490a6704 (patch)
tree58b819bdfe41dd5f950018d7b30758dfcd5e8c30 /lua/lexers/lexer.lua
parentc51b9e952d4565dcca259baaf30dd035a1ae9c11 (diff)
downloadvis-603bc09d0f6235379f9026b25a5f78bf490a6704.tar.gz
vis-603bc09d0f6235379f9026b25a5f78bf490a6704.tar.xz
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.
Diffstat (limited to 'lua/lexers/lexer.lua')
-rw-r--r--lua/lexers/lexer.lua2
1 files changed, 2 insertions, 0 deletions
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',