aya/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c++.xml

326 行
10 KiB
XML

<lexer>
<config>
<name>C++</name>
<alias>cpp</alias>
<alias>c++</alias>
<filename>*.cpp</filename>
<filename>*.hpp</filename>
<filename>*.c++</filename>
<filename>*.h++</filename>
<filename>*.cc</filename>
<filename>*.hh</filename>
<filename>*.cxx</filename>
<filename>*.hxx</filename>
<filename>*.C</filename>
<filename>*.H</filename>
<filename>*.cp</filename>
<filename>*.CPP</filename>
<mime_type>text/x-c++hdr</mime_type>
<mime_type>text/x-c++src</mime_type>
<ensure_nl>true</ensure_nl>
</config>
<rules>
<state name="classname">
<rule pattern="(\[\[.+\]\])(\s*)">
<bygroups>
<token type="NameAttribute"/>
<token type="Text"/>
</bygroups>
</rule>
<rule pattern="[a-zA-Z_]\w*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule pattern="\s*(?=[&gt;{])">
<token type="Text"/>
<pop depth="1"/>
</rule>
</state>
<state name="whitespace">
<rule pattern="^#if\s+0">
<token type="CommentPreproc"/>
<push state="if0"/>
</rule>
<rule pattern="^#">
<token type="CommentPreproc"/>
<push state="macro"/>
</rule>
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)">
<bygroups>
<usingself state="root"/>
<token type="CommentPreproc"/>
</bygroups>
<push state="if0"/>
</rule>
<rule pattern="^(\s*(?:/[*].*?[*]/\s*)?)(#)">
<bygroups>
<usingself state="root"/>
<token type="CommentPreproc"/>
</bygroups>
<push state="macro"/>
</rule>
<rule pattern="\n">
<token type="Text"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="\\\n">
<token type="Text"/>
</rule>
<rule pattern="//(\n|[\w\W]*?[^\\]\n)">
<token type="CommentSingle"/>
</rule>
<rule pattern="/(\\\n)?[*][\w\W]*?[*](\\\n)?/">
<token type="CommentMultiline"/>
</rule>
<rule pattern="/(\\\n)?[*][\w\W]*">
<token type="CommentMultiline"/>
</rule>
</state>
<state name="macro">
<rule pattern="(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)">
<bygroups>
<token type="CommentPreproc"/>
<token type="Text"/>
<token type="CommentPreprocFile"/>
</bygroups>
</rule>
<rule pattern="[^/\n]+">
<token type="CommentPreproc"/>
</rule>
<rule pattern="/[*](.|\n)*?[*]/">
<token type="CommentMultiline"/>
</rule>
<rule pattern="//.*?\n">
<token type="CommentSingle"/>
<pop depth="1"/>
</rule>
<rule pattern="/">
<token type="CommentPreproc"/>
</rule>
<rule pattern="(?&lt;=\\)\n">
<token type="CommentPreproc"/>
</rule>
<rule pattern="\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
</rule>
</state>
<state name="statements">
<rule pattern="(reinterpret_cast|static_assert|thread_local|dynamic_cast|static_cast|const_cast|co_return|protected|namespace|consteval|constexpr|typename|co_await|co_yield|operator|restrict|explicit|template|override|noexcept|requires|decltype|alignof|private|alignas|virtual|mutable|nullptr|concept|export|friend|typeid|throws|public|delete|final|throw|catch|using|this|new|try)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(enum)\b(\s+)(class)\b(\s*)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
<push state="classname"/>
</rule>
<rule pattern="(class|struct|enum|union)\b(\s*)">
<bygroups>
<token type="Keyword"/>
<token type="Text"/>
</bygroups>
<push state="classname"/>
</rule>
<rule pattern="\[\[.+\]\]">
<token type="NameAttribute"/>
</rule>
<rule pattern="(R)(&#34;)([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralString"/>
<token type="LiteralStringDelimiter"/>
<token type="LiteralString"/>
</bygroups>
</rule>
<rule pattern="(u8|u|U)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
</bygroups>
<push state="string"/>
</rule>
<rule pattern="(L?)(&#34;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralString"/>
</bygroups>
<push state="string"/>
</rule>
<rule pattern="(L?)(&#39;)(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\&#39;\n])(&#39;)">
<bygroups>
<token type="LiteralStringAffix"/>
<token type="LiteralStringChar"/>
<token type="LiteralStringChar"/>
<token type="LiteralStringChar"/>
</bygroups>
</rule>
<rule pattern="(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="(\d+\.\d*|\.\d+|\d+[fF])[fF]?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="0[xX]([0-9A-Fa-f](&#39;?[0-9A-Fa-f]+)*)[LlUu]*">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="0(&#39;?[0-7]+)+[LlUu]*">
<token type="LiteralNumberOct"/>
</rule>
<rule pattern="0[Bb][01](&#39;?[01]+)*[LlUu]*">
<token type="LiteralNumberBin"/>
</rule>
<rule pattern="[0-9](&#39;?[0-9]+)*[LlUu]*">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="\*/">
<token type="Error"/>
</rule>
<rule pattern="[~!%^&amp;*+=|?:&lt;&gt;/-]">
<token type="Operator"/>
</rule>
<rule pattern="[()\[\],.]">
<token type="Punctuation"/>
</rule>
<rule pattern="(restricted|volatile|continue|register|default|typedef|struct|extern|switch|sizeof|static|return|union|while|const|break|goto|enum|else|case|auto|for|asm|if|do)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(bool|int|long|float|short|double|char((8|16|32)_t)?|wchar_t|unsigned|signed|void|u?int(_fast|_least|)(8|16|32|64)_t)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="(typename|__inline|restrict|_inline|thread|inline|naked)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(__m(128i|128d|128|64))\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="__(forceinline|identifier|unaligned|declspec|fastcall|stdcall|finally|except|assume|int32|cdecl|int64|based|leave|int16|raise|noop|int8|w64|try|asm)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(true|false|NULL)\b">
<token type="NameBuiltin"/>
</rule>
<rule pattern="([a-zA-Z_]\w*)(\s*)(:)(?!:)">
<bygroups>
<token type="NameLabel"/>
<token type="Text"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="[a-zA-Z_]\w*">
<token type="Name"/>
</rule>
</state>
<state name="function">
<rule>
<include state="whitespace"/>
</rule>
<rule>
<include state="statements"/>
</rule>
<rule pattern=";">
<token type="Punctuation"/>
</rule>
<rule pattern="\{">
<token type="Punctuation"/>
<push/>
</rule>
<rule pattern="\}">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
</state>
<state name="string">
<rule pattern="&#34;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule pattern="\\([\\abfnrtv&#34;\&#39;]|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="[^\\&#34;\n]+">
<token type="LiteralString"/>
</rule>
<rule pattern="\\\n">
<token type="LiteralString"/>
</rule>
<rule pattern="\\">
<token type="LiteralString"/>
</rule>
</state>
<state name="if0">
<rule pattern="^\s*#if.*?(?&lt;!\\)\n">
<token type="CommentPreproc"/>
<push/>
</rule>
<rule pattern="^\s*#el(?:se|if).*\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
</rule>
<rule pattern="^\s*#endif.*?(?&lt;!\\)\n">
<token type="CommentPreproc"/>
<pop depth="1"/>
</rule>
<rule pattern=".*?\n">
<token type="Comment"/>
</rule>
</state>
<state name="root">
<rule>
<include state="whitespace"/>
</rule>
<rule pattern="((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)">
<bygroups>
<usingself state="root"/>
<token type="NameFunction"/>
<usingself state="root"/>
<usingself state="root"/>
<token type="Punctuation"/>
</bygroups>
<push state="function"/>
</rule>
<rule pattern="((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)">
<bygroups>
<usingself state="root"/>
<token type="NameFunction"/>
<usingself state="root"/>
<usingself state="root"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule>
<push state="statement"/>
</rule>
<rule pattern="__(multiple_inheritance|virtual_inheritance|single_inheritance|interface|uuidof|super|event)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="__(offload|blockingoffload|outer)\b">
<token type="KeywordPseudo"/>
</rule>
</state>
<state name="statement">
<rule>
<include state="whitespace"/>
</rule>
<rule>
<include state="statements"/>
</rule>
<rule pattern="[{]">
<token type="Punctuation"/>
<push state="root"/>
</rule>
<rule pattern="[;}]">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
</state>
</rules>
</lexer>