logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

nsis.lua (8095B)


  1. -- Copyright 2006-2024 Robert Gieseke. See LICENSE.
  2. -- NSIS LPeg lexer
  3. -- Based on NSIS 2.46 docs: http://nsis.sourceforge.net/Docs/.
  4. local lexer = require('lexer')
  5. local token, word_match = lexer.token, lexer.word_match
  6. local P, S = lpeg.P, lpeg.S
  7. local lex = lexer.new('nsis')
  8. -- Whitespace.
  9. lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
  10. -- Comments (4.1).
  11. local line_comment = lexer.to_eol(S(';#'))
  12. local block_comment = lexer.range('/*', '*/')
  13. lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment))
  14. -- Strings.
  15. local sq_str = lexer.range("'")
  16. local dq_str = lexer.range('"')
  17. local bq_str = lexer.range('`')
  18. lex:add_rule('string', token(lexer.STRING, sq_str + dq_str + bq_str))
  19. -- Constants (4.2.3).
  20. lex:add_rule('constant', token(lexer.CONSTANT, word_match{
  21. '$PROGRAMFILES', '$PROGRAMFILES32', '$PROGRAMFILES64', '$COMMONFILES', '$COMMONFILES32',
  22. '$COMMONFILES64', '$DESKTOP', '$EXEDIR', '$EXEFILE', '$EXEPATH', '${NSISDIR}', '$WINDIR',
  23. '$SYSDIR', '$TEMP', '$STARTMENU', '$SMPROGRAMS', '$SMSTARTUP', '$QUICKLAUNCH$DOCUMENTS',
  24. '$SENDTO', '$RECENT', '$FAVORITES', '$MUSIC', '$PICTURES', '$VIDEOS', '$NETHOOD', '$FONTS',
  25. '$TEMPLATES', '$APPDATA', '$LOCALAPPDATA', '$PRINTHOOD', '$INTERNET_CACHE', '$COOKIES',
  26. '$HISTORY', '$PROFILE', '$ADMINTOOLS', '$RESOURCES', '$RESOURCES_LOCALIZED', '$CDBURN_AREA',
  27. '$HWNDPARENT', '$PLUGINSDIR'
  28. }))
  29. -- TODO? Constants used in strings: $$ $\r $\n $\t
  30. -- Variables (4.2).
  31. lex:add_rule('variable', token(lexer.VARIABLE, word_match{
  32. '$0', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$R0', '$R1', '$R2', '$R3', '$R4',
  33. '$R5', '$R6', '$R7', '$R8', '$R9', '$INSTDIR', '$OUTDIR', '$CMDLINE', '$LANGUAGE', 'Var',
  34. '/GLOBAL'
  35. } + '$' * lexer.word))
  36. -- Keywords.
  37. lex:add_rule('keyword', token(lexer.KEYWORD, word_match{
  38. -- Pages (4.5).
  39. 'Page', 'UninstPage', 'PageEx', 'PageEnd', 'PageExEnd',
  40. -- Section commands (4.6).
  41. 'AddSize', 'Section', 'SectionEnd', 'SectionIn', 'SectionGroup', 'SectionGroupEnd',
  42. -- Functions (4.7).
  43. 'Function', 'FunctionEnd',
  44. -- Callbacks (4.7.2).
  45. '.onGUIInit', '.onInit', '.onInstFailed', '.onInstSuccess', '.onGUIEnd', '.onMouseOverSection',
  46. '.onRebootFailed', '.onSelChange', '.onUserAbort', '.onVerifyInstDir', 'un.onGUIInit',
  47. 'un.onInit', 'un.onUninstFailed', 'un.onUninstSuccess', 'un.onGUIEnd', 'un.onRebootFailed',
  48. 'un.onSelChange', 'un.onUserAbort',
  49. -- General Attributes (4.8.1).
  50. 'AddBrandingImage', 'AllowRootDirInstall', 'AutoCloseWindow', 'BGFont', 'BGFont', 'BrandingText',
  51. '/TRIMLEFT', '/TRIMRIGHT', '/TRIMCENTER', 'Caption', 'ChangeUI', 'CheckBitmap', 'CompletedText',
  52. 'ComponentText', 'CRCCheck', 'DetailsButtonText', 'DirText', 'DirVar', 'DirVerify',
  53. 'FileErrorText', 'Icon', 'InstallButtonText', 'InstallColors', 'InstallDir', 'InstallDirRegKey',
  54. 'InstProgressFlags', 'InstType', 'LicenseBkColor', 'LicenseData', 'LicenseForceSelection',
  55. 'LicenseText', 'MiscButtonText', 'Name', 'OutFile', 'RequestExecutionLevel', 'SetFont',
  56. 'ShowInstDetails', 'ShowUninstDetails', 'SilentInstall', 'SilentUnInstall', 'SpaceTexts',
  57. 'SubCaption', 'UninstallButtonText', 'UninstallCaption', 'UninstallIcon', 'UninstallSubCaption',
  58. 'UninstallText', 'WindowIcon', 'XPStyle', 'admin', 'auto', 'bottom', 'checkbox', 'false', 'force',
  59. 'height', 'hide', 'highest', 'leave', 'left', 'nevershow', 'none', 'normal', 'off', 'on',
  60. 'radiobuttons', 'right', 'show', 'silent', 'silentlog', 'top', 'true', 'user', 'width',
  61. -- Compiler Flags (4.8.2).
  62. 'AllowSkipFiles', 'FileBufSize', 'SetCompress', 'SetCompressor', '/SOLID', '/FINAL', 'zlib',
  63. 'bzip2', 'lzma', 'SetCompressorDictSize', 'SetDatablockOptimize', 'SetDateSave', 'SetOverwrite',
  64. 'ifnewer', 'ifdiff', 'lastused', 'try',
  65. -- Version Information (4.8.3).
  66. 'VIAddVersionKey', 'VIProductVersion', '/LANG', 'ProductName', 'Comments', 'CompanyName',
  67. 'LegalCopyright', 'FileDescription', 'FileVersion', 'ProductVersion', 'InternalName',
  68. 'LegalTrademarks', 'OriginalFilename', 'PrivateBuild', 'SpecialBuild',
  69. -- Basic Instructions (4.9.1).
  70. 'Delete', '/REBOOTOK', 'Exec', 'ExecShell', 'ExecShell', 'File', '/nonfatal', 'Rename',
  71. 'ReserveFile', 'RMDir', 'SetOutPath',
  72. -- Registry INI File Instructions (4.9.2).
  73. 'DeleteINISec', 'DeleteINIStr', 'DeleteRegKey', '/ifempty', 'DeleteRegValue', 'EnumRegKey',
  74. 'EnumRegValue', 'ExpandEnvStrings', 'FlushINI', 'ReadEnvStr', 'ReadINIStr', 'ReadRegDWORD',
  75. 'ReadRegStr', 'WriteINIStr', 'WriteRegBin', 'WriteRegDWORD', 'WriteRegStr', 'WriteRegExpandStr',
  76. 'HKCR', 'HKEY_CLASSES_ROOT', 'HKLM', 'HKEY_LOCAL_MACHINE', 'HKCU', 'HKEY_CURRENT_USER', 'HKU',
  77. 'HKEY_USERS', 'HKCC', 'HKEY_CURRENT_CONFIG', 'HKDD', 'HKEY_DYN_DATA', 'HKPD',
  78. 'HKEY_PERFORMANCE_DATA', 'SHCTX', 'SHELL_CONTEXT',
  79. -- General Purpose Instructions (4.9.3).
  80. 'CallInstDLL', 'CopyFiles', '/SILENT', '/FILESONLY', 'CreateDirectory', 'CreateShortCut',
  81. 'GetDLLVersion', 'GetDLLVersionLocal', 'GetFileTime', 'GetFileTimeLocal', 'GetFullPathName',
  82. '/SHORT', 'GetTempFileName', 'SearchPath', 'SetFileAttributes', 'RegDLL', 'UnRegDLL',
  83. -- Flow Control Instructions (4.9.4).
  84. 'Abort', 'Call', 'ClearErrors', 'GetCurrentAddress', 'GetFunctionAddress', 'GetLabelAddress',
  85. 'Goto', 'IfAbort', 'IfErrors', 'IfFileExists', 'IfRebootFlag', 'IfSilent', 'IntCmp', 'IntCmpU',
  86. 'MessageBox', 'MB_OK', 'MB_OKCANCEL', 'MB_ABORTRETRYIGNORE', 'MB_RETRYCANCEL', 'MB_YESNO',
  87. 'MB_YESNOCANCEL', 'MB_ICONEXCLAMATION', 'MB_ICONINFORMATION', 'MB_ICONQUESTION', 'MB_ICONSTOP',
  88. 'MB_USERICON', 'MB_TOPMOST', 'MB_SETFOREGROUND', 'MB_RIGHT', 'MB_RTLREADING', 'MB_DEFBUTTON1',
  89. 'MB_DEFBUTTON2', 'MB_DEFBUTTON3', 'MB_DEFBUTTON4', 'IDABORT', 'IDCANCEL', 'IDIGNORE', 'IDNO',
  90. 'IDOK', 'IDRETRY', 'IDYES', 'Return', 'Quit', 'SetErrors', 'StrCmp', 'StrCmpS',
  91. -- File Instructions (4.9.5).
  92. 'FileClose', 'FileOpen', 'FileRead', 'FileReadByte', 'FileSeek', 'FileWrite', 'FileWriteByte',
  93. 'FindClose', 'FindFirst', 'FindNext',
  94. -- Uninstaller Instructions (4.9.6).
  95. 'WriteUninstaller',
  96. -- Miscellaneous Instructions (4.9.7).
  97. 'GetErrorLevel', 'GetInstDirError', 'InitPluginsDir', 'Nop', 'SetErrorLevel', 'SetRegView',
  98. 'SetShellVarContext', 'all', 'current', 'Sleep',
  99. -- String Manipulation Instructions (4.9.8).
  100. 'StrCpy', 'StrLen',
  101. -- Stack Support (4.9.9).
  102. 'Exch', 'Pop', 'Push',
  103. -- Integer Support (4.9.10).
  104. 'IntFmt', 'IntOp',
  105. -- Reboot Instructions (4.9.11).
  106. 'Reboot', 'SetRebootFlag',
  107. -- Install Logging Instructions (4.9.12).
  108. 'LogSet', 'LogText',
  109. -- Section Management (4.9.13).
  110. 'SectionSetFlags', 'SectionGetFlags', 'SectionGetFlags', 'SectionSetText', 'SectionGetText',
  111. 'SectionSetInstTypes', 'SectionGetInstTypes', 'SectionSetSize', 'SectionGetSize',
  112. 'SetCurInstType', 'GetCurInstType', 'InstTypeSetText', 'InstTypeGetText',
  113. -- User Interface Instructions (4.9.14).
  114. 'BringToFront', 'CreateFont', 'DetailPrint', 'EnableWindow', 'FindWindow', 'GetDlgItem',
  115. 'HideWindow', 'IsWindow', 'LockWindow', 'SendMessage', 'SetAutoClose', 'SetBrandingImage',
  116. 'SetDetailsView', 'SetDetailsPrint', 'listonlytextonly', 'both', 'SetCtlColors', '/BRANDING',
  117. 'SetSilent', 'ShowWindow',
  118. -- Multiple Languages Instructions (4.9.15).
  119. 'LoadLanguageFile', 'LangString', 'LicenseLangString',
  120. -- Compile time commands (5).
  121. '!include', '!addincludedir', '!addplugindir', '!appendfile', '!cd', '!delfile', '!echo',
  122. '!error', '!execute', '!packhdr', '!system', '!tempfile', '!warning', '!verbose', '{__FILE__}',
  123. '{__LINE__}', '{__DATE__}', '{__TIME__}', '{__TIMESTAMP__}', '{NSIS_VERSION}', '!define',
  124. '!undef', '!ifdef', '!ifndef', '!if', '!ifmacrodef', '!ifmacrondef', '!else', '!endif',
  125. '!insertmacro', '!macro', '!macroend', '!searchparse', '!searchreplace'
  126. }))
  127. -- Numbers.
  128. lex:add_rule('number', token(lexer.NUMBER, lexer.integer))
  129. -- Operators.
  130. lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%|&^~!<>')))
  131. -- Labels (4.3).
  132. lex:add_rule('label', token(lexer.LABEL, lexer.word * ':'))
  133. -- Identifiers.
  134. lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
  135. lexer.property['scintillua.comment'] = '#'
  136. return lex