| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <?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>
|