304 lines
18 KiB
XML
304 lines
18 KiB
XML
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||
|
<!-- ==========================================================================\
|
||
|
|
|
||
|
| To learn how to make your own language parser, please check the following
|
||
|
| link:
|
||
|
| https://npp-user-manual.org/docs/function-list/
|
||
|
|
|
||
|
\=========================================================================== -->
|
||
|
<NotepadPlus>
|
||
|
<functionList>
|
||
|
<!-- ========================================================= [ C++ ] -->
|
||
|
<parser
|
||
|
displayName="C++"
|
||
|
id ="cplusplus_syntax"
|
||
|
commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
|
||
|
>
|
||
|
<classRange
|
||
|
mainExpr="(?x) # use inline comments
|
||
|
^[\t\x20]* # leading whitespace
|
||
|
(template\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
(class|struct) # class/struct definition keyword
|
||
|
[\t\x20]+ # following whitespace
|
||
|
((\w+|\[\[[^\r\n]*\]\])[\t\x20]+)* # type attributes
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # class/struct identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
(\s*final\s*)? # final specifier
|
||
|
(
|
||
|
\s*:\s* # inheritance separator
|
||
|
((private|protected|public|virtual)\s+)* # visibility/virtual specifier
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # parent class/struct identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
(
|
||
|
\s*,\s* # multiple inheritance separator
|
||
|
((private|protected|public|virtual)\s+)* # visibility/virtual specifier
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # parent class/struct identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
)*
|
||
|
)?
|
||
|
\s* # trailing whitespace
|
||
|
\{ # class/struct body
|
||
|
"
|
||
|
openSymbole ="\{"
|
||
|
closeSymbole="\}"
|
||
|
>
|
||
|
<className>
|
||
|
<nameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(class|struct) # class/struct definition keyword
|
||
|
[\t\x20]+ # following whitespace
|
||
|
((\w+|\[\[[^\r\n]*\]\])[\t\x20]+)* # type attributes
|
||
|
(\w+\s*::\s*)* # namespace specifier
|
||
|
\w+ # class/struct identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
(\s*final\s*)? # final specifier
|
||
|
\s* # trailing whitespace
|
||
|
(:\s*\w+|\{) # inheritance separator | class/struct body
|
||
|
"
|
||
|
/>
|
||
|
<nameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(\w+\s*::\s*)* # namespace specifier
|
||
|
\w+ # class/struct identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
(\s*final\s*)? # final specifier
|
||
|
\s* # trailing whitespace
|
||
|
(:\s*\w+|\{) # inheritance separator | class/struct body
|
||
|
"
|
||
|
/>
|
||
|
<nameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(\w+\s*::\s*)* # namespace specifier
|
||
|
\w+ # class/struct identifier
|
||
|
"
|
||
|
/>
|
||
|
</className>
|
||
|
<function
|
||
|
mainExpr="(?x) # use inline comments
|
||
|
^[\t\x20]* # leading whitespace
|
||
|
(template\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
((consteval|constexpr|explicit|friend|inline|static|virtual)\s+)* # left function definition keywords
|
||
|
(
|
||
|
( # conversion operator definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
operator\s+ # operator keyword
|
||
|
((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
|
||
|
( # operator type definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # operator type identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
)*
|
||
|
(\s*(\*|\*\*|&)\s*)? # type pointer/reference
|
||
|
)
|
||
|
| (
|
||
|
((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
|
||
|
( # return type definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # return type identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
)
|
||
|
( # type pointer/reference
|
||
|
\s+
|
||
|
| (\*|\*\*|&)\s+
|
||
|
| \s+(\*|\*\*|&)
|
||
|
| \s+(\*|\*\*|&)\s+
|
||
|
)
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
(
|
||
|
( # function definition
|
||
|
(?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
| ( # operator definition
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
\s* # following whitespace
|
||
|
\(
|
||
|
[^\)\(]* # function parameters
|
||
|
(\([^\)\(]*\)[^\)\(]*)* # functors as parameter
|
||
|
\)
|
||
|
(\s*(const|final|noexcept|override|volatile)\s*)* # right function definition keywords
|
||
|
\s* # trailing whitespace
|
||
|
\{ # function body
|
||
|
"
|
||
|
>
|
||
|
<functionName>
|
||
|
<funcNameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\w\t\x20\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol | conversion operator
|
||
|
| (?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
\s* # following whitespace
|
||
|
\( # function parameters
|
||
|
"
|
||
|
/>
|
||
|
<funcNameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\w\t\x20\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol | conversion operator
|
||
|
| (?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
"
|
||
|
/>
|
||
|
</functionName>
|
||
|
</function>
|
||
|
</classRange>
|
||
|
<function
|
||
|
mainExpr="(?x) # use inline comments
|
||
|
^[\t\x20]* # leading whitespace
|
||
|
(template\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
((consteval|constexpr|explicit|friend|inline|static|virtual)\s+)* # left function definition keywords
|
||
|
(
|
||
|
( # conversion operator definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
operator\s+ # operator keyword
|
||
|
((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
|
||
|
( # operator type definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # operator type identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
)*
|
||
|
(\s*(\*|\*\*|&)\s*)? # type pointer/reference
|
||
|
)
|
||
|
| (
|
||
|
((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
|
||
|
( # return type definition
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
\w+ # return type identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
)
|
||
|
( # type pointer/reference
|
||
|
\s+
|
||
|
| (\*|\*\*|&)\s+
|
||
|
| \s+(\*|\*\*|&)
|
||
|
| \s+(\*|\*\*|&)\s+
|
||
|
)
|
||
|
(
|
||
|
\w+ # namespace identifier
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,<>]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
)*
|
||
|
(
|
||
|
( # function definition
|
||
|
(?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
| ( # operator definition
|
||
|
operator\(\) # operator parenthesis
|
||
|
| operator # operator keyword
|
||
|
[\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
\s* # following whitespace
|
||
|
\(
|
||
|
[^\)\(]* # function parameters
|
||
|
(\([^\)\(]*\)[^\)\(]*)* # functors as parameter
|
||
|
\)
|
||
|
(\s*(const|final|noexcept|override|volatile)\s*)* # right function definition keywords
|
||
|
\s* # trailing whitespace
|
||
|
\{ # function body
|
||
|
"
|
||
|
>
|
||
|
<functionName>
|
||
|
<nameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\w\t\x20\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol | conversion operator
|
||
|
| (?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
\s* # following whitespace
|
||
|
\( # function parameters
|
||
|
"
|
||
|
/>
|
||
|
<nameExpr
|
||
|
expr="(?x) # use inline comments
|
||
|
(
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\w\t\x20\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol | conversion operator
|
||
|
| (?!(if|while|for|switch)\s*\() # exclude block/loop definition
|
||
|
\w+ # function identifier
|
||
|
)
|
||
|
"
|
||
|
/>
|
||
|
</functionName>
|
||
|
<className>
|
||
|
<nameExpr expr="(?x) # use inline comments
|
||
|
\w+ # namespace identifier
|
||
|
(?=
|
||
|
(\s*<\s*[\w\t\x20\(\)\=\.:,]*\s*>\s*)? # template parameters
|
||
|
\s*::\s* # namespace separator
|
||
|
(
|
||
|
operator\(\) # parenthesis operator
|
||
|
| operator # operator keyword
|
||
|
[\w\t\x20\[\]\*\=\+\-\~\|\^%!,&<>]+ # operator symbol | conversion operator
|
||
|
| \w+ # function identifier
|
||
|
)
|
||
|
\( # function parameters
|
||
|
)
|
||
|
" />
|
||
|
</className>
|
||
|
</function>
|
||
|
</parser>
|
||
|
</functionList>
|
||
|
</NotepadPlus>
|