Skip to content

Commit

Permalink
Elixir: Added missing keywords (#2958)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-dyer authored Jun 21, 2021
1 parent 42fabfe commit 114e462
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion components/prism-elixir.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Prism.languages.elixir = {
},
'function': /\b[_a-zA-Z]\w*[?!]?(?:(?=\s*(?:\.\s*)?\()|(?=\/\d))/,
'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|exception|impl|module|p|protocol|struct|delegate)?|do|else|end|fn|for|if|import|not|or|raise|require|rescue|try|unless|use|when)\b/,
'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|delegate|exception|impl|macro|module|n|np|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|quote|raise|require|rescue|try|unless|unquote|use|when)\b/,
'boolean': /\b(?:true|false|nil)\b/,
'operator': [
/\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-elixir.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 39 additions & 35 deletions tests/languages/elixir/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
after alias and case
catch cond def
defcallback
defexception
defimpl defmodule
defp
defprotocol
defdelegate
defstruct do else
end fn for if
import not or
raise require rescue try
unless use when

----------------------------------------------------

[
["keyword", "after"], ["keyword", "alias"], ["keyword", "and"], ["keyword", "case"],
["keyword", "catch"], ["keyword", "cond"], ["keyword", "def"],
["keyword", "defcallback"],
["keyword", "defexception"],
["keyword", "defimpl"], ["keyword", "defmodule"],
["keyword", "defp"],
["keyword", "defprotocol"],
["keyword", "defdelegate"],
["keyword", "defstruct"], ["keyword", "do"], ["keyword", "else"],
["keyword", "end"], ["keyword", "fn"], ["keyword", "for"], ["keyword", "if"],
["keyword", "import"], ["keyword", "not"], ["keyword", "or"],
["keyword", "raise"], ["keyword", "require"], ["keyword", "rescue"], ["keyword", "try"],
["keyword", "unless"], ["keyword", "use"], ["keyword", "when"]
]

----------------------------------------------------

Checks for all keywords.
after alias and case
catch cond def
defcallback
defexception
defimpl defmodule
defp
defprotocol
defdelegate
defmacro quote unquote
defn defnp
defstruct do else
end fn for if
import not or
raise require rescue try
unless use when

----------------------------------------------------

[
["keyword", "after"], ["keyword", "alias"], ["keyword", "and"], ["keyword", "case"],
["keyword", "catch"], ["keyword", "cond"], ["keyword", "def"],
["keyword", "defcallback"],
["keyword", "defexception"],
["keyword", "defimpl"], ["keyword", "defmodule"],
["keyword", "defp"],
["keyword", "defprotocol"],
["keyword", "defdelegate"],
["keyword", "defmacro"], ["keyword", "quote"], ["keyword", "unquote"],
["keyword", "defn"], ["keyword", "defnp"],
["keyword", "defstruct"], ["keyword", "do"], ["keyword", "else"],
["keyword", "end"], ["keyword", "fn"], ["keyword", "for"], ["keyword", "if"],
["keyword", "import"], ["keyword", "not"], ["keyword", "or"],
["keyword", "raise"], ["keyword", "require"], ["keyword", "rescue"], ["keyword", "try"],
["keyword", "unless"], ["keyword", "use"], ["keyword", "when"]
]

----------------------------------------------------

Checks for all keywords.

0 comments on commit 114e462

Please sign in to comment.