From c457b4b2d663a3a34dd983a645902812077fbe7f Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 2 Dec 2024 19:17:04 +0100 Subject: [PATCH] Import NSIS Lexer from Pygments --- README.md | 2 +- lexers/embedded/nsis.xml | 59 ++++++++++++++ lexers/testdata/nsis.actual | 37 +++++++++ lexers/testdata/nsis.expected | 148 ++++++++++++++++++++++++++++++++++ 4 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 lexers/embedded/nsis.xml create mode 100644 lexers/testdata/nsis.actual create mode 100644 lexers/testdata/nsis.expected diff --git a/README.md b/README.md index 7c35585a7..735b55671 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ translators for Pygments lexers and styles. | K | Kotlin | | L | Lighttpd configuration file, LLVM, Lua | | M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, MCFunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL | -| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix | +| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix, NSIS | | O | Objective-C, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode | | P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, PromQL, Promela, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 | | Q | QBasic, QML | diff --git a/lexers/embedded/nsis.xml b/lexers/embedded/nsis.xml new file mode 100644 index 000000000..6c3a7be96 --- /dev/null +++ b/lexers/embedded/nsis.xml @@ -0,0 +1,59 @@ + + + NSIS + nsis + nsi + nsh + *.nsi + *.nsh + text/x-nsis + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lexers/testdata/nsis.actual b/lexers/testdata/nsis.actual new file mode 100644 index 000000000..1a11d55fb --- /dev/null +++ b/lexers/testdata/nsis.actual @@ -0,0 +1,37 @@ +!include "nsDialogs.nsh" +!include "winmessages.nsh" +!include "logiclib.nsh" +OutFile "test.exe" + +Page Custom pre + +var dialog +var hwnd +var button + +Function pre + nsDialogs::Create 1018 + Pop $dialog + ${NSD_CreateCheckbox} 0 0 50 6 "Enable button below" + Pop $hwnd + ${NSD_OnClick} $hwnd EnDisableButton + + ${NSD_CreateButton} 25 25 50 50 "Hello World" + Pop $button + EnableWindow $button 0 # start out disabled + + nsDialogs::Show +FunctionEnd + +Function EnDisableButton + Pop $hwnd + ${NSD_GetState} $hwnd $0 + ${If} $0 == 1 + EnableWindow $button 1 + ${Else} + EnableWindow $button 0 + ${EndIf} +FunctionEnd + +Section "" +SectionEnd diff --git a/lexers/testdata/nsis.expected b/lexers/testdata/nsis.expected new file mode 100644 index 000000000..deecc5ea1 --- /dev/null +++ b/lexers/testdata/nsis.expected @@ -0,0 +1,148 @@ +[ + {"type":"CommentPreproc","value":"!include"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"nsDialogs.nsh\""}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"CommentPreproc","value":"!include"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"winmessages.nsh\""}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"CommentPreproc","value":"!include"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"logiclib.nsh\""}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"OutFile"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"test.exe\""}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Keyword","value":"Page"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"Custom"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"pre"}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Keyword","value":"var"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"dialog"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"var"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"hwnd"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"var"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"button"}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Keyword","value":"Function"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"pre"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordNamespace","value":"nsDialogs"}, + {"type":"Punctuation","value":"::"}, + {"type":"NameFunction","value":"Create"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"1018"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"Keyword","value":"Pop"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$dialog"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordPseudo","value":"${NSD_CreateCheckbox}"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"0"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"0"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"50"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"6"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"Enable button below\""}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"Keyword","value":"Pop"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$hwnd"}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"KeywordPseudo","value":"${NSD_OnClick}"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$hwnd"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"EnDisableButton"}, + {"type":"TextWhitespace","value":"\n\n\t"}, + {"type":"KeywordPseudo","value":"${NSD_CreateButton}"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"25"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"25"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"50"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"50"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"Hello World\""}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"Keyword","value":"Pop"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$button"}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"Keyword","value":"EnableWindow"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$button"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"0"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Comment","value":"# start out disabled"}, + {"type":"TextWhitespace","value":"\n\n\t"}, + {"type":"KeywordNamespace","value":"nsDialogs"}, + {"type":"Punctuation","value":"::"}, + {"type":"NameFunction","value":"Show"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"FunctionEnd"}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Keyword","value":"Function"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"EnDisableButton"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"Keyword","value":"Pop"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$hwnd"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordPseudo","value":"${NSD_GetState}"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$hwnd"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameBuiltinPseudo","value":"$0"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordPseudo","value":"${If}"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameBuiltinPseudo","value":"$0"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":"=="}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"1"}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"Keyword","value":"EnableWindow"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$button"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"1"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordPseudo","value":"${Else}"}, + {"type":"TextWhitespace","value":"\n\t\t"}, + {"type":"Keyword","value":"EnableWindow"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameVariable","value":"$button"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Text","value":"0"}, + {"type":"TextWhitespace","value":"\n\t"}, + {"type":"KeywordPseudo","value":"${EndIf}"}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"FunctionEnd"}, + {"type":"TextWhitespace","value":"\n\n"}, + {"type":"Keyword","value":"Section"}, + {"type":"TextWhitespace","value":" "}, + {"type":"LiteralStringDouble","value":"\"\""}, + {"type":"TextWhitespace","value":"\n"}, + {"type":"Keyword","value":"SectionEnd"}, + {"type":"TextWhitespace","value":"\n"} +]