Skip to content

Instantly share code, notes, and snippets.

@Lunatoid
Created January 24, 2025 16:24
Show Gist options
  • Save Lunatoid/2fe1df4f5d097eeea517dd7c4863824a to your computer and use it in GitHub Desktop.
Save Lunatoid/2fe1df4f5d097eeea517dd7c4863824a to your computer and use it in GitHub Desktop.
hljs.registerLanguage("jai", function(e) {
return {
aliases: ["jai"],
keywords: {
keyword: "xx break case continue defer else enum enum_flags for if return struct type_of union using inline no_inline push_context remove ifx then interface operator",
literal: "true false null",
},
illegal: "</",
contains: [
e.C_LINE_COMMENT_MODE,
e.C_BLOCK_COMMENT_MODE,
{
className: "string",
variants: [
e.QUOTE_STRING_MODE,
hljs.END_SAME_AS_BEGIN({
begin: /(?<=#string\s+)(\w+)/,
end: /(\w+)/
})
],
},
{
className: "number",
relevance: 10,
variants: [
{
begin: /\b0x[A-Fa-f0-9]+\b/
},
{
begin: /\b0b[01]+\b/
},
{
begin: /\b\d+(\.\d+)?\b/
}
]
},
{
className: "type",
begin: /int|u8|u16|u32|u64|s8|s16|s32|s64|bool|string|float|float32|float64|Table|String_Builder/
},
{
className: "operator",
begin: /\+|-|\/|\*|%|\+=|-=|\*=|\/=|%=|<<|>>|:=|::|=|---|\.\*|<<=|>>=|<<<|<<<=|>>>|>>>=|==|===|->/,
},
{
className: "name",
begin: /@\w+/,
},
{
className: "built_in",
begin: /\$\w+/,
},
{
className: "meta",
begin: /#\w+/
},
{
className: "built_in",
begin: /temp|context/,
relevance: 10
},
{
className: "keyword",
begin: /type_of|size_of|code_of|type_info|cast|xx|initializer_of|is_constant/,
relevance: 10
},
{
begin: /(\w+)\s*::\s*\(.*\)/,
returnBegin: true,
relevance: 5,
contains: [
{
className: 'title.function',
begin: /\w+/,
end: /(?=\s*::\s*\(.*\))/
},
]
},
{
begin: /\w+\(.*\)/,
returnBegin: true,
contains: [
{
className: 'title.function.invoke',
begin: /\w+/,
end: /(?=\(.*\))/
},
]
},
{
begin: /\w+\s*::\s*/,
returnBegin: true,
contains: [
{
className: 'property',
begin: /\w+/,
end: /(?=\s*::\s*)/
},
]
},
{
begin: /(\w+)\s*:\s*(\[.*\])?\s*\**\s*(\w+)/,
returnBegin: true,
contains: [
{
className: 'property',
begin: /\w+/,
end: /(?=\s*:)/
},
{
className: 'type',
excludeBegin: true,
begin: /:\s*(\[.*\])?\s*\**\s*/,
end: /\w+/,
}
]
}
]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment