Languages like SQL, SPARQL, Fortran and BASIC have case-insensitive keywords.
Currently, if you want such keywords in your SDF3 grammar, you need to introduce a character class for each keyword yourself:

lexical syntax
  HEAD           = [Hh][Ee][Aa][Dd]

context-free syntax
  BuiltInCall.Head = <<HEAD>().<Prop>>

This means that you have to introduce extra non-terminals in your context-free production, which clutters the ASTs and also messes up the generated code completion templates.

We can avoid these problems by creating native SDF3 support for case-insensitive keywords. Functionally, this would mean:
- character classes are generated and don’t need to be defined by the user
- a default keyword format (all upper case characters / all lower case characters / first character upper case) can be defined by the user and will be used for pretty-printing and code completion purposes.

Possibly, it is sufficient to turn case-insensitive keywords on/off on a per-language basis, rather than defining for each individual keyword whether it is case-insensitive or not. The pretty-printer/code-completer would then use whatever the user specified in the context-free syntax. For example, BuiltInCall.Head = <hEaD().<Prop>> is pretty-printed as hEaD()....

Submitted by Oskar van Rest on 26 March 2015 at 11:47

On 26 March 2015 at 12:02 Eduardo Amorim commented:

SDF2 actually supports case insensitive keywords by using single-quoted literals in productions (
In SDF3, there is currently not support for it because every literal is translated to a SDF2 double-quoted literal and therefore it is automatically case-sensitive.
I have been thinking about how to specify this with the proper granularity (per keyword, per production, per section or per file) and then make it part of the formalism.
Currently, what you can do, if you don’t worry that much about the generated pp/code completion is to write the production in the productive form, as in:

      context-free syntax
         BuiltInCall.Head = 'HEAD' "(" ")" "." Prop

and use single quote for literals that you want to be case-insensitive.

On 26 March 2015 at 13:33 Oskar van Rest commented:

Great to hear there is already some support for this. Looking forward to seeing this in SDF3.

Somehow the SDF Yellowgrass project is hidden for me (“You are not allowed to visit this page”). Whoever manages the project should open it up.

On 15 December 2015 at 16:31 Eduardo Amorim commented:

By using the {case-insensitive} attribute, all keywords in a template can be parsed as case-insensitive literals.

On 15 December 2015 at 16:31 Eduardo Amorim closed this issue.

Log in to post comments