Comment-like keywords ?

  • Hi community,

    I am currently writing a style for a new programming language (that one is for kids, and it’s in French, so it’s for French kids ;-).

    I’d like to have a specific keyword for a print instruction which would more or less work as a comment :

    e.g. writing

    print whathever is written after the print keyword is not considered a keyword w. r. t. syntax highlighting

    I tried a number of things: comments (but I do have proper comments so reuse is bad, furthermore accentuated letters appear not to be supported in comment openings), keywords in prefix mode (but I could not completly understand what these are) and a few others…

    Many thanks in advance for any help with this,
    Best regs,

  • @Renaud-Sirdey

    I assume you are using UDL and define a new language. If this is the case,
    then I would propose to use a delimiter definition instead of keyword and
    use the special command ((EOL)) as closing word. E.g.
    when having text like

    some text
    additional text
    print statement
    some further text
    and another print statement

    and using word print as the opening delimiter and ((EOL)) for closing
    the lines with print would get coloured.

    Is it this what you try to achieve?


  • Thanks a lot Claudia,

    It’s close to it.

    Here is exactly what I am trying to achieve with UDL :

    Assuming for example that ajouter, à and dans are keywords of my langage and écrire (also a keyword) is my print instruction.

    Then I’d like the input line

    ajouter 1 à x dans x

    to show as

    ajouter 1 à x dans x

    whereas I’d like the input line (which will print the message “ajouter 1 à x dans x”)

    écrire ajouter 1 à x dans x

    to show as

    écrire ajouter 1 à x dans x

    The solution you propose almost does it (it does indeed not highlight the keywords after écrire however all the words on the line are bound to the same style).

    Also, there seems to be an issue when accentuated letters are used as delimiters (i.e. it works with ecrire but not with écrire).

    Since I am developping a French language, this latter issue is important to me.

    Anyhow, many thanks for your first reply and many thanks in advance for any further insights you may provide,

    B. r., Renaud

  • Hello Renaud,

    seems you are right, you can use it as keywords but not as comment or delimiters and
    the second question about having the print statement colored and the following text not
    even if keywords are located is, afaik, also not possible, sorry.
    I guess this is the best you can have at the moment.


  • Ok thanks a lot Claudia,

    I will follow up on this post when I settle on some solution.


Log in to reply