Skip to content

Commit

Permalink
add more keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
YouNeedWork committed May 8, 2023
1 parent ed4c68d commit a089edb
Showing 1 changed file with 118 additions and 75 deletions.
193 changes: 118 additions & 75 deletions move.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,129 @@
Language: move
Author: Yusong Wang <[email protected]>
Contributors: Yusong Wang <[email protected]>
Website:
Category: common, system
Website:
Category: common
*/

/** @type LanguageFn */
export default function move(hljs) {
//const regex = hljs.regex;
export default function (hljs) {
const KEYWORDS = [
"abort",
"acquires",
"has",
"as",
"break",
"continue",
"copy",
"drop",
"key",
"mut",
"store",
"define",
"else",
"false",
"fun",
"if",
"invariant",
"let",
"loop",
"module",
"entry",
"move",
"native",
"public",
"const",
"return",
"spec",
"struct",
"true",
"use",
"while",
"script",
"friend",
"address",
];

const KEYWORDS = [
"abort",
"acquires",
"has",
"as",
"break",
"continue",
"copy",
"drop",
"key",
"mut",
"store",
"define",
"else",
"false",
"fun",
"if",
"invariant",
"let",
"loop",
"module",
"entry",
"move",
"native",
"public",
"const",
"return",
"spec",
"struct",
"true",
"use",
"while"
];
const LITERALS = ["true", "false"];

const LITERALS = [
"true",
"false"
];
const BUILTINS = [
"move_to_sender",
"emit_event",
"emit",
"borrow_global_mut",
"has",
"assert",
"borrow_global",
"exists",
"freeze",
"move_from",
"move_to",
"old",
"transfer",
"public_transfer",
"freeze_object",
"public_freeze_object",
"share_object",
"public_share_object",
];

const BUILTINS = [
"move_to_sender",
"borrow_global",
"emit_event",
"borrow_global_mut",
"has",
"move_from",
"exists",
];
const TYPES = ["u8", "u16", "u32", "u64", "u128", "u256", "bool", "vector"];

const TYPES = [
"u8",
"u64",
"u128",
"u256",
"vector",
"address",
"bool"
];

return {
name: 'move',
aliases: ['move'],
keywords: {
$pattern: hljs.IDENT_RE + '!?',
type: TYPES,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILTINS
},
illegal: '</',
contains: []
};
return {
name: "move",
aliases: ["move"],
keywords: {
$pattern: hljs.IDENT_RE + "!?",
type: TYPES,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILTINS,
},
illegal: "</",
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.COMMENT("/\\*", "\\*/", { contains: ["self"] }),
hljs.inherit(hljs.QUOTE_STRING_MODE, {
begin: /b?"/,
illegal: null,
}),
{
className: "string",
variants: [
{ begin: /r(#*)"(.|\n)*?"\1(?!#)/ },
{ begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/ },
],
},
{ className: "symbol", begin: /'[a-zA-Z_][a-zA-Z0-9_]*/ },
{
className: "number",
variants: [
{ begin: "\\b0x([A-Fa-f0-9_]+)" },
{ begin: "\\b([0-9]+)(u(8|64|128))?" },
],
relevance: 0,
},
{
className: "function",
beginKeywords: "fun",
end: "(\\(|<)",
excludeEnd: !0,
contains: [hljs.UNDERSCORE_TITLE_MODE],
},
{
className: "class",
beginKeywords: "struct resource module",
end: "{",
contains: [
hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, { endsParent: !0 }),
],
illegal: "[\\w\\d]",
},
{
className: "punctuation",
begin: ":",
},
{ begin: hljs.IDENT_RE + "::", keywords: { built_in: BUILTINS } },
],
};
}

//export registerLanguage("move", move)

0 comments on commit a089edb

Please sign in to comment.