Closed HuibSprangers-leiden closed 2 years ago
I've been working on this for a bit now and I've come up to a snag. Basically, from what I can tell, the parser currently works in syntaxModesRules.ts using the hardcoded keywords, e.g. 'print' in the functions. Naturally the next step to making this work with other languages would be to make these hardcoded keywords be used dynamically depending on the current language. To get the current language is simple in typescript using window.State.lang. But obtaining the relevant keywords for this language within the typescript is where I end up getting stuck.
The way I've been trying to make this work so far is by creating a method within syntaxModesRules to search for the relevant keyword within the keyword-
So I've been a bit stuck trying to figure out what the best approach to this issue is, my current plan is to assign the previously hardcoded keywords to variables and overwrite these whenever the site's language is changed, but I'm not quite sure how viable of a strategy this would be either.
Which is why I made this comment to explain why this hasn't received much of an update and ask @Felienne (or anybody else reading this) about whether or not I'm on the right track/ if there's a better solution to the issue.
Hi @HuibSprangers-leiden!
I understand how hard this issue is because of the hard coding of keywords. My proposal would be to do this as follows:
This approach will also allow us to create "mixed highlighters" that correctly highlight programs with Dutch and English keywords are used together
Thanks for the help and the quick reply @Felienne. So, if I understand it right, then I'll need to make it work like this:
Is this fitting with what you had in mind?
Yes that is more or less what I had in mind! I only think we'd want to do the generation in a separate file, not necessarily in generate-typescript (because that is a compiler and we would do different things here)
Okay, thanks a ton for the help! I should be able to work with this.
Currently, if you change the keyword in the parser, it will use it but not highlight it