From aff50fc8f6b1ae6c0303faa52a363ff9746e51db Mon Sep 17 00:00:00 2001 From: harehare Date: Tue, 27 Oct 2026 21:16:33 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(docs):=20add=20missing=20key?= =?UTF-8?q?words=20to=20syntax=20highlighters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add as/yield to highlight-mq.js and sync the keyword lists in the sublime syntax, playground, chrome extension, repl and debugger with the lexer keyword table. --- assets/mq.sublime-syntax | 2 +- crates/mq-repl/src/command_context.rs | 4 ++-- crates/mq-repl/src/repl.rs | 2 +- crates/mq-run/src/debugger.rs | 2 +- docs/books/theme/highlight-mq.js | 4 ++-- .../mq-chrome-extension/entrypoints/popup/lib/mqLanguage.ts | 2 +- packages/mq-playground/src/Playground.tsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/mq.sublime-syntax b/assets/mq.sublime-syntax index da1c859e5..4078203e4 100644 --- a/assets/mq.sublime-syntax +++ b/assets/mq.sublime-syntax @@ -23,7 +23,7 @@ contexts: scope: comment.line.number-sign.mq keywords: - - match: '\b(def|do|let|if|elif|else|end|while|until|unless|foreach|self|nodes|match|fn|break|continue|include|import|module|var|loop|try|catch|as)\b' + - match: '\b(def|do|let|if|elif|else|end|while|until|unless|foreach|self|nodes|match|fn|break|continue|include|import|module|var|loop|try|catch|as|yield)\b' scope: keyword.control.mq - match: '(//=|<<|>>|<=|>=|==|!=|=~|!~|\|\||&&|\?\?|::|\.\.|\|=|\+=|-=|\*=|/=|%=|->|=|<|>|\||:|;|\?|!|\+|-|\*|/|%|@)' scope: keyword.operator.mq diff --git a/crates/mq-repl/src/command_context.rs b/crates/mq-repl/src/command_context.rs index fce2a1de4..bf8799f31 100644 --- a/crates/mq-repl/src/command_context.rs +++ b/crates/mq-repl/src/command_context.rs @@ -50,10 +50,10 @@ pub enum Command { /// /// This list must be kept in sync with the keyword definitions in /// `crates/mq-lang/src/lexer.rs` (see the lexer keyword table in `ident_or_keyword`). -const KEYWORDS: &[&str; 28] = &[ +const KEYWORDS: &[&str; 29] = &[ "def", "let", "if", "unless", "elif", "else", "end", "while", "until", "loop", "foreach", "self", "nodes", "fn", "break", "continue", "include", "true", "false", "None", "match", "try", "catch", "import", "module", "do", "var", - "as", + "as", "yield", ]; impl fmt::Display for Command { diff --git a/crates/mq-repl/src/repl.rs b/crates/mq-repl/src/repl.rs index 3d140f1df..b4fbede02 100644 --- a/crates/mq-repl/src/repl.rs +++ b/crates/mq-repl/src/repl.rs @@ -24,7 +24,7 @@ static HIGHLIGHT_PATTERNS: LazyLock> = LazyLock::new(|| { ), (r#""([^"\\]|\\.)*""#, |s| s.bright_green()), ( - r"\b(def|let|if|unless|elif|else|end|while|until|foreach|self|nodes|fn|break|continue|include|true|false|None|match|import|module|do|var)\b", + r"\b(def|let|if|unless|elif|else|end|while|until|foreach|self|nodes|fn|break|continue|include|true|false|None|match|import|module|do|var|try|catch|loop|as|yield)\b", |s| s.bright_blue(), ), (r"\b\d+\b", |s| s.bright_magenta()), diff --git a/crates/mq-run/src/debugger.rs b/crates/mq-run/src/debugger.rs index 0632a44f8..26431ee7f 100644 --- a/crates/mq-run/src/debugger.rs +++ b/crates/mq-run/src/debugger.rs @@ -500,7 +500,7 @@ static HIGHLIGHT_PATTERNS: LazyLock> = LazyLock::new(|| { ), // Keywords ( - r"\b(as|break|catch|continue|def|do|elif|else|end|fn|foreach|if|unless|import|include|let|loop|match|module|nodes|self|try|until|var|while)\b", + r"\b(as|break|catch|continue|def|do|elif|else|end|fn|foreach|if|unless|import|include|let|loop|match|module|nodes|self|try|until|var|while|yield)\b", |s| s.truecolor(103, 184, 227).bold().to_string(), ), // Boolean / None constants diff --git a/docs/books/theme/highlight-mq.js b/docs/books/theme/highlight-mq.js index 5676175bc..b64b5360f 100644 --- a/docs/books/theme/highlight-mq.js +++ b/docs/books/theme/highlight-mq.js @@ -6,7 +6,7 @@ function hljsDefineMq(hljs) { const KEYWORDS = { keyword: - "def do let if elif else end while until unless foreach self nodes match fn break continue include import module var loop try catch", + "def do let if elif else end while until unless foreach self nodes match fn break continue include import module var loop try catch as yield", literal: "true false None", }; @@ -77,7 +77,7 @@ }; const KEYWORD_ALTERNATION = - "def|do|let|if|elif|else|end|while|until|unless|foreach|self|nodes|match|fn|break|continue|include|import|module|var|loop|try|catch"; + "def|do|let|if|elif|else|end|while|until|unless|foreach|self|nodes|match|fn|break|continue|include|import|module|var|loop|try|catch|as|yield"; const FUNCTION_CALL = { className: "title.function.invoke", diff --git a/packages/mq-chrome-extension/entrypoints/popup/lib/mqLanguage.ts b/packages/mq-chrome-extension/entrypoints/popup/lib/mqLanguage.ts index 114d0cfb2..d17f7c9a4 100644 --- a/packages/mq-chrome-extension/entrypoints/popup/lib/mqLanguage.ts +++ b/packages/mq-chrome-extension/entrypoints/popup/lib/mqLanguage.ts @@ -6,7 +6,7 @@ type MqState = { }; const KEYWORDS = - /^\b(let|def|do|match|while|until|unless|foreach|if|elif|else|end|self|None|nodes|break|continue|include|import|module|var|loop)\b/; + /^\b(let|def|do|match|while|until|unless|foreach|if|elif|else|end|self|None|nodes|break|continue|include|import|module|var|loop|fn|try|catch|as|yield)\b/; const OPERATORS = /^(\/\/=|<<|>>|\|\||\?\?|<=|>=|==|!=|=~|&&|\+=|-=|\*=|\/=|\|=|=|\||:|;|\?|!|\+|-|\*|\/|%|<|>|@)/; const FUNCTION_CALL = /^[a-zA-Z_]\w*(?=\s*\()/; diff --git a/packages/mq-playground/src/Playground.tsx b/packages/mq-playground/src/Playground.tsx index 4815b4b23..84b51f726 100644 --- a/packages/mq-playground/src/Playground.tsx +++ b/packages/mq-playground/src/Playground.tsx @@ -1838,7 +1838,7 @@ export const Playground = () => { root: [ [/#[^\n]*/, "comment"], [ - /\b(let|def|do|match|while|until|unless|foreach|if|elif|else|end|self|None|nodes|break|continue|include|import|module|var|loop|yield)\b/, + /\b(let|def|do|match|while|until|unless|foreach|if|elif|else|end|self|None|nodes|break|continue|include|import|module|var|loop|yield|fn|try|catch|as)\b/, "keyword", ], [/;/, "delimiter"],