Is it possible to reprocess the whole sytanx tree again?
The context:
I’m creating a language package for Excel functions. One of the peculiarities is that some tokens change according to the idiom. For example, the Boolean token can be TRUE (English) or VERDADEIRO (Portuguese).
I created an external token that handles this based on the currIdiom variable:
Everything is working, but when I switch between languages, it seems to me that it keeps the previous syntax tree, I need to type something to update. See the example below, TRUE is in purple (recognized as a BoolToken when language is en-US), but when I change it to Portuguese, I need to type something to stop being purple (= no longer recognized as a BoolToken):
How can I force a reprocess so that highlighting works when switching idiom?
Pass the language as a parameter to whatever creates the parser, and update your configuration to use a new parser whenever the language setting is changed.
No. You can use dialects or reconfigured external tokenizers to make small changes like that. Recompiling the grammar should never be necessary at run-time.