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

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

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

		-- RISC-V accepts hash, double-slash, C block comments
		{ pattern = "#.-\n", type = "comment" },
		common.c_comment_patterns,

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

		-- Relocation modifiers precede normal dotted mnemonics and directives
		{ pattern = "%%[%a_][%w_]*", type = "keyword" },
		common.instruction_patterns,
		common.symbol_patterns,

		-- Operand separators, address expressions, vector-mask punctuation
		{ pattern = "[%+%-=/%*%^%%<>!~|&@%?:,%[%]%(%){}]", type = "operator" },
	},

	block_comment = common.block_comment,
	outline_patterns = common.outline_patterns,
	symbols = common.with_gnu_symbols(vocabulary),
})
