Sourcecookifier plugin

irradium
2010-07-16
2013-05-21
  • irradium

    irradium - 2010-07-16

    I'm using SourceCookifier plugin and I'm trying to define language rules for AutoHotKey files, but I haven't got any result until now.
    Could Someone help me ?
    Thanks in advance
    Mauro

     
  • Andrew Redd

    Andrew Redd - 2010-08-06

    AHK comes with user defined rules.  You just have to copy over the userdefinedlangs.xml from the Autohotkey folder

     
  • ViXaY

    ViXaY - 2012-04-12

    I am sure he means getting AHK functions to show up in the function list for source cookifier

    here is the old XML that worked with Function List plugin

        <Language name="AHK Autohotkey" imagelistpath="">
            <CommList param1="/\*" param2="\*/" />
            <Group name="FUNCTION" subgroup="" icon="0" child="0" autoexp="0" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
                <Rules regexbeg="^" regexfunc="[a-zA-Z0-9@?#\[\]_]+" regexend="\([^(]*\)" bodybegin="{" bodyend="}" sep="$" />
            </Group>
            <Group name="SUB" subgroup="" icon="0" child="0" autoexp="0" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
                <Rules regexbeg="^" regexfunc="[a-zA-Z0-9@?#\[\]_&apos;-]+[:]" regexend="[ \t]*$" bodybegin="" bodyend="^[r]eturn[ \t]*$" sep="$" />
                <Rules regexbeg="^" regexfunc="[a-zA-Z0-9@?#\[\]_&apos;-]+[:]" regexend="[ \t]*[;].*$" bodybegin="" bodyend="^[r]eturn[ \t]*$" sep="" />
            </Group>
            <Group name="OTHER" subgroup="" icon="0" child="0" autoexp="0" matchcase="0" fendtobbeg="" bbegtobend="" keywords="">
                <Rules regexbeg="" regexfunc="[#!^+&amp;*~$ -=\[\]\\;&apos;,./A-Za-z0-9]+[:][:][ \t]*$" regexend="" bodybegin="" bodyend="" sep="" />
            </Group>
        </Language>
    
     
  • ViXaY

    ViXaY - 2012-04-12

    Yo, I took a a crack at it and this is what I've come up with so far:

      <item>
        <key>
          <string>Autohotkey</string>
        </key>
        <value>
          <Language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <BuildIn>false</BuildIn>
            <Extensions>
              <string>.ahk</string>
            </Extensions>
            <DisplayAccess>false</DisplayAccess>
            <DisplayReturnType>false</DisplayReturnType>
            <DisplayScope>false</DisplayScope>
            <DisplaySignature>false</DisplaySignature>
            <CaseSensitive>false</CaseSensitive>
            <ScopeOperator>.</ScopeOperator>
            <TagTypes>
              <item>
                <key>
                  <string>a</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Function]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^(\w+)\s*\(.*\)\s*\{/\1/a/ei</string>
                      <string>/^(\w+)\s*\(.*\)\s*$/\1/a/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>python_function.png</IconFilename>
                    <ForeColor>-16772364</ForeColor>
                  </TagType>
                </value>
              </item>
              <item>
                <key>
                  <string>h</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Hotstring]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^\:\S*\:(\S+)\:\:/\1/h/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>php_text_elements.png</IconFilename>
                    <ForeColor>-16777216</ForeColor>
                  </TagType>
                </value>
              </item>
              <item>
                <key>
                  <string>l</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Label]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^(\w+)\:\:/\1/l/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>php_named_html_elements.png</IconFilename>
                    <ForeColor>-16777216</ForeColor>
                  </TagType>
                </value>
              </item>
            </TagTypes>
          </Language>
        </value>
      </item>
    

    Put in SourceCookiefier.languages.xml and try it out, works well enough for functions i suppose and i tried a few things. This is in no way a final version so please bear that in mind. Just a beta to get you started

     
  • UFO

    UFO - 2012-04-12

    Thx and don't hesitate taking further cracks at it.
    Everything will flow right into the next version.
    cheers

     
  • UFO

    UFO - 2012-04-17

    I wanted to have a try at least before adding it for the next version,
    since I don't know Autohotkey scripting… so I tried the rules on some of these:
    http://www.autohotkey.com/docs/scripts/
    But your definitions returned 0 tags.
    Maybe you tried it on another language?
    I guess something's s wrong here..

     
  • ViXaY

    ViXaY - 2012-04-19

    Can you give me exactly which script you tried? Some scripts don't have functions. I tested with niftywindows and it worked only on a few things :/, so I modified it a bit.

    So it isn't extensively tested or anything :(. We can probably get better results at the Autohotkey forum.

    see http://www.autohotkey.com/community/viewtopic.php?f=7&t=58792 for more in depth discussion of the lexer
    You just need a subset.
    Also see here
    https://bitbucket.org/birkenfeld/pygments-main/src/96e8b9cb83ef/pygments/lexers/other.py#cl-2189
    for details.

    Anyway I have been spending way too much time trying to figure it out. :/ So here's the version I have so far, it currently has a false positives, and still parses regions inside comments. Also for some reason valid regex works for 1 valid literal, but not for another identical literal! e.g.:

    4GuiEscape:
    4ButtonCancel:
    4GuiClose:
      Gui, 4:cancel

    with pattern

    ^(^\s*)([^,:;\s\(\"]+?):\s*$
    

    matches only the Cancel but not escape or close!

    I guess this is the problem one encounters when meddling with complex regexs and such. :(

    Without further ado, my modified version

      <item>
        <key>
          <string>Autohotkey</string>
        </key>
        <value>
          <Language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <BuildIn>false</BuildIn>
            <Extensions>
              <string>.ahk</string>
            </Extensions>
            <DisplayAccess>false</DisplayAccess>
            <DisplayReturnType>false</DisplayReturnType>
            <DisplayScope>false</DisplayScope>
            <DisplaySignature>false</DisplaySignature>
            <CaseSensitive>false</CaseSensitive>
            <ScopeOperator>.</ScopeOperator>
            <TagTypes>
              <item>
                <key>
                  <string>a</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Function]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^(\w+)\s*\(.*\)\s*\{/\1/a/ei</string>
                      <string>/^(\w{3,})\s*\(.*\)\s*$/\1/a/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>python_function.png</IconFilename>
                    <ForeColor>-16772364</ForeColor>
                  </TagType>
                </value>
              </item>
              <item>
                <key>
                  <string>h</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Hotstring]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^:\S*:(\S+)::(.{5})/\1__(\2...)/h/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>php_text_elements.png</IconFilename>
                    <ForeColor>-16777216</ForeColor>
                  </TagType>
                </value>
              </item>
              <item>
                <key>
                  <string>l</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Hotkey]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^([^,;:]+)\:\:/\1/l/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>rc_accelerator.png</IconFilename>
                    <ForeColor>-16777216</ForeColor>
                  </TagType>
                </value>
              </item>
              <item>
                <key>
                  <string>L</string>
                </key>
                <value>
                  <TagType>
                    <Description>[Label]</Description>
                    <BuildIn>false</BuildIn>
                    <RegexPatterns>
                      <string>/^(^\s*)([^,:;\s\(\"]+?):\s*$/\1\2/L/ei</string>
                    </RegexPatterns>
                    <Show>true</Show>
                    <TrackCaret>false</TrackCaret>
                    <IconFilename>php_named_html_elements.png</IconFilename>
                    <ForeColor>-16777216</ForeColor>
                  </TagType>
                </value>
              </item>
            </TagTypes>
          </Language>
        </value>
      </item>
    
     
  • UFO

    UFO - 2012-04-19

    iirc there's no such operator like "\s" in gnu(!) regex.
    at the moment you have to use "" instead and it will work.
    actually you could have used a simple "", but there was a bug in sourcecookifier
    which didn't allow using space chars in expressions, an I didn't release the
    fixed version, yet.

     
  • UFO

    UFO - 2012-04-19

    PS: As I mentioned I don't know AHK at all and unfortunately don't have enough time
    digging into it. If you say that your set of rules is ok, then I'll simply include it.. thx again!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks