diff options
Diffstat (limited to 'lexers')
101 files changed, 489 insertions, 113 deletions
diff --git a/lexers/LICENSE b/lexers/LICENSE index 13cd311..627e560 100644 --- a/lexers/LICENSE +++ b/lexers/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2007-2015 Mitchell +Copyright (c) 2007-2016 Mitchell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lexers/actionscript.lua b/lexers/actionscript.lua index 0aafe63..a913a45 100644 --- a/lexers/actionscript.lua +++ b/lexers/actionscript.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Actionscript LPeg lexer. local l = require('lexer') diff --git a/lexers/ada.lua b/lexers/ada.lua index cbcb651..7258431 100644 --- a/lexers/ada.lua +++ b/lexers/ada.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Ada LPeg lexer. local l = require('lexer') diff --git a/lexers/ansi_c.lua b/lexers/ansi_c.lua index e7e04d5..5c8e007 100644 --- a/lexers/ansi_c.lua +++ b/lexers/ansi_c.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- C LPeg lexer. local l = require('lexer') diff --git a/lexers/antlr.lua b/lexers/antlr.lua index 7c9e444..91dbd60 100644 --- a/lexers/antlr.lua +++ b/lexers/antlr.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- ANTLR LPeg lexer. local l = require('lexer') diff --git a/lexers/apdl.lua b/lexers/apdl.lua index 97d8d2c..1c91a08 100644 --- a/lexers/apdl.lua +++ b/lexers/apdl.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- APDL LPeg lexer. local l = require('lexer') diff --git a/lexers/apl.lua b/lexers/apl.lua index 878e889..4fa492e 100644 --- a/lexers/apl.lua +++ b/lexers/apl.lua @@ -1,5 +1,5 @@ +-- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE. -- APL LPeg lexer. --- Author: David B. Lamkins <david@lamkins.net> local l = require('lexer') local token, word_match = l.token, l.word_match @@ -25,13 +25,13 @@ local rad = P('.') local exp = S('eE') local img = S('jJ') local sgn = P('¯')^-1 -local float = sgn * (dig^0 * rad * dig^1 + dig^1 * rad * dig^0 + dig^1) - * (exp * sgn *dig^1)^-1 +local float = sgn * (dig^0 * rad * dig^1 + dig^1 * rad * dig^0 + dig^1) * + (exp * sgn *dig^1)^-1 local number = token(l.NUMBER, float * img * float + float) -- Keywords. -local keyword = token(l.KEYWORD, P('⍞') + P('χ') + P('⍺') + P('⍶') - + P('⍵') + P('⍹') + P('⎕') * R('AZ', 'az')^0) +local keyword = token(l.KEYWORD, P('⍞') + P('χ') + P('⍺') + P('⍶') + P('⍵') + + P('⍹') + P('⎕') * R('AZ', 'az')^0) -- Names. local n1l = R('AZ', 'az') diff --git a/lexers/applescript.lua b/lexers/applescript.lua index 08b3432..07cf1d3 100644 --- a/lexers/applescript.lua +++ b/lexers/applescript.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Applescript LPeg lexer. local l = require('lexer') diff --git a/lexers/asm.lua b/lexers/asm.lua index 1cba511..e599f72 100644 --- a/lexers/asm.lua +++ b/lexers/asm.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- NASM Assembly LPeg lexer. local l = require('lexer') diff --git a/lexers/asp.lua b/lexers/asp.lua index 044966c..dc1b0e9 100644 --- a/lexers/asp.lua +++ b/lexers/asp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- ASP LPeg lexer. local l = require('lexer') diff --git a/lexers/autoit.lua b/lexers/autoit.lua new file mode 100644 index 0000000..1a3bc55 --- /dev/null +++ b/lexers/autoit.lua @@ -0,0 +1,168 @@ +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. 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 M = {_NAME = '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) + +-- 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)) + +-- 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', + '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', + 'WinSetTrans', 'WinWait', 'WinWaitActive', 'WinWaitClose', 'WinWaitNotActive' +}, nil, true)) + +-- Preprocessor. +local preproc = token(l.PREPROCESSOR, '#' * word_match({ + 'include-once', 'include', 'pragma', 'forceref', 'RequireAdmin', 'NoTrayIcon', + 'OnAutoItStartRegister' +}, '-', 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) + +-- Macros. +local macro = token('macro', '@' * (l.alnum + '_')^1) + +-- Variables. +local var = token(l.VARIABLE, '$' * (l.alnum + '_')^1) + +-- Identifiers. +local ident = token(l.IDENTIFIER, (l.alnum + '_')^1) + +-- Numbers. +local nbr = token(l.NUMBER, l.float + l.integer) + +-- 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 +} + +return M diff --git a/lexers/awk.lua b/lexers/awk.lua index 7948d21..944c698 100644 --- a/lexers/awk.lua +++ b/lexers/awk.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- AWK LPeg lexer. -- Modified by Wolfgang Seeberg 2012, 2013. diff --git a/lexers/bash.lua b/lexers/bash.lua index f15e51a..7bf7957 100644 --- a/lexers/bash.lua +++ b/lexers/bash.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Shell LPeg lexer. local l = require('lexer') diff --git a/lexers/batch.lua b/lexers/batch.lua index d3e1ece..a39d20a 100644 --- a/lexers/batch.lua +++ b/lexers/batch.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Batch LPeg lexer. local l = require('lexer') diff --git a/lexers/bibtex.lua b/lexers/bibtex.lua index 992667a..b47770c 100644 --- a/lexers/bibtex.lua +++ b/lexers/bibtex.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Bibtex LPeg lexer. local l = require('lexer') diff --git a/lexers/boo.lua b/lexers/boo.lua index 54ad1a6..aadacc4 100644 --- a/lexers/boo.lua +++ b/lexers/boo.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Boo LPeg lexer. local l = require('lexer') diff --git a/lexers/caml.lua b/lexers/caml.lua index b701306..be0f241 100644 --- a/lexers/caml.lua +++ b/lexers/caml.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- OCaml LPeg lexer. local l = require('lexer') diff --git a/lexers/cmake.lua b/lexers/cmake.lua index fcc3493..278d96a 100644 --- a/lexers/cmake.lua +++ b/lexers/cmake.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- CMake LPeg lexer. local l = require('lexer') diff --git a/lexers/coffeescript.lua b/lexers/coffeescript.lua index b1c649e..366d390 100644 --- a/lexers/coffeescript.lua +++ b/lexers/coffeescript.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- CoffeeScript LPeg lexer. local l = require('lexer') diff --git a/lexers/container.lua b/lexers/container.lua index 6223f2e..c3a6900 100644 --- a/lexers/container.lua +++ b/lexers/container.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Container LPeg lexer. -- This is SciTE's plain text lexer. diff --git a/lexers/cpp.lua b/lexers/cpp.lua index 3d64c93..518fe64 100644 --- a/lexers/cpp.lua +++ b/lexers/cpp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- C++ LPeg lexer. local l = require('lexer') diff --git a/lexers/csharp.lua b/lexers/csharp.lua index 6f7ab79..6212d37 100644 --- a/lexers/csharp.lua +++ b/lexers/csharp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- C# LPeg lexer. local l = require('lexer') diff --git a/lexers/css.lua b/lexers/css.lua index a753cc7..cb3e26b 100644 --- a/lexers/css.lua +++ b/lexers/css.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- CSS LPeg lexer. local l = require('lexer') diff --git a/lexers/cuda.lua b/lexers/cuda.lua index 0cf22e6..c24c778 100644 --- a/lexers/cuda.lua +++ b/lexers/cuda.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- CUDA LPeg lexer. local l = require('lexer') diff --git a/lexers/desktop.lua b/lexers/desktop.lua index 267f366..22c95f3 100644 --- a/lexers/desktop.lua +++ b/lexers/desktop.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Desktop Entry LPeg lexer. local l = require('lexer') diff --git a/lexers/diff.lua b/lexers/diff.lua index 24f7ff2..9bc63f1 100644 --- a/lexers/diff.lua +++ b/lexers/diff.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Diff LPeg lexer. local l = require('lexer') diff --git a/lexers/django.lua b/lexers/django.lua index 13a5341..19bcc05 100644 --- a/lexers/django.lua +++ b/lexers/django.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Django LPeg lexer. local l = require('lexer') diff --git a/lexers/dmd.lua b/lexers/dmd.lua index 2675559..f73763a 100644 --- a/lexers/dmd.lua +++ b/lexers/dmd.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- D LPeg lexer. -- Heavily modified by Brian Schott (@Hackerpilot on Github). diff --git a/lexers/eiffel.lua b/lexers/eiffel.lua index 871ed8f..7dd08d1 100644 --- a/lexers/eiffel.lua +++ b/lexers/eiffel.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Eiffel LPeg lexer. local l = require('lexer') diff --git a/lexers/elixir.lua b/lexers/elixir.lua index 015f29b..264f713 100644 --- a/lexers/elixir.lua +++ b/lexers/elixir.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2015-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Contributed by Richard Philips. -- Elixer LPeg lexer. @@ -36,7 +36,7 @@ local keyword_token = token(l.KEYWORD, word_match{ "is_port", "is_record", "is_reference", "is_tuple", "is_exception", "case", "when", "cond", "for", "if", "unless", "try", "receive", "send", "exit", "raise", "throw", "after", "rescue", "catch", "else", "do", "end", "quote", - "unquote", "super", "import", "require", "alias", "use", "self" + "unquote", "super", "import", "require", "alias", "use", "self", "with", "fn" }) -- Functions diff --git a/lexers/erlang.lua b/lexers/erlang.lua index 73321fa..a741d63 100644 --- a/lexers/erlang.lua +++ b/lexers/erlang.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Erlang LPeg lexer. local l = require('lexer') diff --git a/lexers/faust.lua b/lexers/faust.lua index a4563e7..34c925e 100644 --- a/lexers/faust.lua +++ b/lexers/faust.lua @@ -1,5 +1,5 @@ +-- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE. -- Faust LPeg lexer, see http://faust.grame.fr/ --- Author: David B. Lamkins <david@lamkins.net> local l = require('lexer') local token, word_match = l.token, l.word_match @@ -27,10 +27,10 @@ local number = token(l.NUMBER, flt + int) -- Keywords. local keyword = token(l.KEYWORD, word_match{ - 'declare', 'import', 'mdoctags', 'dependencies', 'distributed', - 'inputs', 'outputs', 'par', 'seq', 'sum', 'prod', 'xor', 'with', - 'environment', 'library', 'component', 'ffunction', 'fvariable', - 'fconstant', 'int', 'float', 'case', 'waveform', 'h:', 'v:', 't:' + 'declare', 'import', 'mdoctags', 'dependencies', 'distributed', 'inputs', + 'outputs', 'par', 'seq', 'sum', 'prod', 'xor', 'with', 'environment', + 'library', 'component', 'ffunction', 'fvariable', 'fconstant', 'int', 'float', + 'case', 'waveform', 'h:', 'v:', 't:' }) -- Identifiers. diff --git a/lexers/fish.lua b/lexers/fish.lua index 9142d60..24ee2df 100644 --- a/lexers/fish.lua +++ b/lexers/fish.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Jason Schindler. See LICENSE. +-- Copyright 2015-2016 Jason Schindler. See LICENSE. -- Fish (http://fishshell.com/) script LPeg lexer. local l = require('lexer') diff --git a/lexers/forth.lua b/lexers/forth.lua index 450f528..d61aa55 100644 --- a/lexers/forth.lua +++ b/lexers/forth.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Forth LPeg lexer. local l = require('lexer') diff --git a/lexers/fortran.lua b/lexers/fortran.lua index c85cbff..2a1fe97 100644 --- a/lexers/fortran.lua +++ b/lexers/fortran.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Fortran LPeg lexer. local l = require('lexer') diff --git a/lexers/fsharp.lua b/lexers/fsharp.lua index b620552..383ab6a 100644 --- a/lexers/fsharp.lua +++ b/lexers/fsharp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- F# LPeg lexer. local l = require('lexer') diff --git a/lexers/gap.lua b/lexers/gap.lua index 78a4b77..3d9f7a4 100644 --- a/lexers/gap.lua +++ b/lexers/gap.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Gap LPeg lexer. local l = require('lexer') diff --git a/lexers/gettext.lua b/lexers/gettext.lua index d63ef41..8556d01 100644 --- a/lexers/gettext.lua +++ b/lexers/gettext.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Gettext LPeg lexer. local l = require('lexer') diff --git a/lexers/gherkin.lua b/lexers/gherkin.lua new file mode 100644 index 0000000..c4f4dae --- /dev/null +++ b/lexers/gherkin.lua @@ -0,0 +1,64 @@ +-- Copyright 2015-2016 Jason Schindler. See LICENSE. +-- Gherkin (https://github.com/cucumber/cucumber/wiki/Gherkin) LPeg lexer. + +local l = require('lexer') +local token, word_match = l.token, l.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'gherkin'} + +-- Whitespace. +local ws = token(l.WHITESPACE, l.space^1) + +-- Tags. +local tag = token('tag', '@' * l.word^0) + +-- Comments. +local comment = token(l.COMMENT, '#' * l.nonnewline^0) + +-- Strings. +local doc_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 +local dq_str = l.delimited_range('"') + +local string = token(l.STRING, doc_str + dq_str) + +-- Placeholders. +local placeholder = token('placeholder', l.nested_pair('<', '>')) + +-- Keywords. +local keyword = token(l.KEYWORD, word_match{ + 'Given', 'When', 'Then', 'And', 'But' +}) + +-- Identifiers. +local identifier = token(l.KEYWORD, P('Scenario Outline') + word_match{ + 'Feature', 'Background', 'Scenario', 'Scenarios', 'Examples' +}) + +-- Examples. +local example = token('example', '|' * l.nonnewline^0) + +-- Numbers. +local number = token(l.NUMBER, l.float + l.integer) + +M._rules = { + {'whitespace', ws}, + {'comment', comment}, + {'tag', tag}, + {'placeholder', placeholder}, + {'keyword', keyword}, + {'identifier', identifier}, + {'example', example}, + {'string', string}, + {'number', number} +} + +M._tokenstyles = { + tag = l.STYLE_LABEL, + placeholder = l.STYLE_NUMBER, + example = l.STYLE_NUMBER +} + +M._FOLDBYINDENTATION = true + +return M diff --git a/lexers/glsl.lua b/lexers/glsl.lua index 65f8303..6d59da8 100644 --- a/lexers/glsl.lua +++ b/lexers/glsl.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- GLSL LPeg lexer. local l = require('lexer') diff --git a/lexers/gnuplot.lua b/lexers/gnuplot.lua index 8561812..26913db 100644 --- a/lexers/gnuplot.lua +++ b/lexers/gnuplot.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Gnuplot LPeg lexer. local l = require('lexer') diff --git a/lexers/go.lua b/lexers/go.lua index 9cc7984..431c622 100644 --- a/lexers/go.lua +++ b/lexers/go.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Go LPeg lexer. local l = require('lexer') diff --git a/lexers/groovy.lua b/lexers/groovy.lua index 92013a7..d23a5a1 100644 --- a/lexers/groovy.lua +++ b/lexers/groovy.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Groovy LPeg lexer. local l = require('lexer') diff --git a/lexers/gtkrc.lua b/lexers/gtkrc.lua index 8aec8c3..02e4d45 100644 --- a/lexers/gtkrc.lua +++ b/lexers/gtkrc.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Gtkrc LPeg lexer. local l = require('lexer') diff --git a/lexers/haskell.lua b/lexers/haskell.lua index 46b5434..de247e1 100644 --- a/lexers/haskell.lua +++ b/lexers/haskell.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Haskell LPeg lexer. -- Modified by Alex Suraci. diff --git a/lexers/html.lua b/lexers/html.lua index 6034702..3a3b78c 100644 --- a/lexers/html.lua +++ b/lexers/html.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- HTML LPeg lexer. local l = require('lexer') diff --git a/lexers/icon.lua b/lexers/icon.lua new file mode 100644 index 0000000..6d0286f --- /dev/null +++ b/lexers/icon.lua @@ -0,0 +1,78 @@ +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. +-- LPeg lexer for the Icon programming language. +-- http://www.cs.arizona.edu/icon +-- Contributed by Carl Sturtivant. + +local l = require('lexer') +local token, word_match = l.token, l.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'icon'} + +-- Whitespace. +local ws = token(l.WHITESPACE, l.space^1) + +--Comments +local line_comment = '#' * l.nonnewline_esc^0 +local comment = token(l.COMMENT, line_comment) + +-- Strings. +local cset = l.delimited_range("'") +local str = l.delimited_range('"') +local string = token(l.STRING, cset + str) + +-- Numbers. +local radix_literal = P('-')^-1 * l.dec_num * S('rR') * l.alnum^1 +local number = token(l.NUMBER, radix_literal + l.float + l.integer) + +-- Preprocessor. +local preproc_word = word_match{ + 'include', 'line', 'define', 'undef', 'ifdef', 'ifndef', 'else', 'endif', + 'error' +} +local preproc = token(l.PREPROCESSOR, S(' \t')^0 * P('$') * preproc_word) + +-- Keywords. +local keyword = token(l.KEYWORD, word_match{ + 'break', 'by', 'case', 'create', 'default', 'do', 'else', 'end', 'every', + 'fail', 'global', 'if', 'initial', 'invocable', 'link', 'local', 'next', + 'not', 'of', 'procedure', 'record', 'repeat', 'return', 'static', 'suspend', + 'then', 'to', 'until', 'while' +}) + +-- Icon Keywords: unique to Icon; use l.TYPE, as Icon is dynamically typed +local type = token(l.TYPE, P('&') * word_match{ + 'allocated', 'ascii', 'clock', 'collections', 'cset', 'current', 'date', + 'dateline', 'digits', 'dump', 'e', 'error', 'errornumber', 'errortext', + 'errorvalue', 'errout', 'fail', 'features', 'file', 'host', 'input', 'lcase', + 'letters', 'level', 'line', 'main', 'null', 'output', 'phi', 'pi', 'pos', + 'progname', 'random', 'regions', 'source', 'storage', 'subject', 'time', + 'trace', 'ucase', 'version' +}) + +-- Identifiers. +local identifier = token(l.IDENTIFIER, l.word) + +-- Operators. +local operator = token(l.OPERATOR, S('+-/*%<>~!=^&|?~@:;,.()[]{}')) + +M._rules = { + {'whitespace', ws}, + {'keyword', keyword}, + {'type', type}, + {'identifier', identifier}, + {'comment', comment}, + {'string', string}, + {'number', number}, + {'preproc', preproc}, + {'operator', operator}, +} + +M._foldsymbols = { + _patterns = {'%l+', '#'}, + [l.PREPROCESSOR] = {ifdef = 1, ifndef = 1, endif = -1}, + [l.KEYWORD] = { procedure = 1, ['end'] = -1}, + [l.COMMENT] = {['#'] = l.fold_line_comments('#')} +} + +return M diff --git a/lexers/idl.lua b/lexers/idl.lua index bc5cbff..8d2399c 100644 --- a/lexers/idl.lua +++ b/lexers/idl.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- IDL LPeg lexer. local l = require('lexer') diff --git a/lexers/ini.lua b/lexers/ini.lua index 15ea7fa..e5df55a 100644 --- a/lexers/ini.lua +++ b/lexers/ini.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Ini LPeg lexer. local l = require('lexer') diff --git a/lexers/io_lang.lua b/lexers/io_lang.lua index 540628c..0d8b483 100644 --- a/lexers/io_lang.lua +++ b/lexers/io_lang.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Io LPeg lexer. local l = require('lexer') diff --git a/lexers/java.lua b/lexers/java.lua index a94ae6d..8773f60 100644 --- a/lexers/java.lua +++ b/lexers/java.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Java LPeg lexer. -- Modified by Brian Schott. diff --git a/lexers/javascript.lua b/lexers/javascript.lua index a9f469b..feb212b 100644 --- a/lexers/javascript.lua +++ b/lexers/javascript.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- JavaScript LPeg lexer. local l = require('lexer') diff --git a/lexers/jsp.lua b/lexers/jsp.lua index 946fe7e..44f53d2 100644 --- a/lexers/jsp.lua +++ b/lexers/jsp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- JSP LPeg lexer. local l = require('lexer') diff --git a/lexers/latex.lua b/lexers/latex.lua index e3eaa27..f1febe9 100644 --- a/lexers/latex.lua +++ b/lexers/latex.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Latex LPeg lexer. -- Modified by Brian Schott. -- Modified by Robert Gieseke. diff --git a/lexers/ledger.lua b/lexers/ledger.lua index ad10b42..1632241 100644 --- a/lexers/ledger.lua +++ b/lexers/ledger.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Charles Lehner. See LICENSE. +-- Copyright 2015-2016 Charles Lehner. See LICENSE. -- ledger journal LPeg lexer, see http://www.ledger-cli.org/ local l = require('lexer') diff --git a/lexers/lexer.lua b/lexers/lexer.lua index 36f68d8..992d690 100644 --- a/lexers/lexer.lua +++ b/lexers/lexer.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. local M = {} diff --git a/lexers/lisp.lua b/lexers/lisp.lua index cdc7126..2d8a907 100644 --- a/lexers/lisp.lua +++ b/lexers/lisp.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Lisp LPeg lexer. local l = require('lexer') diff --git a/lexers/lua.lua b/lexers/lua.lua index 2ad1190..fba4600 100644 --- a/lexers/lua.lua +++ b/lexers/lua.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Lua LPeg lexer. -- Original written by Peter Odding, 2007/04/04. diff --git a/lexers/makefile.lua b/lexers/makefile.lua index 480e032..45eb310 100644 --- a/lexers/makefile.lua +++ b/lexers/makefile.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Makefile LPeg lexer. local l = require('lexer') diff --git a/lexers/man.lua b/lexers/man.lua index a2d6175..557e11d 100644 --- a/lexers/man.lua +++ b/lexers/man.lua @@ -1,3 +1,4 @@ +-- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE. -- man/roff LPeg lexer. local l = require('lexer') @@ -11,13 +12,14 @@ local ws = token(l.WHITESPACE, l.space^1) -- Markup. local rule1 = token(l.STRING, - P('.') * (P('B') * P('R')^-1 + P('I') * P('PR')^-1) * l.nonnewline^0) + P('.') * (P('B') * P('R')^-1 + P('I') * P('PR')^-1) * + l.nonnewline^0) local rule2 = token(l.NUMBER, P('.') * S('ST') * P('H') * l.nonnewline^0) local rule3 = token(l.KEYWORD, - P('.br') + P('.DS') + P('.RS') + P('.RE') + P('.PD')) + P('.br') + P('.DS') + P('.RS') + P('.RE') + P('.PD')) local rule4 = token(l.LABEL, P('.') * (S('ST') * P('H') + P('.TP'))) local rule5 = token(l.VARIABLE, - P('.B') * P('R')^-1 + P('.I') * S('PR')^-1 + P('.PP')) + P('.B') * P('R')^-1 + P('.I') * S('PR')^-1 + P('.PP')) local rule6 = token(l.TYPE, P('\\f') * S('BIPR')) local rule7 = token(l.PREPROCESSOR, l.starts_line('.') * l.alpha^1) diff --git a/lexers/markdown.lua b/lexers/markdown.lua index b865955..14380e9 100644 --- a/lexers/markdown.lua +++ b/lexers/markdown.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Markdown LPeg lexer. local l = require('lexer') diff --git a/lexers/nemerle.lua b/lexers/nemerle.lua index d628c8a..3bab7a7 100644 --- a/lexers/nemerle.lua +++ b/lexers/nemerle.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Nemerle LPeg lexer. local l = require('lexer') diff --git a/lexers/nim.lua b/lexers/nim.lua index d830774..8fa438c 100644 --- a/lexers/nim.lua +++ b/lexers/nim.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Nim LPeg lexer. local l = require('lexer') diff --git a/lexers/null.lua b/lexers/null.lua index d5a1131..c2e70c2 100644 --- a/lexers/null.lua +++ b/lexers/null.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Null LPeg lexer. local M = {_NAME = 'null'} diff --git a/lexers/objective_c.lua b/lexers/objective_c.lua index db8a5a2..4722c2c 100644 --- a/lexers/objective_c.lua +++ b/lexers/objective_c.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Objective C LPeg lexer. local l = require('lexer') diff --git a/lexers/pascal.lua b/lexers/pascal.lua index 20a7800..6cb6a2e 100644 --- a/lexers/pascal.lua +++ b/lexers/pascal.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Pascal LPeg lexer. local l = require('lexer') diff --git a/lexers/perl.lua b/lexers/perl.lua index a80248c..f77893e 100644 --- a/lexers/perl.lua +++ b/lexers/perl.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Perl LPeg lexer. local l = require('lexer') diff --git a/lexers/php.lua b/lexers/php.lua index feaa670..22eb960 100644 --- a/lexers/php.lua +++ b/lexers/php.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- PHP LPeg lexer. local l = require('lexer') diff --git a/lexers/pike.lua b/lexers/pike.lua index d5a130c..9367ea2 100644 --- a/lexers/pike.lua +++ b/lexers/pike.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Pike LPeg lexer. local l = require('lexer') diff --git a/lexers/powershell.lua b/lexers/powershell.lua index a94938b..4a3ba07 100644 --- a/lexers/powershell.lua +++ b/lexers/powershell.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2015-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- PowerShell LPeg lexer. -- Contributed by Jeff Stone. diff --git a/lexers/prolog.lua b/lexers/prolog.lua index 8fe63dc..bda9b53 100644 --- a/lexers/prolog.lua +++ b/lexers/prolog.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Prolog LPeg lexer. local l = require('lexer') diff --git a/lexers/props.lua b/lexers/props.lua index ef5edad..5602787 100644 --- a/lexers/props.lua +++ b/lexers/props.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Props LPeg lexer. local l = require('lexer') diff --git a/lexers/ps.lua b/lexers/ps.lua index 5aa8d62..c8a0ac4 100644 --- a/lexers/ps.lua +++ b/lexers/ps.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Postscript LPeg lexer. local l = require('lexer') diff --git a/lexers/pure.lua b/lexers/pure.lua index bece406..256a2dc 100644 --- a/lexers/pure.lua +++ b/lexers/pure.lua @@ -1,5 +1,5 @@ +-- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE. -- pure LPeg lexer, see http://purelang.bitbucket.org/ --- Author: David B. Lamkins <david@lamkins.net> local l = require('lexer') local token, word_match = l.token, l.word_match @@ -30,10 +30,10 @@ local number = token(l.NUMBER, flt + int) -- Keywords. local keyword = token(l.KEYWORD, word_match{ - 'namespace', 'with', 'end', 'using', 'interface', 'extern', 'let', - 'const', 'def', 'type', 'public', 'private', 'nonfix', 'outfix', - 'infix', 'infixl', 'infixr', 'prefix', 'postfix', 'if', 'otherwise', - 'when', 'case', 'of', 'then', 'else' + 'namespace', 'with', 'end', 'using', 'interface', 'extern', 'let', 'const', + 'def', 'type', 'public', 'private', 'nonfix', 'outfix', 'infix', 'infixl', + 'infixr', 'prefix', 'postfix', 'if', 'otherwise', 'when', 'case', 'of', + 'then', 'else' }) -- Identifiers. diff --git a/lexers/python.lua b/lexers/python.lua index a96ac60..42b931d 100644 --- a/lexers/python.lua +++ b/lexers/python.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Python LPeg lexer. local l = require('lexer') diff --git a/lexers/rails.lua b/lexers/rails.lua index 07f463c..1ecfa16 100644 --- a/lexers/rails.lua +++ b/lexers/rails.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Ruby on Rails LPeg lexer. local l = require('lexer') diff --git a/lexers/rebol.lua b/lexers/rebol.lua index ecedd5a..3ab7691 100644 --- a/lexers/rebol.lua +++ b/lexers/rebol.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Rebol LPeg lexer. local l = require('lexer') diff --git a/lexers/rest.lua b/lexers/rest.lua index 1e0b3b1..8a355be 100644 --- a/lexers/rest.lua +++ b/lexers/rest.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- reStructuredText LPeg lexer. local l = require('lexer') diff --git a/lexers/rexx.lua b/lexers/rexx.lua index 6e13dd3..582d86e 100644 --- a/lexers/rexx.lua +++ b/lexers/rexx.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Rexx LPeg lexer. local l = require('lexer') @@ -67,7 +67,7 @@ local func = token(l.FUNCTION, word_match({ }, '2', true)) -- Identifiers. -local word = l.alpha * (l.alnum + S('@#$\\.!?_')^0) +local word = l.alpha * (l.alnum + S('@#$\\.!?_'))^0 local identifier = token(l.IDENTIFIER, word) -- Operators. diff --git a/lexers/rhtml.lua b/lexers/rhtml.lua index 00dee38..3886e20 100644 --- a/lexers/rhtml.lua +++ b/lexers/rhtml.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- RHTML LPeg lexer. local l = require('lexer') diff --git a/lexers/rstats.lua b/lexers/rstats.lua index a17bac0..19e43e8 100644 --- a/lexers/rstats.lua +++ b/lexers/rstats.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- R LPeg lexer. local l = require('lexer') diff --git a/lexers/ruby.lua b/lexers/ruby.lua index 910b906..d923917 100644 --- a/lexers/ruby.lua +++ b/lexers/ruby.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Ruby LPeg lexer. local l = require('lexer') diff --git a/lexers/rust.lua b/lexers/rust.lua index 4fef3ae..f8ad5a8 100644 --- a/lexers/rust.lua +++ b/lexers/rust.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. +-- Copyright 2015-2016 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. -- Rust LPeg lexer. local l = require("lexer") diff --git a/lexers/scheme.lua b/lexers/scheme.lua index bec5377..4d10bbb 100644 --- a/lexers/scheme.lua +++ b/lexers/scheme.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Scheme LPeg lexer. local l = require('lexer') diff --git a/lexers/smalltalk.lua b/lexers/smalltalk.lua index 298173f..735ea47 100644 --- a/lexers/smalltalk.lua +++ b/lexers/smalltalk.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Smalltalk LPeg lexer. local l = require('lexer') diff --git a/lexers/snobol4.lua b/lexers/snobol4.lua new file mode 100644 index 0000000..08e5a9b --- /dev/null +++ b/lexers/snobol4.lua @@ -0,0 +1,64 @@ +-- Copyright 2013-2016 Michael T. Richter. See LICENSE. +-- SNOBOL4 lexer. +-- This lexer works with classic SNOBOL4 as well as the CSNOBOL4 extensions. + +local l = require 'lexer' +local token, word_match = l.token, l.word_match +local B, P, R, S, V = lpeg.B, lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local M = { _NAME = 'snobol4' } + +-- Helper patterns. +local dotted_id = l.word * (P'.' * l.word)^0 + +local dq_str = l.delimited_range('"', true, true) +local sq_str = l.delimited_range("'", true, true) + +local branch = B(l.space * P':(') * dotted_id * #P')' +local sbranch = B(l.space * P':' * S'SF' * '(') * dotted_id * #P')' +local sbranchx = B(P')' * S'SF' * P'(') * dotted_id * #P')' + +-- Token definitions. +local bif = token(l.FUNCTION, l.word_match({ + 'APPLY', 'ARRAY', 'CHAR', 'CONVERT', 'COPY', 'DATA', 'DATE', 'DIFFER', 'DUPL', + 'EQ', 'EVAL', 'FILE_ABSPATH', 'FILE_ISDIR', 'FREEZE', 'FUNCTION', 'GE', 'GT', + 'HOST', 'IDENT', 'INTEGER', 'IO_FINDUNIT', 'ITEM', 'LABEL', 'LOAD', 'LPAD', + 'LE', 'LGT', 'LT', 'NE', 'OPSYN', 'ORD', 'PROTOTYPE', 'REMDR', 'REPLACE', + 'REVERSE', 'RPAD', 'RSORT', 'SERV_LISTEN', 'SET', 'SETEXIT', 'SIZE', 'SORT', + 'SQRT', 'SSET', 'SUBSTR', 'TABLE', 'THAW', 'TIME', 'TRACE', 'TRIM', 'UNLOAD', + 'VALUE', 'VDIFFER', +}, '', true) * #l.delimited_range('()', false, true, true)) +local comment = token(l.COMMENT, l.starts_line(S'*#|;!' * l.nonnewline^0)) +local control = token(l.PREPROCESSOR, l.starts_line(P'-' * l.word)) +local identifier = token(l.DEFAULT, dotted_id) +local keyword = token(l.KEYWORD, l.word_match({ + 'ABORT', 'ARRAY', 'CONTINUE', 'DEFINE', 'END', 'FRETURN', 'INPUT', 'NRETURN', + 'OUTPUT', 'PUNCH', 'RETURN', 'SCONTINUE', 'TABLE', +}, '', true) + P'&' * l.word) +local label = token(l.LABEL, l.starts_line(dotted_id)) +local number = token(l.NUMBER, l.float + l.integer) +local operator = token(l.OPERATOR, S'¬?$.!%*/#+-@⊥&^~\\=') +local pattern = l.token(l.CLASS, l.word_match({ -- "class" to keep distinct + 'ABORT', 'ANY', 'ARB', 'ARBNO', 'BAL', 'BREAK', 'BREAKX', 'FAIL', 'FENCE', + 'LEN', 'NOTANY', 'POS', 'REM', 'RPOS', 'RTAB', 'SPAN', 'SUCCEED', 'TAB', +}, '', true) * #l.delimited_range('()', false, true, true)) +local str = token(l.STRING, sq_str + dq_str) +local target = token(l.LABEL, branch + sbranch + sbranchx) +local ws = token(l.WHITESPACE, l.space^1) + +M._rules = { + { 'comment', comment }, + { 'control', control }, + { 'string', str }, + { 'number', number }, + { 'keyword', keyword }, + { 'label', label }, + { 'target', target }, + { 'pattern', pattern }, + { 'built-in', bif }, + { 'operator', operator }, + { 'identifier', identifier }, + { 'whitespace', ws }, +} + +return M diff --git a/lexers/sql.lua b/lexers/sql.lua index 1ff5a74..7ea207f 100644 --- a/lexers/sql.lua +++ b/lexers/sql.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- SQL LPeg lexer. local l = require('lexer') diff --git a/lexers/tcl.lua b/lexers/tcl.lua index f014c35..f76e6ee 100644 --- a/lexers/tcl.lua +++ b/lexers/tcl.lua @@ -1,4 +1,4 @@ --- Copyright 2014-2015 Joshua Krämer. See LICENSE. +-- Copyright 2014-2016 Joshua Krämer. See LICENSE. -- Tcl LPeg lexer. -- This lexer follows the TCL dodekalogue (http://wiki.tcl.tk/10259). -- It is based on the previous lexer by Mitchell. diff --git a/lexers/tex.lua b/lexers/tex.lua index 7eb9e75..ec1e717 100644 --- a/lexers/tex.lua +++ b/lexers/tex.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Plain TeX LPeg lexer. -- Modified by Robert Gieseke. diff --git a/lexers/texinfo.lua b/lexers/texinfo.lua index f964424..34f9eb2 100644 --- a/lexers/texinfo.lua +++ b/lexers/texinfo.lua @@ -1,4 +1,4 @@ --- Copyright 2014-2015 stef@ailleurs.land. See LICENSE. +-- Copyright 2014-2016 stef@ailleurs.land. See LICENSE. -- Plain Texinfo version 5.2 LPeg lexer -- Freely inspired from Mitchell work and valuable help from him too ! diff --git a/lexers/text.lua b/lexers/text.lua index 6331f93..51b4f11 100644 --- a/lexers/text.lua +++ b/lexers/text.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Text LPeg lexer. local M = {_NAME = 'text'} diff --git a/lexers/toml.lua b/lexers/toml.lua index d7d2960..82ca91c 100644 --- a/lexers/toml.lua +++ b/lexers/toml.lua @@ -1,4 +1,4 @@ --- Copyright 2015 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. +-- Copyright 2015-2016 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. -- TOML LPeg lexer. local l = require("lexer") diff --git a/lexers/vala.lua b/lexers/vala.lua index d9a0a3a..46f074c 100644 --- a/lexers/vala.lua +++ b/lexers/vala.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Vala LPeg lexer. local l = require('lexer') diff --git a/lexers/vb.lua b/lexers/vb.lua index 6541a92..453a74c 100644 --- a/lexers/vb.lua +++ b/lexers/vb.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- VisualBasic LPeg lexer. local l = require('lexer') diff --git a/lexers/vbscript.lua b/lexers/vbscript.lua index f4d9f36..1fcc6d7 100644 --- a/lexers/vbscript.lua +++ b/lexers/vbscript.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- VisualBasic LPeg lexer. local l = require('lexer') diff --git a/lexers/verilog.lua b/lexers/verilog.lua index bfee3b6..9160e0f 100644 --- a/lexers/verilog.lua +++ b/lexers/verilog.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- Verilog LPeg lexer. local l = require('lexer') diff --git a/lexers/vhdl.lua b/lexers/vhdl.lua index 4cad5f7..6bbba11 100644 --- a/lexers/vhdl.lua +++ b/lexers/vhdl.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- VHDL LPeg lexer. local l = require('lexer') diff --git a/lexers/wsf.lua b/lexers/wsf.lua index fc024b2..21da83c 100644 --- a/lexers/wsf.lua +++ b/lexers/wsf.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- WSF LPeg lexer (based on XML). -- Contributed by Jeff Stone. diff --git a/lexers/xml.lua b/lexers/xml.lua index 25e6e45..2692b2a 100644 --- a/lexers/xml.lua +++ b/lexers/xml.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- XML LPeg lexer. local l = require('lexer') diff --git a/lexers/xtend.lua b/lexers/xtend.lua index 500dc33..cc2bf8e 100644 --- a/lexers/xtend.lua +++ b/lexers/xtend.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2014-2015 Piotr Orzechowski [drzewo.org]. See LICENSE. +-- Copyright (c) 2014-2016 Piotr Orzechowski [drzewo.org]. See LICENSE. -- Xtend LPeg lexer. local l = require('lexer') diff --git a/lexers/yaml.lua b/lexers/yaml.lua index 9c015e3..b88d5a0 100644 --- a/lexers/yaml.lua +++ b/lexers/yaml.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. -- YAML LPeg lexer. -- It does not keep track of indentation perfectly. |
