php.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- ==========================================================================\
  3. |
  4. | To learn how to make your own language parser, please check the following
  5. | link:
  6. | https://npp-user-manual.org/docs/function-list/
  7. |
  8. \=========================================================================== -->
  9. <NotepadPlus>
  10. <functionList>
  11. <!-- ========================================================= [ PHP ] -->
  12. <!-- PHP - Personal Home Page / PHP Hypertext Preprocessor -->
  13. <parser
  14. displayName="PHP - Personal Home Page / PHP Hypertext Preprocessor"
  15. id ="php_syntax"
  16. commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  17. (?s:\x2F\x2A.*?\x2A\x2F) # Multi Line Comment x2F -> '/' x2A -> '*'
  18. | (?m-s:(?:\x23|\x2F{2}).*$) # Single Line Comment 1 # and 2 //
  19. # | (?s:\x22(?:[^\x22\x24\x5C]|\x5C.)*\x22) # String Literal - Double Quoted
  20. | (?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22) # String Literal - Double Quoted
  21. | (?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27) # String Literal - Single Quoted
  22. | (?: # Here Document
  23. \x3C{3}(?'HDID'[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*)[^\r\n]*(?:\r?\n|\n?\r)
  24. (?s:.*?)
  25. (?:\r?\n|\n?\r)\k'HDID' # close with exactly the same identifier, in the first column
  26. )
  27. | (?: # Now Document
  28. \x3C{3}\x27(?'NDID'[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*)\x27[^\r\n]*(?:\r?\n|\n?\r)
  29. (?s:.*?)
  30. (?:\r?\n|\n?\r)\k'NDID' # close with exactly the same identifier, in the first column
  31. )
  32. "
  33. >
  34. <classRange
  35. mainExpr ="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  36. (?(DEFINE) # definition of sub-routines
  37. (?'VALID_ID'
  38. \b(?!(?-i: # keywords (case-sensitive), not to be used as identifier
  39. a(?:bstract|nd|rray|s)
  40. | b(?:ool|reak)
  41. | c(?:a(?:llable|se|tch)|l(?:ass|one)|on(?:st|tinue))
  42. | d(?:e(?:clare|fault)|ie|o)
  43. | e(?:cho|lse(?:if)?|mpty|nd(?:declare|for(?:each)?|if|switch|while)|val|x(?:it|tends))
  44. | f(?:alse|loat|inal|or(?:each)?|unction)
  45. | g(?:lobal|oto)
  46. | i(?:f|mplements|n(?:clude(?:_once)?|st(?:anceof|eadof)|t(?:erface)?)|sset)
  47. | list
  48. | mixed
  49. | n(?:amespace|ew|u(?:ll|meric))
  50. | o(?:r|bject)
  51. | p(?:r(?:i(?:nt|vate)|otected)|ublic)
  52. | re(?:quire(?:_once)?|turn)
  53. | s(?:t(?:atic|ring)|witch)
  54. | t(?:hrow|r(?:ait|ue|y))
  55. | u(?:nset|se)
  56. | var
  57. | while
  58. | xor
  59. | __(?:halt_compiler|(?:CLASS|DIR|F(?:ILE|UNCTION)|LINE|METHOD|NAMESPACE|TRAIT)__)
  60. )\b)
  61. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # valid character combination for identifiers
  62. )
  63. (?'INTERFACE_LIST'
  64. \s+(?:\x5C|(?&amp;VALID_ID))+
  65. (?:
  66. \s*,
  67. \s*(?:\x5C|(?&amp;VALID_ID))+
  68. )*
  69. )
  70. )
  71. (?m-i) # ^ and $ match at line-breaks, case-sensitive
  72. ^\h* # optional leading white-space at start-of-line
  73. (?:
  74. (?:(?-i:abstract|final)\s+)? # optional class entry type
  75. (?-i:class)\s+
  76. \K # discard text matched so far
  77. (?&amp;VALID_ID) # identifier used as class name
  78. (?: # optional extends-from-class
  79. \s+(?-i:extends)
  80. \s+(?:\x5C|(?&amp;VALID_ID))+
  81. )?
  82. (?: # optional implements-class/interfaces
  83. \s+(?-i:implements)
  84. (?&amp;INTERFACE_LIST)
  85. )?
  86. |
  87. (?-i:interface)\s+
  88. \K # discard text matched so far
  89. (?&amp;VALID_ID) # identifier used as interface name
  90. (?: # optional extends-from list
  91. \s+(?-i:extends)
  92. (?&amp;INTERFACE_LIST)
  93. )?
  94. |
  95. (?-i:trait)\s+
  96. \K # discard text matched so far
  97. (?&amp;VALID_ID) # identifier used as trait name
  98. )
  99. \s*\{
  100. "
  101. openSymbole ="\{"
  102. closeSymbole="\}"
  103. >
  104. <className>
  105. <nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*" />
  106. </className>
  107. <function
  108. mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  109. (?m-i) # ^ and $ match at line-breaks, case-sensitive
  110. ^\h* # optional leading white-space at start-of-line
  111. (?:(?-i: # field modifiers
  112. p(?:r(?:ivate|otected)|ublic) # - access modifiers
  113. | abstract|final|static # - ...
  114. )\s+)* # require a white-space separator
  115. (?-i:function)\s+
  116. \K # discard text matched so far
  117. (?:\x26\s*)? # optionally a reference
  118. (?'VALID_ID' # valid identifier, use as subroutine
  119. \b(?!(?-i: # keywords (case-sensitive), not to be used as identifier
  120. a(?:bstract|nd|rray|s)
  121. | b(?:ool|reak)
  122. | c(?:a(?:llable|se|tch)|l(?:ass|one)|on(?:st|tinue))
  123. | d(?:e(?:clare|fault)|ie|o)
  124. | e(?:cho|lse(?:if)?|mpty|nd(?:declare|for(?:each)?|if|switch|while)|val|x(?:it|tends))
  125. | f(?:alse|loat|inal|or(?:each)?|unction)
  126. | g(?:lobal|oto)
  127. | i(?:f|mplements|n(?:clude(?:_once)?|st(?:anceof|eadof)|t(?:erface)?)|sset)
  128. | list
  129. | mixed
  130. | n(?:amespace|ew|u(?:ll|meric))
  131. | o(?:r|bject)
  132. | p(?:r(?:i(?:nt|vate)|otected)|ublic)
  133. | re(?:quire(?:_once)?|turn)
  134. | s(?:t(?:atic|ring)|witch)
  135. | t(?:hrow|r(?:ait|ue|y))
  136. | u(?:nset|se)
  137. | var
  138. | while
  139. | xor
  140. | __(?:halt_compiler|(?:CLASS|DIR|F(?:ILE|UNCTION)|LINE|METHOD|NAMESPACE|TRAIT)__)
  141. )\b)
  142. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # valid character combination for identifiers
  143. ) # identifier used as method name
  144. \s*\( # start of function parameters
  145. (?:[^{;]*(?:\{|;)) # start of function body or abstract function without body
  146. "
  147. >
  148. <functionName>
  149. <funcNameExpr expr="(?:\x26\s*)?[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*\s*\((?:[^/{]|/(?![*/]))*" />
  150. <!-- comment out the following node to display the method with parameters -->
  151. <funcNameExpr expr="(?:\x26\s*)?[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*" />
  152. </functionName>
  153. </function>
  154. </classRange>
  155. <function
  156. mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
  157. (?m-i) # ^ and $ match at line-breaks, case-sensitive
  158. ^\h* # optional leading white-space at start-of-line
  159. (?-i:function)\s+
  160. \K # discard text matched so far
  161. (?:\x26\s*)? # optionally a reference
  162. (?'VALID_ID' # valid identifier, use as subroutine
  163. \b(?!(?-i: # keywords (case-sensitive), not to be used as identifier
  164. a(?:bstract|nd|rray|s)
  165. | b(?:ool|reak)
  166. | c(?:a(?:llable|se|tch)|l(?:ass|one)|on(?:st|tinue))
  167. | d(?:e(?:clare|fault)|ie|o)
  168. | e(?:cho|lse(?:if)?|mpty|nd(?:declare|for(?:each)?|if|switch|while)|val|x(?:it|tends))
  169. | f(?:alse|loat|inal|or(?:each)?|unction)
  170. | g(?:lobal|oto)
  171. | i(?:f|mplements|n(?:clude(?:_once)?|st(?:anceof|eadof)|t(?:erface)?)|sset)
  172. | list
  173. | mixed
  174. | n(?:amespace|ew|u(?:ll|meric))
  175. | o(?:r|bject)
  176. | p(?:r(?:i(?:nt|vate)|otected)|ublic)
  177. | re(?:quire(?:_once)?|turn)
  178. | s(?:t(?:atic|ring)|witch)
  179. | t(?:hrow|r(?:ait|ue|y))
  180. | u(?:nset|se)
  181. | var
  182. | while
  183. | xor
  184. | __(?:halt_compiler|(?:CLASS|DIR|F(?:ILE|UNCTION)|LINE|METHOD|NAMESPACE|TRAIT)__)
  185. )\b)
  186. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # valid character combination for identifiers
  187. ) # identifier used as function name
  188. \s*\( # start of function parameters
  189. [^{]*\{ # start of function body
  190. "
  191. >
  192. <functionName>
  193. <nameExpr expr="(?:\x26\s*)?[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*\s*\((?:[^/{]|/(?![*/]))*" />
  194. <!-- comment out the following node to display the function with its parameters -->
  195. <!-- <nameExpr expr="(?:\x26\s*)?[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*" /> -->
  196. </functionName>
  197. </function>
  198. </parser>
  199. </functionList>
  200. </NotepadPlus>