tartrazine/lexers/graphql.xml

89 lines
2.8 KiB
XML

<lexer>
<config>
<name>GraphQL</name>
<alias>graphql</alias>
<alias>graphqls</alias>
<alias>gql</alias>
<filename>*.graphql</filename>
<filename>*.graphqls</filename>
</config>
<rules>
<state name="root">
<rule pattern="(query|mutation|subscription|fragment|scalar|implements|interface|union|enum|input|type)">
<token type="KeywordDeclaration"/>
<push state="type"/>
</rule>
<rule pattern="(on|extend|schema|directive|\.\.\.)">
<token type="KeywordDeclaration"/>
</rule>
<rule pattern="(QUERY|MUTATION|SUBSCRIPTION|FIELD|FRAGMENT_DEFINITION|FRAGMENT_SPREAD|INLINE_FRAGMENT|SCHEMA|SCALAR|OBJECT|FIELD_DEFINITION|ARGUMENT_DEFINITION|INTERFACE|UNION|ENUM|ENUM_VALUE|INPUT_OBJECT|INPUT_FIELD_DEFINITION)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="[^\W\d]\w*">
<token type="NameProperty"/>
</rule>
<rule pattern="\@\w+">
<token type="NameDecorator"/>
</rule>
<rule pattern=":">
<token type="Punctuation"/>
<push state="type"/>
</rule>
<rule pattern="[\(\)\{\}\[\],!\|=]">
<token type="Punctuation"/>
</rule>
<rule pattern="\$\w+">
<token type="NameVariable"/>
</rule>
<rule pattern="\d+i">
<token type="LiteralNumber"/>
</rule>
<rule pattern="\d+\.\d*([Ee][-+]\d+)?i">
<token type="LiteralNumber"/>
</rule>
<rule pattern="\.\d+([Ee][-+]\d+)?i">
<token type="LiteralNumber"/>
</rule>
<rule pattern="\d+[Ee][-+]\d+i">
<token type="LiteralNumber"/>
</rule>
<rule pattern="\d+(\.\d+[eE][+\-]?\d+|\.\d*|[eE][+\-]?\d+)">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="\.\d+([eE][+\-]?\d+)?">
<token type="LiteralNumberFloat"/>
</rule>
<rule pattern="(0|[1-9][0-9]*)">
<token type="LiteralNumberInteger"/>
</rule>
<rule pattern="&#34;&#34;&#34;[\x00-\x7F]*?&#34;&#34;&#34;">
<token type="LiteralString"/>
</rule>
<rule pattern="&#34;(\\[&#34;\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|[^\\])&#34;">
<token type="LiteralStringChar"/>
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">
<token type="LiteralString"/>
</rule>
<rule pattern="&#34;(true|false|null)*&#34;">
<token type="Literal"/>
</rule>
<rule pattern="[\r\n\s]+">
<token type="TextWhitespace"/>
</rule>
<rule pattern="#[^\r\n]*">
<token type="Comment"/>
</rule>
</state>
<state name="type">
<rule pattern="[^\W\d]\w*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
<rule>
<include state="root"/>
</rule>
</state>
</rules>
</lexer>