4

Working to create my own major mode for sqf language (arma3 scripting) I get this error:

Error during redisplay: (jit-lock-function 1) signaled (invalid-regexp "Regular expression too big")
Error during redisplay: (jit-lock-function 501) signaled (invalid-regexp "Regular expression too big")

The issue is a list of specific built-in language commands that reaches about 2500 of them initialized as following:

(defvar arma-commands
  '(
    "abs"
    "accTime"
    ... 
    "worldToScreen" ;; thats the 2500th command ;-)
    ))

Using the common (,(regexp-opt arma-commands 'words) . font-lock-builtin-face) for highlighting properly raises that error I mentioned before.

Is there any right and efficient way to solve this?

3
  • 3
    You could split it into multiple font-lock rules, where each rule would handle, say, 2000 entries. Having said this, is this really a god way to highlight a language? Maybe you could find highlighting rules which doesn't require a fixed list of reserved words. Commented Jul 13, 2022 at 16:54
  • To add to my earlier response at emacs.stackexchange.com/a/72596/31220 .... Assuming 2500 words, back of napkin calculation shows that, the avg. size of each word has to be 26 = (/ (expt 2 16) 2500) for the jit lock to explode every time. What is the total length of all the words in your regexp?
    – user31220
    Commented Jul 15, 2022 at 3:45
  • 2503 words as you can see it at this site: community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands. Actually @Lindydancer has the right answer: splitting all the scripting commands in groups although it also possible matching just a part of it (prefix) and not the enterely word (lot of commands share the same prefix).
    – xbelanch
    Commented Jul 15, 2022 at 7:34

1 Answer 1

7

REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */

According to https://git.savannah.gnu.org/cgit/emacs.git/tree/src/regex-emacs.c?h=53c0690fa28f338071703f1567d2d1c4054416f0#n1231

/* This is not an arbitrary limit: the arguments which represent offsets
   into the pattern are two bytes long.  So if 2^15 bytes turns out to
   be too small, many things would have to change.  */

# define MAX_BUF_SIZE (1 << 15)

So, I believe you are out of luck in configuring the limit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.