Lua syntax file

Started by scottbilas, June 17, 2009, 08:24:09 PM

Previous topic - Next topic

scottbilas

Lua bundle in library

The current lua spec has [[ ]] as a comment, but that's only correct if preceded by a --. Without it, it's a string.

I updated my lua_spec.xml like in the below XML to fix. Note that Lua allows arbitrary depth of comments with the ='s so I just picked six levels' worth to implement. Not sure if there's a better way to do this in HE.


      <Style id="comment" name="Comments" text="1" bold="0" italic="1" underline="0" clr="Strings" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="--" close="\n"/>
          <Block open="--[[" close="]]"/>
          <Block open="--[=[" close="]=]"/>
          <Block open="--[==[" close="]==]"/>
          <Block open="--[===[" close="]===]"/>
          <Block open="--[====[" close="]====]"/>
          <Block open="--[=====[" close="]=====]"/>
        </Blocks>
        <Containers>
          <Close id="normal"/>
          <Close id="todo"/>
        </Containers>
      </Style>
      <Style id="string" name="Strings" text="1" bold="0" italic="0" underline="0" clr="Strings" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="&quot;" close="&quot;"/>
          <Block open="[[" close="]]"/>
          <Block open="[=[" close="]=]"/>
          <Block open="[==[" close="]==]"/>
          <Block open="[===[" close="]===]"/>
          <Block open="[====[" close="]====]"/>
          <Block open="[=====[" close="]=====]"/>
        </Blocks>
      </Style>


Found in #1.43.680.

alex

#1
Hello Scott,

thanks a lot. I would update schema in library to include your changes.  (Updated)
The schema was created by me (copied from somewhere and checked with some samples) so it can be wrong or incomplete.

Just interesting, why all these levels are needed to somebody?
And you did all right, there is no regexp like support for such definition yet.

Best regards,
Alex
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

scottbilas

I just added six levels because it was easy to copy-paste. I don't know why anybody would use that many levels, but it is what the Lua spec supports. I don't think there's a limit on how deep the ='s can go.

My guess is that they did this so that you can have nested comments. Like a block of code with block comments in it, and then you can comment the entire thing out with an outer even bigger comment. Then copy paste that somewhere else and put another comment around the whole thing..

I only use --[[]] and [[]] personally. :)

alex

Ok. But probably in this case this nested levels comments should be modified in a way that they are also allowed inside of the comment block. And probably extracted to another style, to have a different color.. Like Nesting levels fex. So every nested comment would be darker as outer..
I would modify schema some when, if people would request ;)
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

jianguhan

Just add  the following text to lua_spec.xml :D

<LABELS>
       <Label group="Functions" match="function[\t ]+([a-zA-Z_0-9:]*[ a-zA-Z_0-9(),]*)" name="\1" image="8" scope="1"></Label>
    </LABELS>

alex

Hi jianghuan,

first welcome on forum and second thanks for your help with lua schema.

I have extended your suggestion a little bit:
    <LABELS>
      <Label group="Functions" match="function\s+([\w:]*)\s*\(([^)]*)\)" name="\1" descr="function \1 (\2)" image="6" scope="1"/>
      <Label group="if" match="\sif\s+(.+?)\s+then" name="\1" descr="if \1 then" scope="1" image="13" navigation="false"/>
      <Label group="for" match="\sfor\s+(.+?)\s+do" name="\1" descr="for \1 do" scope="1" image="13" navigation="false"/>     
    </LABELS>


And have added:
    <SPECIFICATION>
       .....
      <Bars navigation="true"/>     
    </SPECIFICATION>

to have Navigation bar visible by default.

I will also update schema in library with your changes, that other people can use them.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]