From a089edbd04eb815369238185665eeda5a8ef1d90 Mon Sep 17 00:00:00 2001 From: wangyusong Date: Mon, 8 May 2023 11:38:15 +0800 Subject: [PATCH] add more keywords --- move.js | 193 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 118 insertions(+), 75 deletions(-) diff --git a/move.js b/move.js index 68a7f4a..75cc66e 100644 --- a/move.js +++ b/move.js @@ -2,86 +2,129 @@ Language: move Author: Yusong Wang Contributors: Yusong Wang -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: '