Need help on creating a wordfile for LESS

Need help on creating a wordfile for LESS

2362
MasterMaster
2362

    Mar 15, 2012#1

    Okay, I am still learning the syntax on the wordfiles, so bear with me. I've got the variables defined finally, and are working perfectly.

    I need anything starting with a "#" OR "." and ending with a valid delimiter to be highlighted as a function.

    I have the valid function definition to get the function list.

    Functions should use . and # as a delimiter, and not require a space or tab in front of them, but may possibly have a space or tab in front. In other words, a function might follow another keyword or even a variable:

    Code: Select all

    @variable#functionName 
    or

    Code: Select all

    @variable.functionName() {
    	// function contents
    }
    or

    Code: Select all

    .functionName(@arguments) { ...  }
    Sometimes functions will be called as a function of a function:

    Code: Select all

    .functionOne#functionTwo
    which will generate a different result than using them separately. Both should be highlighted as functions, even though they appear to be one word. The delimiters need to be recognized, but included as part of the function definition in the next word, and the . and # should be highlighted as part of that word.

    . and # are both defined as delimiters, and need to be due to other areas of the language.

    Here is another caveat... border, .border, @border, #border, are all different. border is a keyword, but can be redefined as a function without conflict, and it can also be defined as a variable without conflict.

    "border" is defined in "/C2".
    "** #" and "** ." are defined in "/C13".

    However, "border" is always the same color, even if preceded by # . or @ when I need the color to change.
    If I remove #, @, and . from the list of delimiters, then functions like @variable.functionName will cease to work properly.

    Ideas?

    6,687586
    Grand MasterGrand Master
    6,687586

      Mar 15, 2012#2

      In general I recommend not to syntax highlight symbol names which are not keywords of the language or predefined symbols in the libraries of the language. If everything defined by the language or the standard libraries of the language are syntax highlighted, the remaining words displayed as normal text are self-defined variables, functions, constants, etc.

      It is never, really never a good idea to define a variable with the same name as a function. Most compilers like C/C++/C# compilers or interpreters like Javascript interpreters know from the context if the name references in a variable or a function. But for a human reading the source it is not so clear what is meant and for other tools like a text editor it is nearly impossible to interpret the word different according to context without being specially designed for that language.

      However, in your case with functions starting either with . or # which of course must be word delimiters, it should be nevertheless possible to highlight them all. You just have to take the priority on syntax highlighting into account used by UltraEdit for duplicate words or substrings matching also predefined words. I have explained syntax highlighting priority in chapter How duplicate words are handled by UE/UES? of The ultimate test for duplicate words macros.

      Without testing for your example with border following should result in correct highlighting.

      /C1"Predefined Functions"
      .border
      /C2"Predefined Keywords"
      border
      /C3"All other Functions"
      ** . #

      Important is that .border is also defined and not just ** . # because UltraEdit favors 100% matching words over substrings. You can imagine why on thinking how the word based syntax highlighting of UltraEdit is coded. The displayed text is split up into a list of words, then every displayed word is searched in the list of defined words and if there is a 100% match, the assigned color is used for this word. The remaining text after the simple word list compares are evaluated further with the substrings. .border must be defined in a color group with a lower number than border or it will be always highlighted with the color of border because . is also a delimiter.

      I hope that syntax highlighting really works as I have explained it. Otherwise there is no chance to get .border highlighted different than just border because . and # must be word delimiters.

      2362
      MasterMaster
      2362

        Mar 15, 2012#3

        You gave me exactly what I was needing. Thank you.

        I'll have to finish this little wordfile project tomorrow, as it is time to go prepare dinner for my family, and then have some family time.

        I'm curious, though, if anyone else will be interested in it when I'm done. I'm working on a wordfile for LESS (which is why it seems so similar to CSS, but it isn't the same, because it does functions, mixin's, and lots of other stuff that has to be "compiled" into a CSS file.)

        There is still a lot of work to do, as the CSS wordfile I had to begin with (that came with UES) is lacking in how I do things, and I started by editing that. It will need to be updated with browser keywords for -webkit, -ms, -o, etc. as it only had the -moz keywords. That means there is a lot to do before I want to share it with the community. I've been "tolerating" the way the CSS files work for quite a long time, and recently decided to take a month off from actual coding to get started "upgrading" my "tools" that I use to work more properly. In doing so, I have created a more proper PHP wordfile, a more proper AHK wordfile, and now I'm working on CSS and LESS wordfiles. (Check http://lesscss.org/ for more info. I have a tool that compiles it into straight CSS.)

        1
        NewbieNewbie
        1

          Mar 22, 2012#4

          So ... did you manage to create a wordfile for LESS? I'd love to have it. :)!

          2362
          MasterMaster
          2362

            Mar 22, 2012#5

            Yes, I managed to create it. Since you are eager to have it, I shall supply it. ASCII and ye shall receive, and all that.

            I have included a readme file in the zip archive, which explains why you need UE 17+ to make use of it, and why I don't have CSS 3 included in it yet, and other stuff.

            Perhaps someone will finish it by adding CSS 3 into a new color group?
            wordfile_less.zip (7.2 KiB)   383

            13
            Basic UserBasic User
            13

              Sep 10, 2013#6

              Hi rhapdog

              Thanks very much for sharing this with us :D your efforts are very much appreciated!