SHJS AutoIt Syntax Highlighting Definition File

This definition file adds support for AutoIt Syntax Highlighting in SHJS.

I wanted to add support for AutoIt in SHJS, so i wrote my own language definition file. This is likely far from perfect, and is of cause subject to change.

Note. Feel free to help improve this if you are interested, simply post your modifications in the comments to this Article.

The .lang source file

The autoit.lang file is included below, you can generate the JavaScript used by SHJS with the sh2js.pl file, but this requires that you have perl installed with the Parse::RecDescent module.

If you are using windows, and would like to learn how to install everything you need to help, check out this Tutorial that we made:Installing Perl CPAN Modules on Windows

The autoit.lang file:


# AutoIt lang definition file by BlueBoden
# Last updated 04-01-2012


comment start ";"
comment delim "#cs" "#ce" multiline
comment delim "#comments-start" "#comments-end" multiline

number = '\<[+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(?:8|16|32|64))|L)?\>'

string delim "'" "'"
string delim '"' '"'

variable = '(?:\$[#]?|@|%)[[:word:]]+'

# Keywords list
keyword = "If|Else|ElseIf|EndIf|While|WEnd|For|Next|Func|EndFunc|#include|#include-once|#NoTrayIcon|#OnAutoItStartRegister|#NoAutoIt3Execute|#RequireAdmin|ByRef|Const|ContinueCase|ContinueLoop|Default|Dim|Do|Until|Enum|Exit|ExitLoop|False|True|To|Step|Return|Global|Dim|Local|Const|ReDim|Select|Case|EndSelect|Static|Switch|EndSwitch|With|EndWith"

symbol = "~","!","%","^","*","(",")","-","+","=","[","]","\\",":",";",",",".","/","?","&","<",">","\|"
vardef FUNCTION = '([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*\()'
function = $FUNCTION

The autoit.js Script

This is the current version of our AutoIt Syntax Highlighter Script, as outputted by sh2js.pl.

if (! this.sh_languages) {
  this.sh_languages = {};
}
sh_languages['autoit'] = [
  [
    [
      /;/g,
      'sh_comment',
      1
    ],
    [
      /#comments-end/g,
      'sh_comment',
      1
    ],
    [
      /#cs/g,
      'sh_comment',
      2
    ],
    [
      /#comments-start/g,
      'sh_comment',
      3
    ],
    [
      /\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,
      'sh_number',
      -1
    ],
    [
      /'/g,
      'sh_string',
      4
    ],
    [
      /"/g,
      'sh_string',
      5
    ],
    [
      /(?:\$[#]?|@|%)[A-Za-z0-9_]+/g,
      'sh_variable',
      -1
    ],
    [
      /\b(?:If|Else|ElseIf|EndIf|While|WEnd|For|Next|Func|EndFunc|#include|#include-once|#NoTrayIcon|#OnAutoItStartRegister|#NoAutoIt3Execute|#RequireAdmin|ByRef|Const|ContinueCase|ContinueLoop|Default|Dim|Do|Until|Enum|Exit|ExitLoop|False|True|To|Step|Return|Global|Dim|Local|Const|ReDim|Select|Case|EndSelect|Static|Switch|EndSwitch|With|EndWith)\b/g,
      'sh_keyword',
      -1
    ],
    [
      /~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g,
      'sh_symbol',
      -1
    ],
    [
      /(?:[A-Za-z]|_)[A-Za-z0-9_]*(?=[ \t]*\()/g,
      'sh_function',
      -1
    ]
  ],
  [
    [
      /$/g,
      null,
      -2
    ]
  ],
  [
    [
      /#ce/g,
      'sh_comment',
      -2
    ]
  ],
  [
    [
      /#comments-end/g,
      'sh_comment',
      -2
    ]
  ],
  [
    [
      /$/g,
      null,
      -2
    ],
    [
      /'/g,
      'sh_string',
      -2
    ]
  ],
  [
    [
      /$/g,
      null,
      -2
    ],
    [
      /"/g,
      'sh_string',
      -2
    ]
  ]
];

Author:

Post comment

Links that you insert are not nofollowed, but will be removed by admins if they are considered spam.

[url=Absolute URL for page]TITLE[/url]

You should insert code boxes around code examples, which will be automatically syntax highlighted.

[code1 html|css|javascript|php|sql]Your Code Here[/code1]

You may want to read our Privacy Policy before submitting your comment.