xref: /Universal-ctags/optlib/elixir.c (revision bd186360d320c31e9777827dbdda155fdc5641bf)
1 /*
2  * Generated by ./misc/optlib2c from optlib/elixir.ctags, Don't edit this manually.
3  */
4 #include "general.h"
5 #include "parse.h"
6 #include "routines.h"
7 #include "field.h"
8 #include "xtag.h"
9 
10 
initializeElixirParser(const langType language CTAGS_ATTR_UNUSED)11 static void initializeElixirParser (const langType language CTAGS_ATTR_UNUSED)
12 {
13 }
14 
ElixirParser(void)15 extern parserDefinition* ElixirParser (void)
16 {
17 	static const char *const extensions [] = {
18 		"ex",
19 		"exs",
20 		NULL
21 	};
22 
23 	static const char *const aliases [] = {
24 		NULL
25 	};
26 
27 	static const char *const patterns [] = {
28 		NULL
29 	};
30 
31 	static kindDefinition ElixirKindTable [] = {
32 		{
33 		  true, 'p', "protocol", "protocols (defprotocol...)",
34 		},
35 		{
36 		  true, 'm', "module", "modules (defmodule ...)",
37 		},
38 		{
39 		  true, 'f', "function", "functions (def ...)",
40 		},
41 		{
42 		  true, 'c', "callback", "callbacks (defcallback ...)",
43 		},
44 		{
45 		  true, 'd', "delegate", "delegates (defdelegate ...)",
46 		},
47 		{
48 		  true, 'e', "exception", "exceptions (defexception ...)",
49 		},
50 		{
51 		  true, 'g', "guard", "guards (defguard ...)",
52 		},
53 		{
54 		  true, 'i', "implementation", "implementations (defimpl ...)",
55 		},
56 		{
57 		  true, 'a', "macro", "macros (defmacro ...)",
58 		},
59 		{
60 		  true, 'o', "operator", "operators (e.g. \"defmacro a <<< b\")",
61 		},
62 		{
63 		  true, 'r', "record", "records (defrecord...)",
64 		},
65 		{
66 		  true, 't', "test", "tests (test ...)",
67 		},
68 		{
69 		  true, 'y', "type", "types (@type ...)",
70 		},
71 	};
72 	static tagRegexTable ElixirTagRegexTable [] = {
73 		{"^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\\.)*([A-Z][a-zA-Z0-9_?!]*)", "\\2",
74 		"p", "{scope=set}", NULL, false},
75 		{"^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\\.)*([A-Z][a-zA-Z0-9_?!]*)", "\\2",
76 		"m", "{scope=set}", NULL, false},
77 		{"^[ \t]*def((p?)|macro(p?))[ \t]+([a-zA-Z0-9_?!]+)[ \t]+([\\|\\^/&<>~.=!*+-]{1,3}|and|or|in|(not( +in)?)|when)[ \t]+[a-zA-Z0-9_?!]", "\\5",
78 		"o", "{scope=ref}{exclusive}", NULL, false},
79 		{"^[ \t]*def[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\1",
80 		"f", "{scope=ref}{{. (public) access:}}", NULL, false},
81 		{"^[ \t]*defp[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\1",
82 		"f", "{scope=ref}{{. (private) access:}}", NULL, false},
83 		{"^[ \t]*(@|def)callback[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\2",
84 		"c", "{scope=ref}", NULL, false},
85 		{"^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\1",
86 		"d", "{scope=ref}", NULL, false},
87 		{"^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\\.)*([A-Z][a-zA-Z0-9_?!]*)", "\\2",
88 		"e", "{scope=ref}{exclusive}", NULL, false},
89 		{"^[ \t]*defexception[ \t]+", "",
90 		"", "{exclusive}"
91 		"{{\n"
92 		"    _scopetop {\n"
93 		"        dup :kind /module eq {\n"
94 		"            dup\n"
95 		"            :name /exception _tag _commit exch scope:\n"
96 		"        } if\n"
97 		"    } if\n"
98 		"}}", NULL, false},
99 		{"^[ \t]*defguard[ \t]+(is_[a-zA-Z0-9_?!]+)", "\\1",
100 		"g", "{scope=ref}{{. (public) access:}}", NULL, false},
101 		{"^[ \t]*defguardp[ \t]+(is_[a-zA-Z0-9_?!]+)", "\\1",
102 		"g", "{scope=ref}{{. (private) access:}}", NULL, false},
103 		{"^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\\.)*([A-Z][a-zA-Z0-9_?!]*)", "\\2",
104 		"i", "{scope=ref}", NULL, false},
105 		{"^[ \t]*defmacro[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\\|\\^/&<>~.=!*+-]+)", "\\1",
106 		"a", "{scope=ref}{{. (public) access:}}", NULL, false},
107 		{"^[ \t]*defmacrop[ \t]+([a-z_][a-zA-Z0-9_?!]*)(.[^\\|\\^/&<>~.=!*+-]+)", "\\1",
108 		"a", "{scope=ref}{{. (private) access:}}", NULL, false},
109 		{"^[ \t]*Record\\.defrecord[ \t(]+:([a-zA-Z0-9_]+)(\\)?)", "\\1",
110 		"r", "{scope=ref}{{. (public) access:}}", NULL, false},
111 		{"^[ \t]*Record\\.defrecordp[ \t(]+:([a-zA-Z0-9_]+)(\\)?)", "\\1",
112 		"r", "{scope=ref}{{. (private) access:}}", NULL, false},
113 		{"^[ \t]*test[ \t(]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*(\\)?)[ \t]*do", "\\1",
114 		"t", "{scope=ref}", NULL, false},
115 		{"^[ \t]*@(type|opaque)[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\2",
116 		"y", "{scope=ref}{{. (public) access:}}", NULL, false},
117 		{"^[ \t]*@typep[ \t]+([a-z_][a-zA-Z0-9_?!]*)", "\\1",
118 		"y", "{scope=ref}{{. (private) access:}}", NULL, false},
119 	};
120 
121 
122 	parserDefinition* const def = parserNew ("Elixir");
123 
124 	def->enabled       = true;
125 	def->extensions    = extensions;
126 	def->patterns      = patterns;
127 	def->aliases       = aliases;
128 	def->method        = METHOD_NOT_CRAFTED|METHOD_REGEX;
129 	def->useCork       = CORK_QUEUE;
130 	def->kindTable     = ElixirKindTable;
131 	def->kindCount     = ARRAY_SIZE(ElixirKindTable);
132 	def->tagRegexTable = ElixirTagRegexTable;
133 	def->tagRegexCount = ARRAY_SIZE(ElixirTagRegexTable);
134 	def->initialize    = initializeElixirParser;
135 
136 	return def;
137 }
138