Implement case-insensitive scripting language
maelmahdy86 opened this issue · 8 comments
Hi,
I've a situation where I need to implement a small scripting language in my system but it must be case-insensitive
Is it supported by csly?
could you explain a bit more what a case insensitive language is for you ? have you any example of typical source code ?
@b3b00 for example, to declare a new variable, user can type: declare x or DECLARE x or DeclArE x
DECLARE keyword should be parsed at all cases
This is basically a lexing probelm as You have to label every possible casing od "declare" as a declare
token. For a short keword you could enumerate all possible casing. For instance a "let" keword can have 2^3 = 8 casing. but declare is 7 letters long and 2^7 is 128 possibilities !
If I have to give it a go I will use the generic lexer with lexer callbacks.
Let me some time to show you with a simple sample.it 's weekend time for now
I quickly coded a sample as a unit test. You can find it https://github.com/b3b00/csly/tree/fix/267/ParserTests/Issue267.
I have problems compiling csly right now (dont now why) so I have not tested it. But the general idea is there :
Thanks for your quick response
unfortunately, the callback solution didn't work but I managed to make it work following your suggestion to go with generic lexer
I highly recommend that you support this feature with other types of lexers as well as it's very common requirement when it comes to embedded scripting languages :)
@maelmahdy86 Indeed my solution can not work without losing syntax checking. Could you share how you 've solved this ?
For tracking and maybe feature enhancement ....
Thanks for your answer, I did not even remember of this feature 😊