(function () {
"use strict";
function graphix(hljs) {
const TYPE_PARAM = {
className: "type",
begin: "'[a-z][a-z0-9_]*\\b",
};
const VARIANT = {
className: "symbol",
begin: "`[A-Z][a-zA-Z0-9_]*",
};
const LABEL = {
className: "attr",
begin: "#[a-z_][a-zA-Z0-9_]*:",
relevance: 0,
};
const REFERENCE = {
className: "operator",
begin: "&[a-z_]",
relevance: 0,
};
const OPERATORS = {
className: "operator",
begin:
"(<-|->|=>|~|\\?|\\$|\\.\\.|::|@|\\*(?=[a-z_])|\\||\\+|\\-|/|%|==|!=|<=|>=|<|>|&&|\\|\\|)",
};
const NUMBER = {
className: "number",
variants: [
{
begin:
"\\b0x[0-9a-fA-F]+(_?[0-9a-fA-F]+)*(i32|z32|i64|z64|u32|v32|u64|v64)?\\b",
},
{
begin:
"\\b\\d+(_?\\d+)*\\.\\d+(_?\\d+)*([eE][+-]?\\d+(_?\\d+)*)?(f32|f64)?\\b",
},
{ begin: "\\b\\d+(_?\\d+)*[eE][+-]?\\d+(_?\\d+)*(f32|f64)?\\b" },
{
begin:
"\\b\\d+(_?\\d+)*(i32|z32|i64|z64|u32|v32|u64|v64|f32|f64)?\\b",
},
],
relevance: 0,
};
const DURATION = {
className: "number",
begin: "\\b\\d+(\\.\\d+)?(ms|s|m|h|d)\\b",
};
const STRING = {
className: "string",
variants: [
{
begin: '"',
end: '"',
contains: [
{
className: "subst",
begin: "\\[",
end: "\\]",
contains: ["self"],
},
{
className: "char.escape",
begin: "\\\\.",
relevance: 0,
},
],
},
],
};
const MODULE_PATH = {
className: "title.function",
begin: "\\b[a-z_][a-z0-9_]*::[a-z_][a-z0-9_]*\\b",
};
const FUNCTION_CALL = {
className: "title.function",
begin: "\\b[a-z_][a-z0-9_]*(?=\\()",
relevance: 0,
};
const TYPE_NAME = {
className: "type",
begin: "\\b[A-Z][a-zA-Z0-9_]*\\b",
relevance: 0,
};
return {
name: "Graphix",
aliases: ["gx"],
keywords: {
keyword:
"let fn mod type val sig use select if throws dynamic sandbox whitelist as with",
literal: "true false null",
built_in:
"Array Map Result Option Error String Number Int Float Bool DateTime Duration Any",
},
contains: [
{
className: "comment",
begin: "///",
end: "$",
relevance: 10,
},
hljs.COMMENT("//", "$"),
hljs.COMMENT("/\\*", "\\*/"),
STRING,
VARIANT,
TYPE_PARAM,
LABEL,
MODULE_PATH,
FUNCTION_CALL,
TYPE_NAME,
DURATION,
NUMBER,
OPERATORS,
REFERENCE,
{
className: "function",
begin: "\\|",
end: "\\|",
keywords: {
keyword: "as",
},
contains: [
TYPE_PARAM,
TYPE_NAME,
{
className: "params",
begin: "[a-z_][a-z0-9_]*",
relevance: 0,
},
],
},
{
begin: ":\\s*",
end: "(?=[,\\)\\}\\]=>]|$)",
keywords: {
built_in:
"Array Map Result Option Error String Number Int Float Bool DateTime Duration Any",
},
contains: [
TYPE_PARAM,
TYPE_NAME,
{
className: "type",
begin:
"\\b(i32|z32|i64|z64|u32|v32|u64|v64|f32|f64|bool|string|null|error|array|datetime|duration|decimal)\\b",
},
],
relevance: 0,
},
],
};
}
if (typeof hljs !== "undefined") {
hljs.registerLanguage("graphix", graphix);
hljs.registerLanguage("gx", graphix);
setTimeout(function () {
var blocks = document.querySelectorAll(
"code.language-graphix, code.language-gx",
);
function escapeHtml(text) {
return text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">");
}
blocks.forEach(function (block) {
block.removeAttribute("data-highlighted");
block.classList.remove("hljs");
block.innerHTML = escapeHtml(block.textContent);
if (typeof hljs.highlightElement === "function") {
hljs.highlightElement(block);
} else if (typeof hljs.highlightBlock === "function") {
hljs.highlightBlock(block);
}
});
}, 100);
}
if (typeof module !== "undefined" && module.exports) {
module.exports = graphix;
}
})();