From 1fc19f5ec488ff98e41847b5e82d2a6876abb7d1 Mon Sep 17 00:00:00 2001 From: gahag Date: Mon, 11 Jul 2022 21:19:04 -0300 Subject: [PATCH] Add elseif docs and syntax highlighter --- src/syntax/lexer/token/mod.rs | 2 +- src/syntax/parser/mod.rs | 2 +- syntax-highlight/emacs/hush-mode.el | 2 +- syntax-highlight/pygments/lexer/hush.py | 2 +- syntax-highlight/vscode/syntaxes/hush.tmLanguage.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/syntax/lexer/token/mod.rs b/src/syntax/lexer/token/mod.rs index f54e1cb..e89d320 100644 --- a/src/syntax/lexer/token/mod.rs +++ b/src/syntax/lexer/token/mod.rs @@ -213,7 +213,7 @@ pub enum TokenKind { impl TokenKind { /// Check if the token terminates a statement block. - /// Currently, only the END and ELSE keywords do that. + /// Currently, only the END, ELSE and ELSEIF keywords do that. pub fn is_block_terminator(&self) -> bool { matches!( self, diff --git a/src/syntax/parser/mod.rs b/src/syntax/parser/mod.rs index 2b02a61..a67f50e 100644 --- a/src/syntax/parser/mod.rs +++ b/src/syntax/parser/mod.rs @@ -216,7 +216,7 @@ where } - /// Parse a block of statements, stopping when ELSE, END of EOF are reached, or after a + /// Parse a block of statements, stopping when ELSE, ELSEIF, END of EOF are reached, or after a /// return is parsed. The Lua-like grammar requires stopping after such conditions. /// This method synchronizes on all errors, producing an empty block if no statements /// can be parsed. diff --git a/syntax-highlight/emacs/hush-mode.el b/syntax-highlight/emacs/hush-mode.el index 56990de..22035bd 100644 --- a/syntax-highlight/emacs/hush-mode.el +++ b/syntax-highlight/emacs/hush-mode.el @@ -6,7 +6,7 @@ ;; hush-mode-map)) (defvar hush-keywords - '("let" "if" "then" "else" "end" "for" "in" "do" "while" "function" "return" + '("let" "if" "then" "else" "elseif" "end" "for" "in" "do" "while" "function" "return" "not" "and" "or" "true" "false" "nil" "break" "self")) (defvar hush-mode-syntax-table diff --git a/syntax-highlight/pygments/lexer/hush.py b/syntax-highlight/pygments/lexer/hush.py index 07f8c6e..6c276c0 100644 --- a/syntax-highlight/pygments/lexer/hush.py +++ b/syntax-highlight/pygments/lexer/hush.py @@ -45,7 +45,7 @@ class HushLexer(RegexLexer): (r'[\[\]().,:;]|@\[', Punctuation), (r'(and|or|not)\b', Operator.Word), - (r'(break|self|do|else|end|for|if|in|return|then|while)\b', Keyword.Reserved), + (r'(break|self|do|else|elseif|end|for|if|in|return|then|while)\b', Keyword.Reserved), (r'(let)\b', Keyword.Declaration), (r'(true|false|nil)\b', Keyword.Constant), diff --git a/syntax-highlight/vscode/syntaxes/hush.tmLanguage.json b/syntax-highlight/vscode/syntaxes/hush.tmLanguage.json index 3934056..bdcdb6d 100644 --- a/syntax-highlight/vscode/syntaxes/hush.tmLanguage.json +++ b/syntax-highlight/vscode/syntaxes/hush.tmLanguage.json @@ -83,7 +83,7 @@ "include": "#comment" }, { - "match": "\\b(if|then|else|end|for|in|do|while|break|return)\\b", + "match": "\\b(if|then|else|elseif|end|for|in|do|while|break|return)\\b", "name": "keyword.control.hush" }, {