c.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. <!-- =========================================================== [ C ] -->
  12. <parser
  13. displayName="C"
  14. id ="c_function"
  15. commentExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
  16. (?s:\x2F\x2A.*?\x2A\x2F) # Multi Line Comment
  17. | (?m-s:\x2F{2}.*$) # Single Line Comment
  18. | (?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22) # String Literal - Double Quoted
  19. | (?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27) # String Literal - Single Quoted
  20. "
  21. >
  22. <function
  23. mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
  24. (?: # Declaration specifiers
  25. \b
  26. (?:
  27. (?-i:auto|register|static|extern|typedef) # Storage class specifier
  28. | (?: # Type specifier
  29. (?-i:void|char|short|int|long|float|double|(?:un)?signed)
  30. | (?-i:struct|union|enum)
  31. \s+
  32. (?&amp;VALID_ID) # Struct, Union or Enum Specifier (simplified)
  33. | (?&amp;VALID_ID) # Type-definition name
  34. )
  35. | (?'TYPE_QUALIFIER'(?-i:const|volatile))
  36. )
  37. \b
  38. \s*
  39. )*
  40. (?'DECLARATOR'
  41. (?'POINTER'
  42. \*
  43. \s*
  44. (?:
  45. \b(?&amp;TYPE_QUALIFIER)\b
  46. \s*
  47. )*
  48. (?:(?&amp;POINTER))? # Boost::Regex 1.58-1.59 do not correctly handle quantifiers on subroutine calls
  49. )?
  50. (?: # 'DIRECT_DECLARATOR'
  51. \s*
  52. (?'VALID_ID' # valid identifier, use as subroutine
  53. \b(?!(?-i:
  54. auto
  55. | break
  56. | c(?:ase|har|on(?:st|ntinue))
  57. | d(?:efault|o(?:uble)?)
  58. | e(?:lse|num|xtern)
  59. | f(?:loat|or)
  60. | goto
  61. | i(?:f|n(?:t|line))
  62. | long
  63. | while
  64. | re(?:gister|strict|turn)
  65. | s(?:hort|i(?:gned|zeof)|t(?:atic|ruct)|witch)
  66. | typedef
  67. | un(?:ion|signed)
  68. | vo(?:id|latile)
  69. | _(?:
  70. A(?:lignas|lignof|tomic)
  71. | Bool
  72. | Complex
  73. | Generic
  74. | Imaginary
  75. | Noreturn
  76. | Static_assert
  77. | Thread_local
  78. )
  79. )\b) # keywords, not to be used as identifier
  80. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # valid character combination for identifiers
  81. )
  82. | \s*\(
  83. (?&amp;DECLARATOR)
  84. \)
  85. | \s*(?&amp;VALID_ID)
  86. \s*\[
  87. [^[\];{]*?
  88. \]
  89. | \s*(?&amp;VALID_ID)
  90. \s*\(
  91. [^();{]*?
  92. \)
  93. )
  94. \s*
  95. )
  96. (?=\{) # start of function body
  97. "
  98. >
  99. <functionName>
  100. <nameExpr expr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
  101. [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*
  102. \s*\( # start of parameters
  103. (?s:.*?) # whatever, until...
  104. \) # end of parameters
  105. " />
  106. <!-- comment out the following node to display the method with its parameters -->
  107. <!-- <nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*" /> -->
  108. </functionName>
  109. </function>
  110. </parser>
  111. </functionList>
  112. </NotepadPlus>