-- lx format
local format = require("core.format")
local common = require("format.asm.common")
local vocabulary = require("format.asm.vocabulary_nasm_x86")

format.register({
	name = "Assembly Source (GNU x86)",
	shortname = "ASM GNU x86",
	author = "liqube",
	internal = true,
	comment = "#",

	patterns = {
		-- Preprocessor directives before hash comments
		common.preprocessor_patterns,

		-- GNU x86 accepts hash comments and preprocessed C comment forms
		{ pattern = "#.-\n", type = "comment" },
		common.c_comment_patterns,

		-- Shared GNU labels, strings, numbers
		common.structure_patterns,

		-- AT&T register and immediate prefixes separate from their values
		{ pattern = "%%", type = "operator" },
		{ pattern = "%$", type = "operator" },
		common.instruction_patterns,
		common.symbol_patterns,

		-- GNU x86 address expressions and relocation suffixes
		{ pattern = "[%+%-=/%*%^<>!~|&@%?:,%[%]%(%){}]", type = "operator" },
	},

	block_comment = common.block_comment,
	outline_patterns = common.outline_patterns,

	-- NASM and GNU assemblers share generated x86 instruction and vocabulary
	symbols = common.with_gnu_symbols(vocabulary),
})
