Closed ellerh closed 7 years ago
Thanks! I'm not up to speed on Emacs syntax tables. Could you please give me a brief description on what's going on in forth--syntax-propertize
?
By the way, thank you so much for your work with SLIME. It's a pleasure to work with.
Could you please give me a brief description on what's going on in forth--syntax-propertize
In general terms: it sets the syntax-table
text-property at places where the normal syntax-table is not sufficient.
Specifically it searches occurrences of (
and \
and if those chars are not surrounded by whitespace sets the syntax to "symbol". It uses syntax-ppss to skip occurrences eg. in strings. Additionally for (
it searches the next )
and sets its syntax to "generic comment delimiter". All this is fused into one loop for efficiency but obvoiusly not easy to read.
Actually I found a case that is still not handled correclty: "( ( )".
Maybe it would be clearer to make forth--syntax-propertize
a small state machine with four states: comment, string, word and whitespace. After figuring out the initial state it seems easy to scan forward for the next potential state switch.
Thanks for the explanation.
Wouldn't it be possible to mimic the Forth parser? Just look at whitespace-delimited tokens and skip ahead if there's a comment or a string?
Wouldn't it be possible to mimic the Forth parser? Just look at whitespace-delimited tokens and skip ahead if there's a comment or a string?
Yes, probably. That's roughly what I meant with the 4-state state machine.
This is a possible way to handle ( ...) comments. Unfortunatly,
forth--syntax-propertize
is already quite complicated and will only become more so if it needs to handle more cases.