From bc3b25fb5c47c97bebef229324ca158a199bef6d Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 07:59:46 -0400 Subject: [PATCH 1/7] Change kind names to singular form Reason: that's the way Exhuberant Ctags defines it's kinds. See http://ctags.sourceforge.net/EXTENDING.html --- .ctags | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.ctags b/.ctags index 25ed702..e2fbcba 100644 --- a/.ctags +++ b/.ctags @@ -1,13 +1,13 @@ --langdef=Elixir --langmap=Elixir:.ex.exs ---regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,functions,functions (def ...)/ ---regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callbacks,callbacks (defcallback ...)/ ---regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegates,delegates (defdelegate ...)/ ---regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exceptions,exceptions (defexception ...)/ ---regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementations,implementations (defimpl ...)/ ---regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macros,macros (defmacro ...)/ ---regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operators,operators (e.g. "defmacro a <<< b")/ ---regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,modules,modules (defmodule ...)/ ---regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocols,protocols (defprotocol...)/ ---regex-Elixir=/^[ \t]*Record\.defrecord[ \t]+:([a-zA-Z0-9_]+)/\1/r,records,records (defrecord...)/ ---regex-Elixir=/^[ \t]*test[ \t]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*/\1/t,tests,tests (test ...)/ +--regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,function,functions (def ...)/ +--regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callback,callbacks (defcallback ...)/ +--regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegate,delegates (defdelegate ...)/ +--regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exception,exceptions (defexception ...)/ +--regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macro,macros (defmacro ...)/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ +--regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,module,modules (defmodule ...)/ +--regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocol,protocols (defprotocol...)/ +--regex-Elixir=/^[ \t]*Record\.defrecord[ \t]+:([a-zA-Z0-9_]+)/\1/r,record,records (defrecord...)/ +--regex-Elixir=/^[ \t]*test[ \t]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*/\1/t,test,tests (test ...)/ From 5bd9c3b7171174f4399098908e6bbc7fd3d9b6f6 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 08:10:43 -0400 Subject: [PATCH 2/7] Update Record.defrecord and test regexes * Records can be private (defrecord*p*) * Both Records and test definitions can use parenthesis instead of spaces. --- .ctags | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ctags b/.ctags index e2fbcba..ccbd0b5 100644 --- a/.ctags +++ b/.ctags @@ -9,5 +9,5 @@ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ --regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,module,modules (defmodule ...)/ --regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocol,protocols (defprotocol...)/ ---regex-Elixir=/^[ \t]*Record\.defrecord[ \t]+:([a-zA-Z0-9_]+)/\1/r,record,records (defrecord...)/ ---regex-Elixir=/^[ \t]*test[ \t]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*/\1/t,test,tests (test ...)/ +--regex-Elixir=/^[ \t]*Record\.defrecord(p?)[ \t(]+:([a-zA-Z0-9_]+)(\)?)/\2/r,record,records (defrecord...)/ +--regex-Elixir=/^[ \t]*test[ \t(]+"([a-z_][a-zA-Z0-9_?! ]*)"*(\)?)/\1/t,test,tests (test ...)/ From 17e690fc508eb91c616f2d673fdd2fb1afeaeb87 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 08:14:40 -0400 Subject: [PATCH 3/7] Update callback regex to use the new callback `defcallback/1` is deprecated, Elixir now uses the `@callback` module attribute to provide the spec for a behaviour callback. --- .ctags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ctags b/.ctags index ccbd0b5..f0524e6 100644 --- a/.ctags +++ b/.ctags @@ -1,7 +1,7 @@ --langdef=Elixir --langmap=Elixir:.ex.exs --regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,function,functions (def ...)/ ---regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callback,callbacks (defcallback ...)/ +--regex-Elixir=/^[ \t]*(@|def)callback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/c,callback,callbacks (@callback ...)/ --regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegate,delegates (defdelegate ...)/ --regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exception,exceptions (defexception ...)/ --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ From b6260af2bdcc1eb244a4181f8ea5c2238feb6a22 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 08:20:27 -0400 Subject: [PATCH 4/7] Add regex for guard definition --- .ctags | 1 + 1 file changed, 1 insertion(+) diff --git a/.ctags b/.ctags index f0524e6..5577c43 100644 --- a/.ctags +++ b/.ctags @@ -4,6 +4,7 @@ --regex-Elixir=/^[ \t]*(@|def)callback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/c,callback,callbacks (@callback ...)/ --regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegate,delegates (defdelegate ...)/ --regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exception,exceptions (defexception ...)/ +--regex-Elixir=/^[ \t]*defguard(p?)[ \t]+(is_[a-zA-Z0-9_?!]+)/\2/g,guard,guards (defguard ...)/ --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macro,macros (defmacro ...)/ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ From 2ef7201c46bb2b6ccb909476b9f74c3b37fa4bf4 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 08:48:14 -0400 Subject: [PATCH 5/7] Update macro and function regex Macros do not necessarily have to be followed by an `(` parenthesis, but they *do* necessarily have to *not* be followed by any of the characters inside the backticks: `|^/&<>~.=!*+-`. Because if they do, then they're no longer normal macros, but _operators_. From https://hexdocs.pm/elixir/operators.html > To define an operator, you can use the usual def* constructs (def, > defp, defmacro, and so on) but with a syntax similar to how the > operator is used So, what applied to `defmacro` applies equally to `def`, that's why we added the bracket expression to the function regex. --- .ctags | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ctags b/.ctags index 5577c43..e9fc45d 100644 --- a/.ctags +++ b/.ctags @@ -1,12 +1,12 @@ --langdef=Elixir --langmap=Elixir:.ex.exs ---regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,function,functions (def ...)/ +--regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\|\^\/&<>~.=!*+-]+)/\2/f,function,functions (def ...)/ --regex-Elixir=/^[ \t]*(@|def)callback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/c,callback,callbacks (@callback ...)/ --regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegate,delegates (defdelegate ...)/ --regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exception,exceptions (defexception ...)/ --regex-Elixir=/^[ \t]*defguard(p?)[ \t]+(is_[a-zA-Z0-9_?!]+)/\2/g,guard,guards (defguard ...)/ --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ ---regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macro,macros (defmacro ...)/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\|\^\/&<>~.=!*+-]+)/\2/a,macro,macros (defmacro ...)/ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ --regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,module,modules (defmodule ...)/ --regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocol,protocols (defprotocol...)/ From 2a981256b32593db0364f691f94664ebbe18b39d Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 09:01:27 -0400 Subject: [PATCH 6/7] Add regexes to parse operators from https://hexdocs.pm/elixir/operators.html: > Elixir is capable of parsing a predefined set of operators; this means > that it's not possible to define new operators (like one could do in > Haskell, for example). However, not all operators that Elixir can > parse are *used* by Elixir: for example, `+` and `||` are used by > Elixir for addition and boolean *or*, but `<~>` is not used (but > valid). The following is a list of all the operators that Elixir is capable of parsing, but that are not used by default (separated by a comma): |, |||, &&&, <<<, >>>, <<~, ~>>, <~, ~>, <~>, <|>, ^^^, ~~~ They could be expressed in a regex atom `(&&&|<~|<~>|etc...)` but I think it can be reduced (I don't know the difference in efficiency) to: `[\|\^&<>~]{1,3}` Adding to that bracket expression the rest of the characters and words used for the defined operators (which can be overriden): `([\|\^\/&<>~.=!*+-]{1,3}|and|or|not|in|not in)` But since the regex engine used in exhuberant-ctags can't do lookahead, I'm not gonna bother to try and make the operator regex exhaustive... plus it's also bad practice to override the default operators. --- .ctags | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.ctags b/.ctags index e9fc45d..95da85e 100644 --- a/.ctags +++ b/.ctags @@ -7,7 +7,11 @@ --regex-Elixir=/^[ \t]*defguard(p?)[ \t]+(is_[a-zA-Z0-9_?!]+)/\2/g,guard,guards (defguard ...)/ --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\|\^\/&<>~.=!*+-]+)/\2/a,macro,macros (defmacro ...)/ ---regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ + +# These are the operators (which can be defined with def(p) and defmacro(p)) +--regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\|\^\/&<>~.=!*+-]{1,3})[ \t]+[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "def a <<< b")/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\|\^\/&<>~.=!*+-]{1,3})[ \t]+[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ + --regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,module,modules (defmodule ...)/ --regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocol,protocols (defprotocol...)/ --regex-Elixir=/^[ \t]*Record\.defrecord(p?)[ \t(]+:([a-zA-Z0-9_]+)(\)?)/\2/r,record,records (defrecord...)/ From 3637529e63a651e0f522715ab468023c29993a56 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Polanco Date: Sun, 3 Mar 2019 12:24:49 -0400 Subject: [PATCH 7/7] Reduce the regex of operators kind to just one regex --- .ctags | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.ctags b/.ctags index 95da85e..02f12db 100644 --- a/.ctags +++ b/.ctags @@ -7,11 +7,7 @@ --regex-Elixir=/^[ \t]*defguard(p?)[ \t]+(is_[a-zA-Z0-9_?!]+)/\2/g,guard,guards (defguard ...)/ --regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementation,implementations (defimpl ...)/ --regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\|\^\/&<>~.=!*+-]+)/\2/a,macro,macros (defmacro ...)/ - -# These are the operators (which can be defined with def(p) and defmacro(p)) ---regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\|\^\/&<>~.=!*+-]{1,3})[ \t]+[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "def a <<< b")/ ---regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\|\^\/&<>~.=!*+-]{1,3})[ \t]+[a-zA-Z0-9_!?!]/\3/o,operator,operators (e.g. "defmacro a <<< b")/ - +--regex-Elixir=/^[ \t]*def((p?)|macro(p?))[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\|\^\/&<>~.=!*+-]{1,3})[ \t]+[a-zA-Z0-9_!?!]/\5/o,operator,operators (e.g. "def a <<< b")/ --regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,module,modules (defmodule ...)/ --regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocol,protocols (defprotocol...)/ --regex-Elixir=/^[ \t]*Record\.defrecord(p?)[ \t(]+:([a-zA-Z0-9_]+)(\)?)/\2/r,record,records (defrecord...)/