#include <eepp/ui/doc/languages/webassemblyinterfacetypes.hpp>
#include <eepp/ui/doc/syntaxdefinitionmanager.hpp>

namespace EE { namespace UI { namespace Doc { namespace Language {

SyntaxDefinition& addWebAssemblyInterfaceTypes() {

	return SyntaxDefinitionManager::instance()
		->add(

			{ "WebAssembly Interface Types",
			  { "%.wit$" },
			  {
				  { { "include", "#comment" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#feature-gate" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#package" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#toplevel-use" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#world" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#interface" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#whitespace" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  },
			  {

			  },
			  "",
			  {}

			} )
		.addRepositories( {

			{ "primitive",
			  {
				  { { "include", "#numeric" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#boolean" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#string" }, "normal", "", SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "doc-comment",
			  {
				  { { "^\\s*///", "$" },
					{ "comment" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#markdown" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "numeric",
			  {
				  { { "\\b(u8|u16|u32|u64|s8|s16|s32|s64|float32|float64)\\b" },
					"type",
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "parameter-list",
			  {
				  { { "(\\()", "(\\))" },
					{ "normal", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#named-type-list" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "named-type-list",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b\\s*(\\:)",
					  "((\\,)|(?=\\))|(?=\\n))" },
					{ "type", "parameter", "type", "type", "type", "type", "operator" },
					{ "type", "type", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "interface",
			  {
				  { { "^\\s*\\b(default\\s+)?(interface)\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z]["
					  "0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "keyword", "type", "type", "type", "type", "type",
					  "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#feature-gate" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#interface-items" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "option",
			  {
				  { { "\\b(option)\\b(\\<)", "(\\>)" },
					{ "normal", "type", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "container",
			  {
				  { { "include", "#tuple" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#list" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#option" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#result" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#handle" }, "normal", "", SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "handle",
			  {
				  { { "\\b(borrow)\\b(\\<)\\s*%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-"
					  "])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\>)" },
					{ "normal", "type", "operator", "type", "normal", "normal", "normal", "normal",
					  "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "function-definition",
			  {
				  { { "\\b(static\\s+)?(func)\\b", "((?<=\\n)|(?=\\}))" },
					{ "function", "keyword", "keyword" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#parameter-list" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#result-list" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "block-comments",
			  {
				  { { "/\\*\\*/" }, "comment", "", SyntaxPatternMatchType::RegEx },
				  { { "/\\*\\*", "\\*/" },
					{ "comment" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#block-comments" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#markdown" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },
				  { { "/\\*(?!\\*)", "\\*/" },
					{ "comment" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#block-comments" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "line-comment",
			  {
				  { { "\\s*//.*" }, "comment", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "list",
			  {
				  { { "\\b(list)\\b(\\<)", "(\\>)" },
					{ "normal", "type", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "\\s*(,)\\s*" },
						  { "normal", "operator" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "\\b([0-9]+)\\b" },
						  { "normal", "number" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "flags",
			  {
				  { { "\\b(flags)\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z]["
					  "0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "type", "type", "type", "type", "type", "operator" },
					{ "type", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#flags-fields" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "package",
			  {
				  { { "^(package)\\s+([^\\s]+)\\s*" },
					{ "normal", "keyword", "string" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "identifier",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b" },
					"type",
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "boolean",
			  {
				  { { "\\b(bool)\\b" }, "type", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "toplevel-use",
			  {
				  { { "^(use)\\s+([^\\s]+)(\\s+(as)\\s+([^\\s]+))?\\s*" },
					{ "normal", "keyword", "normal", "normal", "keyword", "type" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "comment",
			  {
				  { { "include", "#block-comments" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#doc-comment" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#line-comment" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "feature-gate",
			  {
				  { { "(@unstable)(\\()", "(\\))" },
					{ "normal", "keyword", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#feature-gate-content" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(@since)(\\()", "(\\))" },
					{ "normal", "keyword", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#feature-gate-content" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(@deprecated)(\\()", "(\\))" },
					{ "normal", "keyword", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#feature-gate-content" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "interface-items",
			  {
				  { { "include", "#feature-gate" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#typedef-item" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#use" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#function" }, "normal", "", SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "operator",
			  {
				  { { "\\=" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\," }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\:" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\;" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\(" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\)" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\{" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\}" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\<" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\>" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\*" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "\\-\\>" }, "operator", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "variant",
			  {
				  { { "\\b(variant)\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-"
					  "z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "type", "normal", "normal", "normal", "normal",
					  "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#variant-cases" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#enum-cases" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "resource",
			  {
				  { { "\\b(resource)\\b\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])("
					  "[a-z][0-9a-z]*|[A-Z][0-9A-Z]*))*)",
					  "((?<=\\n)|(?=\\}))" },
					{ "normal", "keyword", "type" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#resource-methods" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "enum",
			  {
				  { { "\\b(enum)\\b\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-"
					  "z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "type", "type", "type", "type", "type", "operator" },
					{ "type", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#enum-cases" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "feature-gate-content",
			  {
				  { { "include", "#comment" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "\\b(feature|version)\\s*(=)\\s*([^\\s,)]+|\"[^\"]*\")" },
					{ "parameter", "parameter", "operator", "string" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "," }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "include", "#whitespace" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "resource-methods",
			  {
				  { { "(\\{)", "(\\})" },
					{ "normal", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#feature-gate" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "\\b(constructor)\\b", "((?<=\\n)|(?=\\}))" },
						  { "type", "keyword", "operator" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#comment" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#parameter-list" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#whitespace" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },

						  },
						  SyntaxPattern::IsApplyEndPatternLast },
						{ { "include", "#function" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "enum-cases",
			  {
				  { { "include", "#comment" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(\\,)" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "include", "#whitespace" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "flags-fields",
			  {
				  { { "include", "#comment" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(\\,)" }, "operator", "", SyntaxPatternMatchType::RegEx },
				  { { "include", "#whitespace" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "record-fields",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b\\s*(\\:)",
					  "((\\,)|(?=\\})|(?=\\n))" },
					{ "normal", "normal", "normal", "normal", "normal", "normal", "operator" },
					{ "normal", "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "markdown",
			  {
				  { { "\\G\\s*(#+.*)$" },
					{ "normal", "keyword" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\G\\s*((\\>)\\s+)+" },
					{ "normal", "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\G\\s*(\\-)\\s+" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\G\\s*(([0-9]+\\.)\\s+)" },
					{ "normal", "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(`.*?`)" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\b(__.*?__)" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\b(_.*?_)" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(\\*\\*.*?\\*\\*)" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(\\*.*?\\*)" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "result-base",
			  {
				  { { "\\b(result)\\b" }, "type", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "types",
			  {
				  { { "include", "#primitive" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#container" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#result-base" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#identifier" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "result-list",
			  {
				  { { "(\\-\\>)", "((?<=\\n)|(?=\\}))" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#parameter-list" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "string",
			  {
				  { { "\\b(string|char)\\b" }, "type", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "result",
			  {
				  { { "\\b(result)\\b(\\<)", "(\\>)" },
					{ "normal", "type", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "(?<!\\w)(\\_)(?!\\w)" }, "normal", "", SyntaxPatternMatchType::RegEx },
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "(?<!result)\\s*(\\,)" },
						  "operator",
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "tuple",
			  {
				  { { "\\b(tuple)\\b(\\<)", "(\\>)" },
					{ "normal", "type", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "(\\,)" }, "operator", "", SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "type-definition",
			  {
				  { { "\\b(type)\\b\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-"
					  "z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\=)",
					  "(?<=\\n)" },
					{ "type", "keyword", "type", "type", "type", "type", "type", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "whitespace",
			  {
				  { { "\\s+" }, "normal", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "use",
			  {
				  { { "\\b(use)\\b\\s+([^\\s]+)(\\.)(\\{)", "(\\})" },
					{ "normal", "keyword", "string", "operator", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-"
							"z]*|[A-Z][0-9A-Z]*))*)\\b" },
						  "type",
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "(\\,)" }, "operator", "", SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "extern",
			  {
				  { { "\\b(interface)\\b\\s*(\\{)", "(\\})" },
					{ "normal", "keyword", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#interface-items" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },
				  { { "include", "#function-definition" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#use-path" }, "normal", "", SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "use-path",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "(\\@)((0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*["
					  "a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?("
					  "?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)" },
					{ "normal", "operator", "number" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\." }, "operator", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "variant-cases",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\b\\s*(\\()",
					  "(\\))\\s*(\\,)?" },
					{ "normal", "normal", "normal", "normal", "normal", "normal", "operator" },
					{ "normal", "operator", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#types" },
						  { "type" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "record",
			  {
				  { { "\\b(record)\\b\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])(["
					  "a-z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "type", "type", "type", "type", "type",
					  "operator" },
					{ "type", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#record-fields" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "function",
			  {
				  { { "\\b%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*)(([\\-])([a-z][0-9a-z]*|["
					  "A-Z][0-9A-Z]*))*)\\s*(\\:)",
					  "((?<=\\n)|(?=\\}))" },
					{ "normal", "function", "function", "normal", "function", "function",
					  "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#feature-gate" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#function-definition" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "world",
			  {
				  { { "^\\s*\\b(default\\s+)?(world)\\s+%?((?<![\\-\\w])([a-z][0-9a-z]*|[A-Z][0-9A-"
					  "Z]*)(([\\-])([a-z][0-9a-z]*|[A-Z][0-9A-Z]*))*)\\s*(\\{)",
					  "(\\})" },
					{ "normal", "keyword", "keyword", "type", "normal", "normal", "normal",
					  "normal", "operator" },
					{ "normal", "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#feature-gate" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "\\b(export)\\b\\s+([^\\s]+)", "((?<=\\n)|(?=\\}))" },
						  { "normal", "keyword", "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#extern" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#whitespace" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },

						  },
						  SyntaxPattern::IsApplyEndPatternLast },
						{ { "\\b(import)\\s+([^\\s]+)", "((?<=\\n)|(?=\\}))" },
						  { "normal", "keyword", "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#extern" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#whitespace" },
								"normal",
								"",
								SyntaxPatternMatchType::LuaPattern },

						  },
						  SyntaxPattern::IsApplyEndPatternLast },
						{ { "\\b(include)\\s+([^\\s]+)\\s*", "(?<=\\n)" },
						  { "normal", "keyword", "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "\\b(with)\\b\\s+(\\{)", "(\\})" },
								{ "normal", "keyword", "operator" },
								{ "normal", "operator" },
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#comment" },
									  "normal",
									  "",
									  SyntaxPatternMatchType::LuaPattern },
									{ { "([^\\s]+)\\s+(as)\\s+([^\\s\\,]+)" },
									  { "normal", "normal", "keyword", "type" },
									  {},
									  "",
									  SyntaxPatternMatchType::RegEx },
									{ { "(\\,)" }, "operator", "", SyntaxPatternMatchType::RegEx },
									{ { "include", "#whitespace" },
									  "normal",
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								},
								SyntaxPattern::IsApplyEndPatternLast },

						  },
						  SyntaxPattern::IsApplyEndPatternLast },
						{ { "include", "#use" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#typedef-item" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#whitespace" },
						  "normal",
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					},
					SyntaxPattern::IsApplyEndPatternLast },

			  } },
			{ "typedef-item",
			  {
				  { { "include", "#feature-gate" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#resource" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#variant" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#record" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#flags" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#enum" }, "normal", "", SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#type-definition" },
					"normal",
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
		} );
}

}}}} // namespace EE::UI::Doc::Language
