-- lx-public:0

-- lx syntax
local syntax = require("core.syntax")
local patterns = require("core.syntax.patterns")

syntax.add({
	name = "Liqubill Preset",
	shortname = "TTP",
	extensions = { "ttp" },
	headers = ";ttp",
	comment = ";",

	patterns = {
		{ pattern = "%w+#?\n", type= "label", line_start = true },

		{ pattern = "(-?[%d%.]+)(deg)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(hz)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(ct)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(st)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(ms)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(db)", type = { "number", "literal" } },
		{ pattern = "(-?[%d%.]+)(%%)", type = { "number", "literal" } },

		{ pattern = "%s*;.-\n", type = "comment", line_start = true },
		{ pattern = "@[%a_][%w_%-]*", type = "keyword" },
		{
			pattern = "%f[%S]%d+:%s*[^#\n]+",
			type = "string",
			post_symbols = "_states", -- post-colorize certain tokens
		},
		{ pattern = "-?%d+%.?%d*", type = "number" },
		{ pattern = "#", type = "label" },
		{ pattern = "[%[%]]", type = "operator" },
		{ pattern = "[%a_][%w_%-]*", type = "symbol" },
		{ pattern = "[:]", type = "operator" },
		{
			pattern = "%s*(%d+)(:)%s*(.-)\n",
			type = { "number", "operator", "string" },
			post_symbols = "_states",
		},
	},
	outline_patterns = {
		{ pattern = "%w+#?\n", line_start = true },
	},
	symbols = {
		["global"] = "label",

		["macro1"] = "keyword",
		["macro2"] = "keyword",
		["macro3"] = "keyword",
		["macro4"] = "keyword",
		["macro5"] = "keyword",
		["macro6"] = "keyword",

		["uni"] = "keyword2",
		["bi"] = "keyword2",
	},
	_states = {
		["on"] = "success",
		["off"] = "error",
	},
})
