tartrazine/lexers/protocol_buffer.xml

119 lines
3.3 KiB
XML
Raw Normal View History

2024-08-02 20:03:49 +00:00
<lexer>
<config>
<name>Protocol Buffer</name>
<alias>protobuf</alias>
<alias>proto</alias>
<filename>*.proto</filename>
</config>
<rules>
<state name="package">
<rule pattern="[a-zA-Z_]\w*">
<token type="NameNamespace"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="message">
<rule pattern="[a-zA-Z_]\w*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="type">
<rule pattern="[a-zA-Z_]\w*">
<token type="Name"/>
<pop depth="1"/>
</rule>
<rule>
<pop depth="1"/>
</rule>
</state>
<state name="root">
<rule pattern="[ \t]+">
<token type="Text"/>
</rule>
<rule pattern="[,;{}\[\]()&lt;&gt;]">
<token type="Punctuation"/>
</rule>
<rule pattern="/(\\\n)?/(\n|(.|\n)*?[^\\]\n)">
<token type="CommentSingle"/>
</rule>
<rule pattern="/(\\\n)?\*(.|\n)*?\*(\\\n)?/">
<token type="CommentMultiline"/>
</rule>
<rule pattern="\b(extensions|required|repeated|optional|returns|default|option|packed|import|ctype|oneof|max|rpc|to)\b">
<token type="Keyword"/>
</rule>
<rule pattern="(sfixed32|sfixed64|fixed32|fixed64|sint32|sint64|double|string|uint32|uint64|int32|float|int64|bytes|bool)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="(true|false)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="(package)(\s+)">
<bygroups>
<token type="KeywordNamespace"/>
<token type="Text"/>
</bygroups>
<push state="package"/>
</rule>
<rule pattern="(message|extend)(\s+)">
<bygroups>
<token type="KeywordDeclaration"/>
<token type="Text"/>
</bygroups>
<push state="message"/>
</rule>
<rule pattern="(enum|group|service)(\s+)">
<bygroups>
<token type="KeywordDeclaration"/>
<token type="Text"/>
</bygroups>
<push state="type"/>
</rule>
<rule pattern="\&#34;.*?\&#34;">
<token type="LiteralString"/>
</rule>
<rule pattern="\&#39;.*?\&#39;">
<token type="LiteralString"/>
</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="(\-?(inf|nan))\b">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="0x[0-9a-fA-F]+[LlUu]*">
<token type="LiteralNumberHex"/>
</rule>
<rule pattern="0[0-7]+[LlUu]*">
<token type="LiteralNumberOct"/>
</rule>
<rule pattern="\d+[LlUu]*">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="[+-=]">
<token type="Operator"/>
</rule>
<rule pattern="([a-zA-Z_][\w.]*)([ \t]*)(=)">
<bygroups>
<token type="Name"/>
<token type="Text"/>
<token type="Operator"/>
</bygroups>
</rule>
<rule pattern="[a-zA-Z_][\w.]*">
<token type="Name"/>
</rule>
</state>
</rules>
2024-08-26 23:18:28 +00:00
</lexer>