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

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

SyntaxDefinition& addNix() {

	return SyntaxDefinitionManager::instance()
		->add(

			{ "Nix",
			  { "%.nix$" },
			  {
				  { { "include", "#expression" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  },
			  {

			  },
			  "",
			  {}

			} )
		.addRepositories( {

			{ "function-header-open-brace",
			  {
				  { { "\\{", "(?=\\})" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-contents" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-header-terminal-arg",
			  {
				  { { "(?=@)", "(?=\\:)" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\@", "(?=\\:)" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*)", "(?=\\:)" },
								{ "parameter" },
								{},
								"",
								SyntaxPatternMatchType::RegEx },
							  { { "include", "#others" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-header-close-brace-with-arg",
			  {
				  { { "\\}", "(?=\\:)" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-header-terminal-arg" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-for-sure",
			  {
				  { { "(?=(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*\\s*[:@]|\\{[^}]*\\}\\s*:|\\{[^#}\"'/"
					  "=]*[,\\?]))",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-definition" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-header-until-colon-with-arg",
			  {
				  { { "(?=\\{)", "(?=\\:)" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-header-open-brace" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#function-header-close-brace-with-arg" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attribute-bind",
			  {
				  { { "include", "#attribute-name" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#attribute-bind-from-equals" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "string",
			  {
				  { { "(?=\\'\\')", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\'\\'", "\\'\\'(?!\\$|\\'|\\\\.)" },
						  { "string" },
						  { "string" },
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "\\'\\'(\\$|\\'|\\\\.)" },
								"string",
								"",
								SyntaxPatternMatchType::RegEx },
							  { { "include", "#interpolation" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(?=\\\")", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#string-quoted" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "([a-zA-Z0-9\\.\\_\\-\\+]*(\\/[a-zA-Z0-9\\.\\_\\-\\+]+)+)",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "string" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(\\<[a-zA-Z0-9\\.\\_\\-\\+]+(\\/[a-zA-Z0-9\\.\\_\\-\\+]+)*\\>)",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "string" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "([a-zA-Z][a-zA-Z0-9\\+\\-\\.]*\\:[a-zA-Z0-9\\%\\/"
					  "\\?\\:\\@\\&\\=\\+\\$\\,\\-\\_\\.\\!\\~\\*\\']+)",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "string" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-definition",
			  {
				  { { "(?=.?)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-body-from-colon" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "(?=.?)", "(?=\\:)" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*)", "(?=\\:)" },
								{ "parameter" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "\\@", "(?=\\:)" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::RegEx,
									  {
										  { { "include", "#function-header-until-colon-no-arg" },
											{ "normal" },
											{},
											"",
											SyntaxPatternMatchType::LuaPattern },
										  { { "include", "#others" },
											{ "normal" },
											{},
											"",
											SyntaxPatternMatchType::LuaPattern },

									  } },
									{ { "include", "#others" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "(?=\\{)", "(?=\\:)" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#function-header-until-colon-with-arg" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },

						  } },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "constants",
			  {
				  { { "\\b(builtins|true|false|null)\\b", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "literal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "\\b(scopedImport|import|isNull|abort|throw|baseNameOf|dirOf|removeAttrs|map|"
					  "toString|derivationStrict|derivation)\\b",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "function" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "\\b[0-9]+\\b", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "number" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-contents",
			  {
				  { { "include", "#bad-reserved" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#function-parameter" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#others" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "function-definition-brace-opened",
			  {
				  { { "(?=.?)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-body-from-colon" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "(?=.?)", "(?=\\:)" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#function-header-close-brace-with-arg" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "(?=.?)", "(?=\\})" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#function-contents" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },

						  } },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attrset-definition",
			  {
				  { { "(?=\\{)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "(\\{)", "(\\})" },
						  { "operator" },
						  { "operator" },
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#attrset-contents" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "(?<=\\})", "(?=([\\])};,]|\\b(else|then)\\b))" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#expression-cont" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },

					} },

			  } },
			{ "function-header-until-colon-no-arg",
			  {
				  { { "(?=\\{)", "(?=\\:)" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#function-header-open-brace" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#function-header-close-brace-no-arg" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "expression",
			  {
				  { { "include", "#parens-and-cont" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#list-and-cont" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#string" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#interpolation" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#with-assert" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#function-for-sure" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#attrset-for-sure" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#attrset-or-function" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#let" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#if" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#operator-unary" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#constants" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#bad-reserved" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#parameter-name-and-cont" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#others" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "attribute-name",
			  {
				  { { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },
				  { { "\\." }, "normal", "", SyntaxPatternMatchType::RegEx },
				  { { "include", "#string-quoted" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#interpolation" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "function-body-from-colon",
			  {
				  { { "(\\:)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attrset-contents",
			  {
				  { { "include", "#attribute-inherit" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#bad-reserved" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#attribute-bind" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#others" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "attrset-definition-brace-opened",
			  {
				  { { "(?<=\\})", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(?=.?)", "\\}" },
					{ "normal" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#attrset-contents" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "string-quoted",
			  {
				  { { "\\\"", "\\\"" },
					{ "string" },
					{ "string" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\\\." }, "string", "", SyntaxPatternMatchType::RegEx },
						{ { "include", "#interpolation" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-parameter",
			  {
				  { { "(\\.\\.\\.)", "(,|(?=\\}))" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "(,|(?=\\}))" },
					{ "parameter" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#whitespace" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#comment" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#function-parameter-default" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "include", "#others" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "attrset-or-function",
			  {
				  { { "\\{", "(?=([\\])};]|\\b(else|then)\\b))" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "(?=(\\s*\\}|\\\"|\\binherit\\b|\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*("
							"\\s*\\.|\\s*=[^=])))",
							"(?=([\\])};,]|\\b(else|then)\\b))" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#attrset-definition-brace-opened" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "(?=(\\.\\.\\.|\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*\\s*[,?]))",
							"(?=([\\])};,]|\\b(else|then)\\b))" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#function-definition-brace-opened" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#bad-reserved" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*",
							"(?=([\\])};]|\\b(else|then)\\b))" },
						  { "parameter" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "(?=\\.)", "(?=([\\])};,]|\\b(else|then)\\b))" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#attrset-definition-brace-opened" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "\\s*(\\,)", "(?=([\\])};,]|\\b(else|then)\\b))" },
								{ "normal", "operator" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#function-definition-brace-opened" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "(?=\\=)", "(?=([\\])};,]|\\b(else|then)\\b))" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#attribute-bind-from-equals" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },
									{ { "include", "#attrset-definition-brace-opened" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "(?=\\?)", "(?=([\\])};,]|\\b(else|then)\\b))" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#function-parameter-default" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },
									{ { "\\,", "(?=([\\])};,]|\\b(else|then)\\b))" },
									  { "operator" },
									  {},
									  "",
									  SyntaxPatternMatchType::RegEx,
									  {
										  { { "include", "#function-definition-brace-opened" },
											{ "normal" },
											{},
											"",
											SyntaxPatternMatchType::LuaPattern },

									  } },

								} },
							  { { "include", "#others" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "expression-cont",
			  {
				  { { "(?=.?)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#parens" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#list" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#string" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#interpolation" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#function-for-sure" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#attrset-for-sure" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#attrset-or-function" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "(\\bor\\b|\\.|==|!=|!|\\<\\=|\\<|\\>\\=|\\>|&&|\\|\\||-\\>|//"
							"|\\?|\\+\\+|-|\\*|/(?=([^*]|$))|\\+)" },
						  "operator",
						  "",
						  SyntaxPatternMatchType::RegEx },
						{ { "include", "#constants" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#bad-reserved" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#parameter-name" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "list",
			  {
				  { { "\\[", "\\]" },
					{ "operator" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attribute-name-single",
			  {
				  { { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "interpolation",
			  {
				  { { "\\$\\{", "\\}" },
					{ "operator" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attrset-for-sure",
			  {
				  { { "(?=\\brec\\b)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\brec\\b", "(?=\\{)" },
						  { "keyword" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#others" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#attrset-definition" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "(?=\\{\\s*(\\}|[^,?]*(=|;)))", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#attrset-definition" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attribute-bind-from-equals",
			  {
				  { { "\\=", "\\;" },
					{ "operator" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "bad-reserved",
			  {
				  { { "\\b(if|then|else|assert|with|let|in|rec|inherit)\\b" },
					"normal",
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "comment-remark",
			  {
				  { { "(TODO|FIXME|BUG|\\!\\!\\!):?" },
					{ "normal", "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "comment",
			  {
				  { { "/\\*([^*]|\\*[^\\/])*", "\\*\\/" },
					{ "comment" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment-remark" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },
				  { { "\\#", "$" },
					{ "comment" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#comment-remark" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-parameter-default",
			  {
				  { { "\\?", "(?=[,}])" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "if",
			  {
				  { { "(?=\\bif\\b)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\bif\\b", "\\bth(?=en\\b)" },
						  { "keyword" },
						  { "keyword" },
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#expression" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "(?<=th)en\\b", "\\bel(?=se\\b)" },
						  { "keyword" },
						  { "keyword" },
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#expression" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "(?<=el)se\\b", "(?=([\\])};,]|\\b(else|then)\\b))" },
						  { "keyword" },
						  { "keyword" },
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#expression" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },

					} },

			  } },
			{ "let",
			  {
				  { { "(?=\\blet\\b)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\blet\\b", "(?=([\\])};,]|\\b(in|else|then)\\b))" },
						  { "keyword" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "(?=\\{)", "(?=([\\])};,]|\\b(else|then)\\b))" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "\\{", "\\}" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::RegEx,
									  {
										  { { "include", "#attrset-contents" },
											{ "normal" },
											{},
											"",
											SyntaxPatternMatchType::LuaPattern },

									  } },
									{ { "(^|(?<=\\}))", "(?=([\\])};,]|\\b(else|then)\\b))" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::RegEx,
									  {
										  { { "include", "#expression-cont" },
											{ "normal" },
											{},
											"",
											SyntaxPatternMatchType::LuaPattern },

									  } },
									{ { "include", "#others" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "include", "#attrset-contents" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#others" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "\\bin\\b", "(?=([\\])};,]|\\b(else|then)\\b))" },
						  { "keyword" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#expression" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },

					} },

			  } },
			{ "list-and-cont",
			  {
				  { { "(?=\\[)", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#list" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "function-body",
			  {
				  { { "(@\\s*([a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*)\\s*)?(\\:)",
					  "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "operator-unary",
			  {
				  { { "(!|-)" }, "operator", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "others",
			  {
				  { { "include", "#whitespace" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#comment" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },
				  { { "include", "#illegal" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::LuaPattern },

			  } },
			{ "parameter-name",
			  {
				  { { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*" },
					"parameter",
					"",
					SyntaxPatternMatchType::RegEx },

			  } },
			{ "parens",
			  {
				  { { "\\(", "\\)" },
					{ "operator" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "parameter-name-and-cont",
			  {
				  { { "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "parameter" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "parens-and-cont",
			  {
				  { { "(?=\\()", "(?=([\\])};,]|\\b(else|then)\\b))" },
					{ "normal" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#parens" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },
						{ { "include", "#expression-cont" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "attribute-inherit",
			  {
				  { { "\\binherit\\b", "\\;" },
					{ "keyword" },
					{ "operator" },
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "\\(", "(?=\\;)" },
						  { "operator" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "\\)", "(?=\\;)" },
								{ "operator" },
								{},
								"",
								SyntaxPatternMatchType::RegEx,
								{
									{ { "include", "#bad-reserved" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },
									{ { "include", "#attribute-name-single" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },
									{ { "include", "#others" },
									  { "normal" },
									  {},
									  "",
									  SyntaxPatternMatchType::LuaPattern },

								} },
							  { { "include", "#expression" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "(?=[a-zA-Z\\_])", "(?=\\;)" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::RegEx,
						  {
							  { { "include", "#bad-reserved" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#attribute-name-single" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },
							  { { "include", "#others" },
								{ "normal" },
								{},
								"",
								SyntaxPatternMatchType::LuaPattern },

						  } },
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

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

			  } },
			{ "with-assert",
			  {
				  { { "\\b(with|assert)\\b", "\\;" },
					{ "keyword" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#expression" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
			{ "illegal",
			  {
				  { { "." }, "normal", "", SyntaxPatternMatchType::RegEx },

			  } },
			{ "function-header-close-brace-no-arg",
			  {
				  { { "\\}", "(?=\\:)" },
					{ "operator" },
					{},
					"",
					SyntaxPatternMatchType::RegEx,
					{
						{ { "include", "#others" },
						  { "normal" },
						  {},
						  "",
						  SyntaxPatternMatchType::LuaPattern },

					} },

			  } },
		} ).setBlockComment( { "/*", "*/" } );;
}

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