lua.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- Copied from https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4563 -->
  3. <NotepadPlus>
  4. <functionList>
  5. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. | Based on:
  7. | http://stackoverflow.com/questions/19246077/how-to-add-lua-functions-to-the-notepad-functionlist-xml
  8. |
  9. | Note(s):
  10. | 1) Multi Line Comment `Level` is supported by Lua 5.1 and above;
  11. | 2) Nested table view not supported;
  12. \-->
  13. <parser
  14. displayName="Lua w/ Class"
  15. id ="lua_syntax"
  16. commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  17. (?s: # Multi Line Comment (MLC)
  18. (?&lt;!-) # - no preceeding dash, otherwise start of SLC
  19. -{2}\x5B(?'MLCLvl'=*)\x5B.*?\x5D\k'MLCLvl'\x5D
  20. )
  21. | (?m-s:-{2}(?!\x5B=*\x5B).*$) # Single Line Comment (SLC)
  22. | (?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22) # String Literal - Double Quoted (SLDQ) / Normal String
  23. | (?s: # String Literal - Multi Line (SLML) / Long String
  24. (?&lt;!-{2}) # - no preceeding double dash, otherwise start of MLC or SLC
  25. \x5B(?'SLMLLvl'=*)\x5B(?:[^\x5C\x5D]|\x5C.)*\x5D\k'SLMLLvl'\x5D
  26. )
  27. | (?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27) # String Literal - Single Quoted (SLSQ) / Char String
  28. "
  29. >
  30. <classRange
  31. mainExpr ="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  32. [.\w]+
  33. \s*=
  34. \s*\{
  35. "
  36. openSymbole ="\{"
  37. closeSymbole="\}"
  38. >
  39. <className>
  40. <nameExpr expr="[.\w]+" />
  41. </className>
  42. <function
  43. mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  44. [.\w]+
  45. \s*=
  46. \s*(?'QT'[\x22\x27]?)\w+\k'QT'
  47. "
  48. >
  49. <functionName>
  50. <funcNameExpr expr=".*" />
  51. </functionName>
  52. </function>
  53. </classRange>
  54. <function
  55. mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  56. (?m-i) # ^ and $ match at line-breaks, case-sensitive
  57. (?(DEFINE) # definition of sub-routine(s)
  58. (?'VALID_ID' # Valid Identifier sub-routine
  59. \b(?!(?-i: # - keywords (case-sensitive), not to be used as identifier
  60. and
  61. | break
  62. | do
  63. | e(?:lse(?:if)?|nd)
  64. | f(?:alse|or|unction)
  65. | goto
  66. | i[fn]
  67. | local
  68. | n(?:il|ot)
  69. | or
  70. | re(?:peat|turn)
  71. | t(?:hen|rue)
  72. | until
  73. | while
  74. )\b)
  75. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # - valid character combination for identifiers
  76. )
  77. )
  78. (?m) # ^ and $ match at line-breaks
  79. (?:
  80. ^\h* # optional leading white-space at start-of-line
  81. (?:local\s+)?
  82. function\s+
  83. \K # discard text matched so far
  84. (?&amp;VALID_ID)
  85. (?:\s*\.\s*(?&amp;VALID_ID))*
  86. (?:\s*:\s*(?&amp;VALID_ID))?
  87. |
  88. (?&amp;VALID_ID)
  89. (?:\s*\.\s*(?&amp;VALID_ID))*
  90. \s*=
  91. \s*function
  92. )
  93. \s*\( # start-of-parameter-list indicator
  94. [^)]* # optional parameters
  95. \) # end-of-parameter-list indicator
  96. "
  97. >
  98. <functionName>
  99. <nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*(?=\s*[(=])" />
  100. </functionName>
  101. <className>
  102. <nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*(?:\s*\.\s*[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*)*(?=\s*[.:])" />
  103. </className>
  104. </function>
  105. </parser>
  106. </functionList>
  107. </NotepadPlus>