Sublime Forum

[syntax definition] Is adding a context to consume whitespace worth adding?

#1

I have a language that has a json-like structure, with values being separated from keys by \s*=\s*. Taking a,dvantage of this, if the syntax detects a key followed by whitespace and a value, it’ll mark the whitespace as illegal.missing-equals-sign. However, the space between a value and the next-key is useless.

Question is, then, will the syntax be more performan if after a value I added a context to consume the whitespace? Note that the possible keys and the values each key accepts is predefined in the language, so the syntax is quite complex in that aspect. If the syntax works by trying to match each character with all the patterns in the active context,I guess consuming wuitespace after the values could save quite a bit of processing time. What do you think?

0 Likes

#2

Probably not, because Sublime’s custom regexp engine (probably) compiles patterns into finite automata. Matching should take linear time regardless of the complexity of the pattern.

0 Likes