Reputation: 136
Does anyone know a way how I could reserve keyword in a case-insensitve way in Rascal?
Due to issue #968 as reported on GitHub (https://github.com/usethesource/rascal/issues/968) I cannot simply use single quotes. This issue will probably be solved. ince I am currently working with a language where keywords are not case-sensitive and trying to analyze code in which someone apparently randomly applied camelcase or all capitals in keywords, however, I am looking for a workaround. For now I am just defining each keyword in three ways. Since there are mistakes in application of camelcase,(like GroupbyGroup, which should have been GroupByGroup in camelcase) I keep having to redefine keywords in even more different ways. Therefore, I was hoping someone would know of a better workaround (or can solve this issue obviously).
Upvotes: 0
Views: 50
Reputation: 15439
The following grammar is automatically extended to define what 'abc'
means
lexical CaseInsensitive = 'abc';
like so:
lexical CaseInsensitive = 'abc';
lexical 'abc' = [aA][bB][cC];
You could do that by yourself as well for your grammar, but it will not change the semantics of disambiguation. The \
notation simply does not subtract the regular languages generated by [aA][bB][cC]
from the context-free language yet. It is not implemented.
A good temporary workaround would be to keep the grammar ambiguous, and use rascal code to filter out the correct tree.
Upvotes: 1