aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/autoit.lua
diff options
context:
space:
mode:
authorqiu-x <alex@alexslomka.xyz>2022-06-29 07:56:51 +0200
committerFelix Van der Jeugt <felix.vanderjeugt@posteo.net>2022-11-29 21:57:18 +0100
commit8a420ecc4c1ed50111464ec66901bd983eaf2dbd (patch)
treef31d2186cafaee6e7f18d32fe99144c3e8148c00 /lua/lexers/autoit.lua
parent981b90a203484182feace48471fe2b53dae7676f (diff)
downloadvis-8a420ecc4c1ed50111464ec66901bd983eaf2dbd.tar.gz
vis-8a420ecc4c1ed50111464ec66901bd983eaf2dbd.tar.xz
Resync the lexers with Scintillua
- Resync the lexers with Scintillua - Update the lexer readme - Update `zenburn` theme to fix some highlighting issues - lexers: redirect print function to vis:info() - Fix support for custom style names - As per error message "lexer.delimited_range() is deprecated, use lexer.range()". - Remove remaining `lexer.delimited_range()` call - Set syntax to `nil` if the file type has no matching lexer - Updated Go lexer for Go 1.18. - lexers/dsv: convert to new lexer format (cherry picked from commit 9edbc3cd9ea1d7142b1305840432a3d2739e755a) - lexers/gemini: disable legacy gemini lexer This reverts commit 468f9ee1b027a7ce98b1a249fa1af5888feeb989. It is in legacy format and of questionable quality. Ideally it should be contributed upstream from where it will eventually trickle down to us. - lexers/git-rebase: convert to new lexer format (cherry picked from commit 4000a4cc9ac4a4c2869dfae772b977a82aee8d8c) - lexers/strace: convert to new lexer format (cherry picked from commit e420451320d97eb164f5629c1bcfab0b595be29d) - lexers/typescript: add new upstream lexer revision 28e2b60 (cherry picked from commit 7326e6deecdaa75fa94ae9ebdb653f9f907b33f2) - use `package.searchpath` instead of a local `searchpath` function - Restore `filetype: support filetype detection via hashbang` - Remove redundant comment - Restore gemini lexer
Diffstat (limited to 'lua/lexers/autoit.lua')
-rw-r--r--lua/lexers/autoit.lua243
1 files changed, 102 insertions, 141 deletions
diff --git a/lua/lexers/autoit.lua b/lua/lexers/autoit.lua
index ee72cfb..42b4bdf 100644
--- a/lua/lexers/autoit.lua
+++ b/lua/lexers/autoit.lua
@@ -1,168 +1,129 @@
--- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
+-- Copyright 2006-2022 Mitchell. See LICENSE.
-- AutoIt LPeg lexer.
-- Contributed by Jeff Stone.
-local l = require('lexer')
-local token, word_match = l.token, l.word_match
-local P, R, S = lpeg.P, lpeg.R, lpeg.S
+local lexer = require('lexer')
+local token, word_match = lexer.token, lexer.word_match
+local P, S = lpeg.P, lpeg.S
-local M = {_NAME = 'autoit'}
+local lex = lexer.new('autoit')
-- Whitespace.
-local ws = token(l.WHITESPACE, l.space^1)
-
--- Comments.
-local line_comment = ';' * l.nonnewline_esc^0
-local block_comment1 = '#comments-start' * (l.any - '#comments-end')^0 *
- P('#comments-end')^-1
-local block_comment2 = '#cs' * (l.any - '#ce')^0 * P('#ce')^-1
-local comment = token(l.COMMENT, line_comment + block_comment1 + block_comment2)
+lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
-- Keywords.
-local kw = token(l.KEYWORD, word_match({
- 'False', 'True', 'And', 'Or', 'Not', 'ContinueCase', 'ContinueLoop',
- 'Default', 'Dim', 'Global', 'Local', 'Const', 'Do', 'Until', 'Enum', 'Exit',
- 'ExitLoop', 'For', 'To', 'Step', 'Next', 'In', 'Func', 'Return', 'EndFunc',
- 'If', 'Then', 'ElseIf', 'Else', 'EndIf', 'Null', 'ReDim', 'Select', 'Case',
- 'EndSelect', 'Static', 'Switch', 'EndSwitch', 'Volatile', 'While', 'WEnd',
- 'With', 'EndWith'
-}, nil, true))
+lex:add_rule('keyword', token(lexer.KEYWORD, word_match({
+ 'False', 'True', 'And', 'Or', 'Not', 'ContinueCase', 'ContinueLoop', 'Default', 'Dim', 'Global',
+ 'Local', 'Const', 'Do', 'Until', 'Enum', 'Exit', 'ExitLoop', 'For', 'To', 'Step', 'Next', 'In',
+ 'Func', 'Return', 'EndFunc', 'If', 'Then', 'ElseIf', 'Else', 'EndIf', 'Null', 'ReDim', 'Select',
+ 'Case', 'EndSelect', 'Static', 'Switch', 'EndSwitch', 'Volatile', 'While', 'WEnd', 'With',
+ 'EndWith'
+}, true)))
-- Functions.
-local func = token(l.FUNCTION, word_match({
- 'Abs', 'ACos', 'AdlibRegister', 'AdlibUnRegister', 'Asc', 'AscW', 'ASin',
- 'Assign', 'ATan', 'AutoItSetOption', 'AutoItWinGetTitle', 'AutoItWinSetTitle',
- 'Beep', 'Binary', 'BinaryLen', 'BinaryMid', 'BinaryToString', 'BitAND',
- 'BitNOT', 'BitOR', 'BitRotate', 'BitShift', 'BitXOR', 'BlockInput', 'Break',
- 'Call', 'CDTray', 'Ceiling', 'Chr', 'ChrW', 'ClipGet', 'ClipPut',
- 'ConsoleRead', 'ConsoleWrite', 'ConsoleWriteError', 'ControlClick',
- 'ControlCommand', 'ControlDisable', 'ControlEnable', 'ControlFocus',
- 'ControlGetFocus', 'ControlGetHandle', 'ControlGetPos', 'ControlGetText',
- 'ControlHide', 'ControlListView', 'ControlMove', 'ControlSend',
- 'ControlSetText', 'ControlShow', 'ControlTreeView', 'Cos', 'Dec', 'DirCopy',
- 'DirCreate', 'DirGetSize', 'DirMove', 'DirRemove', 'DllCall',
- 'DllCallAddress', 'DllCallbackFree', 'DllCallbackGetPtr',
- 'DllCallbackRegister', 'DllClose', 'DllOpen', 'DllStructCreate',
- 'DllStructGetData', 'DllStructGetPtr', 'DllStructGetSize', 'DllStructSetData',
- 'DriveGetDrive', 'DriveGetFileSystem', 'DriveGetLabel', 'DriveGetSerial',
- 'DriveGetType', 'DriveMapAdd', 'DriveMapDel', 'DriveMapGet', 'DriveSetLabel',
- 'DriveSpaceFree', 'DriveSpaceTotal', 'DriveStatus', 'EnvGet', 'EnvSet',
- 'EnvUpdate', 'Eval', 'Execute', 'Exp', 'FileChangeDir', 'FileClose',
- 'FileCopy', 'FileCreateNTFSLink', 'FileCreateShortcut', 'FileDelete',
- 'FileExists', 'FileFindFirstFile', 'FileFindNextFile', 'FileFlush',
- 'FileGetAttrib', 'FileGetEncoding', 'FileGetLongName', 'FileGetPos',
- 'FileGetShortcut', 'FileGetShortName', 'FileGetSize', 'FileGetTime',
- 'FileGetVersion', 'FileInstall', 'FileMove', 'FileOpen', 'FileOpenDialog',
- 'FileRead', 'FileReadLine', 'FileReadToArray', 'FileRecycle',
- 'FileRecycleEmpty', 'FileSaveDialog', 'FileSelectFolder', 'FileSetAttrib',
- 'FileSetEnd', 'FileSetPos', 'FileSetTime', 'FileWrite', 'FileWriteLine',
- 'Floor', 'FtpSetProxy', 'FuncName', 'GUICreate', 'GUICtrlCreateAvi',
- 'GUICtrlCreateButton', 'GUICtrlCreateCheckbox', 'GUICtrlCreateCombo',
- 'GUICtrlCreateContextMenu', 'GUICtrlCreateDate', 'GUICtrlCreateDummy',
- 'GUICtrlCreateEdit', 'GUICtrlCreateGraphic', 'GUICtrlCreateGroup',
- 'GUICtrlCreateIcon', 'GUICtrlCreateInput', 'GUICtrlCreateLabel',
- 'GUICtrlCreateList', 'GUICtrlCreateListView', 'GUICtrlCreateListViewItem',
- 'GUICtrlCreateMenu', 'GUICtrlCreateMenuItem', 'GUICtrlCreateMonthCal',
- 'GUICtrlCreateObj', 'GUICtrlCreatePic', 'GUICtrlCreateProgress',
- 'GUICtrlCreateRadio', 'GUICtrlCreateSlider', 'GUICtrlCreateTab',
+lex:add_rule('function', token(lexer.FUNCTION, word_match({
+ 'Abs', 'ACos', 'AdlibRegister', 'AdlibUnRegister', 'Asc', 'AscW', 'ASin', 'Assign', 'ATan',
+ 'AutoItSetOption', 'AutoItWinGetTitle', 'AutoItWinSetTitle', 'Beep', 'Binary', 'BinaryLen',
+ 'BinaryMid', 'BinaryToString', 'BitAND', 'BitNOT', 'BitOR', 'BitRotate', 'BitShift', 'BitXOR',
+ 'BlockInput', 'Break', 'Call', 'CDTray', 'Ceiling', 'Chr', 'ChrW', 'ClipGet', 'ClipPut',
+ 'ConsoleRead', 'ConsoleWrite', 'ConsoleWriteError', 'ControlClick', 'ControlCommand',
+ 'ControlDisable', 'ControlEnable', 'ControlFocus', 'ControlGetFocus', 'ControlGetHandle',
+ 'ControlGetPos', 'ControlGetText', 'ControlHide', 'ControlListView', 'ControlMove', 'ControlSend',
+ 'ControlSetText', 'ControlShow', 'ControlTreeView', 'Cos', 'Dec', 'DirCopy', 'DirCreate',
+ 'DirGetSize', 'DirMove', 'DirRemove', 'DllCall', 'DllCallAddress', 'DllCallbackFree',
+ 'DllCallbackGetPtr', 'DllCallbackRegister', 'DllClose', 'DllOpen', 'DllStructCreate',
+ 'DllStructGetData', 'DllStructGetPtr', 'DllStructGetSize', 'DllStructSetData', 'DriveGetDrive',
+ 'DriveGetFileSystem', 'DriveGetLabel', 'DriveGetSerial', 'DriveGetType', 'DriveMapAdd',
+ 'DriveMapDel', 'DriveMapGet', 'DriveSetLabel', 'DriveSpaceFree', 'DriveSpaceTotal', 'DriveStatus',
+ 'EnvGet', 'EnvSet', 'EnvUpdate', 'Eval', 'Execute', 'Exp', 'FileChangeDir', 'FileClose',
+ 'FileCopy', 'FileCreateNTFSLink', 'FileCreateShortcut', 'FileDelete', 'FileExists',
+ 'FileFindFirstFile', 'FileFindNextFile', 'FileFlush', 'FileGetAttrib', 'FileGetEncoding',
+ 'FileGetLongName', 'FileGetPos', 'FileGetShortcut', 'FileGetShortName', 'FileGetSize',
+ 'FileGetTime', 'FileGetVersion', 'FileInstall', 'FileMove', 'FileOpen', 'FileOpenDialog',
+ 'FileRead', 'FileReadLine', 'FileReadToArray', 'FileRecycle', 'FileRecycleEmpty',
+ 'FileSaveDialog', 'FileSelectFolder', 'FileSetAttrib', 'FileSetEnd', 'FileSetPos', 'FileSetTime',
+ 'FileWrite', 'FileWriteLine', 'Floor', 'FtpSetProxy', 'FuncName', 'GUICreate', 'GUICtrlCreateAvi',
+ 'GUICtrlCreateButton', 'GUICtrlCreateCheckbox', 'GUICtrlCreateCombo', 'GUICtrlCreateContextMenu',
+ 'GUICtrlCreateDate', 'GUICtrlCreateDummy', 'GUICtrlCreateEdit', 'GUICtrlCreateGraphic',
+ 'GUICtrlCreateGroup', 'GUICtrlCreateIcon', 'GUICtrlCreateInput', 'GUICtrlCreateLabel',
+ 'GUICtrlCreateList', 'GUICtrlCreateListView', 'GUICtrlCreateListViewItem', 'GUICtrlCreateMenu',
+ 'GUICtrlCreateMenuItem', 'GUICtrlCreateMonthCal', 'GUICtrlCreateObj', 'GUICtrlCreatePic',
+ 'GUICtrlCreateProgress', 'GUICtrlCreateRadio', 'GUICtrlCreateSlider', 'GUICtrlCreateTab',
'GUICtrlCreateTabItem', 'GUICtrlCreateTreeView', 'GUICtrlCreateTreeViewItem',
- 'GUICtrlCreateUpdown', 'GUICtrlDelete', 'GUICtrlGetHandle', 'GUICtrlGetState',
- 'GUICtrlRead', 'GUICtrlRecvMsg', 'GUICtrlRegisterListViewSort',
- 'GUICtrlSendMsg', 'GUICtrlSendToDummy', 'GUICtrlSetBkColor',
- 'GUICtrlSetColor', 'GUICtrlSetCursor', 'GUICtrlSetData',
- 'GUICtrlSetDefBkColor', 'GUICtrlSetDefColor', 'GUICtrlSetFont',
- 'GUICtrlSetGraphic', 'GUICtrlSetImage', 'GUICtrlSetLimit',
- 'GUICtrlSetOnEvent', 'GUICtrlSetPos', 'GUICtrlSetResizing', 'GUICtrlSetState',
- 'GUICtrlSetStyle', 'GUICtrlSetTip', 'GUIDelete', 'GUIGetCursorInfo',
- 'GUIGetMsg', 'GUIGetStyle', 'GUIRegisterMsg', 'GUISetAccelerators',
- 'GUISetBkColor', 'GUISetCoord', 'GUISetCursor', 'GUISetFont', 'GUISetHelp',
- 'GUISetIcon', 'GUISetOnEvent', 'GUISetState', 'GUISetStyle', 'GUIStartGroup',
- 'GUISwitch', 'Hex', 'HotKeySet', 'HttpSetProxy', 'HttpSetUserAgent', 'HWnd',
- 'InetClose', 'InetGet', 'InetGetInfo', 'InetGetSize', 'InetRead', 'IniDelete',
- 'IniRead', 'IniReadSection', 'IniReadSectionNames', 'IniRenameSection',
- 'IniWrite', 'IniWriteSection', 'InputBox', 'Int', 'IsAdmin', 'IsArray',
- 'IsBinary', 'IsBool', 'IsDeclared', 'IsDllStruct', 'IsFloat', 'IsFunc',
- 'IsHWnd', 'IsInt', 'IsKeyword', 'IsNumber', 'IsObj', 'IsPtr', 'IsString',
- 'Log', 'MemGetStats', 'Mod', 'MouseClick', 'MouseClickDrag', 'MouseDown',
- 'MouseGetCursor', 'MouseGetPos', 'MouseMove', 'MouseUp', 'MouseWheel',
- 'MsgBox', 'Number', 'ObjCreate', 'ObjCreateInterface', 'ObjEvent', 'ObjGet',
- 'ObjName', 'OnAutoItExitRegister', 'OnAutoItExitUnRegister', 'Ping',
- 'PixelChecksum', 'PixelGetColor', 'PixelSearch', 'ProcessClose',
- 'ProcessExists', 'ProcessGetStats', 'ProcessList', 'ProcessSetPriority',
- 'ProcessWait', 'ProcessWaitClose', 'ProgressOff', 'ProgressOn', 'ProgressSet',
- 'Ptr', 'Random', 'RegDelete', 'RegEnumKey', 'RegEnumVal', 'RegRead',
- 'RegWrite', 'Round', 'Run', 'RunAs', 'RunAsWait', 'RunWait', 'Send',
- 'SendKeepActive', 'SetError', 'SetExtended', 'ShellExecute',
- 'ShellExecuteWait', 'Shutdown', 'Sin', 'Sleep', 'SoundPlay',
- 'SoundSetWaveVolume', 'SplashImageOn', 'SplashOff', 'SplashTextOn', 'Sqrt',
- 'SRandom', 'StatusbarGetText', 'StderrRead', 'StdinWrite', 'StdioClose',
- 'StdoutRead', 'String', 'StringAddCR', 'StringCompare', 'StringFormat',
- 'StringFromASCIIArray', 'StringInStr', 'StringIsAlNum', 'StringIsAlpha',
- 'StringIsASCII', 'StringIsDigit', 'StringIsFloat', 'StringIsInt',
- 'StringIsLower', 'StringIsSpace', 'StringIsUpper', 'StringIsXDigit',
- 'StringLeft', 'StringLen', 'StringLower', 'StringMid', 'StringRegExp',
- 'StringRegExpReplace', 'StringReplace', 'StringReverse', 'StringRight',
- 'StringSplit', 'StringStripCR', 'StringStripWS', 'StringToASCIIArray',
- 'StringToBinary', 'StringTrimLeft', 'StringTrimRight', 'StringUpper', 'Tan',
- 'TCPAccept', 'TCPCloseSocket', 'TCPConnect', 'TCPListen', 'TCPNameToIP',
- 'TCPRecv', 'TCPSend', 'TCPShutdown, UDPShutdown', 'TCPStartup, UDPStartup',
- 'TimerDiff', 'TimerInit', 'ToolTip', 'TrayCreateItem', 'TrayCreateMenu',
- 'TrayGetMsg', 'TrayItemDelete', 'TrayItemGetHandle', 'TrayItemGetState',
- 'TrayItemGetText', 'TrayItemSetOnEvent', 'TrayItemSetState',
- 'TrayItemSetText', 'TraySetClick', 'TraySetIcon', 'TraySetOnEvent',
- 'TraySetPauseIcon', 'TraySetState', 'TraySetToolTip', 'TrayTip', 'UBound',
- 'UDPBind', 'UDPCloseSocket', 'UDPOpen', 'UDPRecv', 'UDPSend', 'VarGetType',
- 'WinActivate', 'WinActive', 'WinClose', 'WinExists', 'WinFlash',
- 'WinGetCaretPos', 'WinGetClassList', 'WinGetClientSize', 'WinGetHandle',
- 'WinGetPos', 'WinGetProcess', 'WinGetState', 'WinGetText', 'WinGetTitle',
- 'WinKill', 'WinList', 'WinMenuSelectItem', 'WinMinimizeAll',
- 'WinMinimizeAllUndo', 'WinMove', 'WinSetOnTop', 'WinSetState', 'WinSetTitle',
+ 'GUICtrlCreateUpdown', 'GUICtrlDelete', 'GUICtrlGetHandle', 'GUICtrlGetState', 'GUICtrlRead',
+ 'GUICtrlRecvMsg', 'GUICtrlRegisterListViewSort', 'GUICtrlSendMsg', 'GUICtrlSendToDummy',
+ 'GUICtrlSetBkColor', 'GUICtrlSetColor', 'GUICtrlSetCursor', 'GUICtrlSetData',
+ 'GUICtrlSetDefBkColor', 'GUICtrlSetDefColor', 'GUICtrlSetFont', 'GUICtrlSetGraphic',
+ 'GUICtrlSetImage', 'GUICtrlSetLimit', 'GUICtrlSetOnEvent', 'GUICtrlSetPos', 'GUICtrlSetResizing',
+ 'GUICtrlSetState', 'GUICtrlSetStyle', 'GUICtrlSetTip', 'GUIDelete', 'GUIGetCursorInfo',
+ 'GUIGetMsg', 'GUIGetStyle', 'GUIRegisterMsg', 'GUISetAccelerators', 'GUISetBkColor',
+ 'GUISetCoord', 'GUISetCursor', 'GUISetFont', 'GUISetHelp', 'GUISetIcon', 'GUISetOnEvent',
+ 'GUISetState', 'GUISetStyle', 'GUIStartGroup', 'GUISwitch', 'Hex', 'HotKeySet', 'HttpSetProxy',
+ 'HttpSetUserAgent', 'HWnd', 'InetClose', 'InetGet', 'InetGetInfo', 'InetGetSize', 'InetRead',
+ 'IniDelete', 'IniRead', 'IniReadSection', 'IniReadSectionNames', 'IniRenameSection', 'IniWrite',
+ 'IniWriteSection', 'InputBox', 'Int', 'IsAdmin', 'IsArray', 'IsBinary', 'IsBool', 'IsDeclared',
+ 'IsDllStruct', 'IsFloat', 'IsFunc', 'IsHWnd', 'IsInt', 'IsKeyword', 'IsNumber', 'IsObj', 'IsPtr',
+ 'IsString', 'Log', 'MemGetStats', 'Mod', 'MouseClick', 'MouseClickDrag', 'MouseDown',
+ 'MouseGetCursor', 'MouseGetPos', 'MouseMove', 'MouseUp', 'MouseWheel', 'MsgBox', 'Number',
+ 'ObjCreate', 'ObjCreateInterface', 'ObjEvent', 'ObjGet', 'ObjName', 'OnAutoItExitRegister',
+ 'OnAutoItExitUnRegister', 'Ping', 'PixelChecksum', 'PixelGetColor', 'PixelSearch', 'ProcessClose',
+ 'ProcessExists', 'ProcessGetStats', 'ProcessList', 'ProcessSetPriority', 'ProcessWait',
+ 'ProcessWaitClose', 'ProgressOff', 'ProgressOn', 'ProgressSet', 'Ptr', 'Random', 'RegDelete',
+ 'RegEnumKey', 'RegEnumVal', 'RegRead', 'RegWrite', 'Round', 'Run', 'RunAs', 'RunAsWait',
+ 'RunWait', 'Send', 'SendKeepActive', 'SetError', 'SetExtended', 'ShellExecute',
+ 'ShellExecuteWait', 'Shutdown', 'Sin', 'Sleep', 'SoundPlay', 'SoundSetWaveVolume',
+ 'SplashImageOn', 'SplashOff', 'SplashTextOn', 'Sqrt', 'SRandom', 'StatusbarGetText', 'StderrRead',
+ 'StdinWrite', 'StdioClose', 'StdoutRead', 'String', 'StringAddCR', 'StringCompare',
+ 'StringFormat', 'StringFromASCIIArray', 'StringInStr', 'StringIsAlNum', 'StringIsAlpha',
+ 'StringIsASCII', 'StringIsDigit', 'StringIsFloat', 'StringIsInt', 'StringIsLower',
+ 'StringIsSpace', 'StringIsUpper', 'StringIsXDigit', 'StringLeft', 'StringLen', 'StringLower',
+ 'StringMid', 'StringRegExp', 'StringRegExpReplace', 'StringReplace', 'StringReverse',
+ 'StringRight', 'StringSplit', 'StringStripCR', 'StringStripWS', 'StringToASCIIArray',
+ 'StringToBinary', 'StringTrimLeft', 'StringTrimRight', 'StringUpper', 'Tan', 'TCPAccept',
+ 'TCPCloseSocket', 'TCPConnect', 'TCPListen', 'TCPNameToIP', 'TCPRecv', 'TCPSend', 'TCPShutdown',
+ 'TCPStartup', 'TimerDiff', 'TimerInit', 'ToolTip', 'TrayCreateItem', 'TrayCreateMenu',
+ 'TrayGetMsg', 'TrayItemDelete', 'TrayItemGetHandle', 'TrayItemGetState', 'TrayItemGetText',
+ 'TrayItemSetOnEvent', 'TrayItemSetState', 'TrayItemSetText', 'TraySetClick', 'TraySetIcon',
+ 'TraySetOnEvent', 'TraySetPauseIcon', 'TraySetState', 'TraySetToolTip', 'TrayTip', 'UBound',
+ 'UDPBind', 'UDPCloseSocket', 'UDPOpen', 'UDPRecv', 'UDPSend', 'UDPShutdown', 'UDPStartup',
+ 'VarGetType', 'WinActivate', 'WinActive', 'WinClose', 'WinExists', 'WinFlash', 'WinGetCaretPos',
+ 'WinGetClassList', 'WinGetClientSize', 'WinGetHandle', 'WinGetPos', 'WinGetProcess',
+ 'WinGetState', 'WinGetText', 'WinGetTitle', 'WinKill', 'WinList', 'WinMenuSelectItem',
+ 'WinMinimizeAll', 'WinMinimizeAllUndo', 'WinMove', 'WinSetOnTop', 'WinSetState', 'WinSetTitle',
'WinSetTrans', 'WinWait', 'WinWaitActive', 'WinWaitClose', 'WinWaitNotActive'
-}, nil, true))
+}, true)))
+
+-- Identifiers.
+lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
+
+-- Comments.
+local line_comment = lexer.to_eol(';')
+local block_comment = lexer.range('#comments-start', '#comments-end') + lexer.range('#cs', '#ce')
+lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment))
-- Preprocessor.
-local preproc = token(l.PREPROCESSOR, '#' * word_match({
+lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, '#' * word_match({
'include-once', 'include', 'pragma', 'forceref', 'RequireAdmin', 'NoTrayIcon',
'OnAutoItStartRegister'
-}, '-', true))
+}, true)))
-- Strings.
-local dq_str = l.delimited_range('"', true, true)
-local sq_str = l.delimited_range("'", true, true)
-local inc = l.delimited_range('<>', true, true, true)
-local str = token(l.STRING, dq_str + sq_str + inc)
+local dq_str = lexer.range('"', true, false)
+local sq_str = lexer.range("'", true, false)
+local inc = lexer.range('<', '>', true, false, true)
+lex:add_rule('string', token(lexer.STRING, dq_str + sq_str + inc))
-- Macros.
-local macro = token('macro', '@' * (l.alnum + '_')^1)
+lex:add_rule('macro', token('macro', '@' * (lexer.alnum + '_')^1))
+lex:add_style('macro', lexer.styles.preprocessor)
-- Variables.
-local var = token(l.VARIABLE, '$' * (l.alnum + '_')^1)
-
--- Identifiers.
-local ident = token(l.IDENTIFIER, (l.alnum + '_')^1)
+lex:add_rule('variable', token(lexer.VARIABLE, '$' * (lexer.alnum + '_')^1))
-- Numbers.
-local nbr = token(l.NUMBER, l.float + l.integer)
+lex:add_rule('number', token(lexer.NUMBER, lexer.number))
-- Operators.
-local oper = token(l.OPERATOR, S('+-^*/&<>=?:()[]'))
-
-M._rules = {
- {'whitespace', ws},
- {'comment', comment},
- {'keyword', kw},
- {'function', func},
- {'preproc', preproc},
- {'string', str},
- {'macro', macro},
- {'variable', var},
- {'number', nbr},
- {'identifier', ident},
- {'operator', oper}
-}
-
-M._tokenstyles = {
- macro = l.STYLE_PREPROCESSOR
-}
+lex:add_rule('operator', token(lexer.OPERATOR, S('+-^*/&<>=?:()[]')))
-return M
+return lex