Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-callbacks.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
3 changes: 3 additions & 0 deletions Units/parser-elixir.r/elixir-callbacks.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CallbackModule input.ex /^defmodule CallbackModule do$/;" module
new_callback input.ex /^ @callback new_callback() :: integer$/;" callback
old_callback input.ex /^ defcallback old_callback(info :: integer) :: integer$/;" callback
8 changes: 8 additions & 0 deletions Units/parser-elixir.r/elixir-callbacks.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule CallbackModule do
use Behaviour
# This is the new callback syntax
@callback new_callback() :: integer

# This is the old (deprecated) callback syntax
defcallback old_callback(info :: integer) :: integer
end
5 changes: 5 additions & 0 deletions Units/parser-elixir.r/elixir-exceptions.b/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Exceptions are defined like structs but their name is the name of module they
are defined in. For this I'll have to use a multiline regex
(`--mline-regex-<LANG>`) which I don't know yet how to use.

This is more a TODO than a bug.
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-exceptions.b/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ModuleError input.ex /^defmodule ModuleError do$/;" module
ModuleError input.ex /^ defexception [:message]$/;" delegate
9 changes: 9 additions & 0 deletions Units/parser-elixir.r/elixir-exceptions.b/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule ErrorModule do
defexception [:message]

@impl true
def exception(value) do
msg = "did not get what was expected, got: #{inspect(value)}"
%ErrorModule{message: msg}
end
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-functions.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
8 changes: 8 additions & 0 deletions Units/parser-elixir.r/elixir-functions.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FunctionModule input.ex /^defmodule FunctionModule do$/;" module
one_liner_func input.ex /^ def one_liner_func, do: :baz$/;" function
func_no_params input.ex /^ def func_no_params do$/;" function
func_head input.ex /^ def func_head(string1, string2 \\\\ nil, separator \\\\ " ")$/;" function
func_one_arity input.ex /^ def func_one_arity(string1, nil, _separator) do$/;" function
normal_func input.ex /^ def normal_func(string1, string2, separator) do$/;" function
private_func input.ex /^ defp private_func(a), do: a <> " alone"$/;" function
private_func_no_params input.ex /^ defp private_func_no_params do$/;" function
27 changes: 27 additions & 0 deletions Units/parser-elixir.r/elixir-functions.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defmodule FunctionModule do
def one_liner_func, do: :baz

def func_no_params do
#
end

# Function head
def func_head(string1, string2 \\ nil, separator \\ " ")

# Function with 1 arity
def func_one_arity(string1, nil, _separator) do
private_function(string1)
end

# Normal function
def normal_func(string1, string2, separator) do
string1 <> separator <> string2
end

# Private function
defp private_func(a), do: a <> " alone"

defp private_func_no_params do
#
end
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-macros.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
5 changes: 5 additions & 0 deletions Units/parser-elixir.r/elixir-macros.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MacroModule input.ex /^defmodule MacroModule do$/;" module
macro input.ex /^ defmacro macro(expr, opts) do$/;" macro
macro_no_params input.ex /^ defmacro macro_no_params do$/;" macro
private_macro input.ex /^ defmacrop private_macro(expr, opts) do$/;" macro
private_macro_no_params input.ex /^ defmacrop private_macro_no_params do$/;" macro
17 changes: 17 additions & 0 deletions Units/parser-elixir.r/elixir-macros.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule MacroModule do
defmacro macro(expr, opts) do
#
end

defmacro macro_no_params do
#
end

defmacrop private_macro(expr, opts) do
#
end

defmacrop private_macro_no_params do
#
end
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-modules.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
3 changes: 3 additions & 0 deletions Units/parser-elixir.r/elixir-modules.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Foo input.ex /^defmodule Foo do$/;" module
Bar input.ex /^defmodule Foo.Bar do$/;" module
Baz input.ex /^ defmodule Baz do$/;" module
7 changes: 7 additions & 0 deletions Units/parser-elixir.r/elixir-modules.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Foo do
end

defmodule Foo.Bar do
defmodule Baz do
end
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-records.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
3 changes: 3 additions & 0 deletions Units/parser-elixir.r/elixir-records.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RecordsModule input.ex /^defmodule RecordsModule do$/;" module
user1 input.ex /^ Record.defrecord(:user1, name: "megan", age: "25")$/;" record
user2 input.ex /^ Record.defrecordp :user2, name: "ivan", age: "23"$/;" record
7 changes: 7 additions & 0 deletions Units/parser-elixir.r/elixir-records.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule RecordsModule do
require Record
Record.defrecord(:user1, name: "megan", age: "25")
Record.defrecordp :user2, name: "ivan", age: "23"
# This is not a typo but an intentional bad test, used to test the parser
Record.defrecordp:bad, name: "ivan", age: "23"
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-sign-operators.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
20 changes: 20 additions & 0 deletions Units/parser-elixir.r/elixir-sign-operators.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
OperatorModule input.ex /^defmodule OperatorModule do$/;" module
+ input.ex /^ def a + b, do: max(a, b)$/;" operator
- input.ex /^ def a - b, do: max(a, b)$/;" operator
* input.ex /^ def a * b, do: max(a, b)$/;" operator
/ input.ex /^ def a \/ b, do: max(a, b)$/;" operator
= input.ex /^ def a = b, do: max(a, b)$/;" operator
. input.ex /^ def a . b, do: max(a, b)$/;" operator
| input.ex /^ def a | b, do: max(a, b)$/;" operator
||| input.ex /^ def _ ||| b, do: max(a, b)$/;" operator
&&& input.ex /^ def a &&& _, do: max(a, b)$/;" operator
<<< input.ex /^ def a <<< b, do: max(a, b)$/;" operator
>>> input.ex /^ defp a >>> b, do: max(a, b)$/;" operator
<<~ input.ex /^ defp _ <<~ _, do: max(a, b)$/;" operator
~>> input.ex /^ defp a ~>> b, do: max(a, b)$/;" operator
<~ input.ex /^ defmacro a <~ b, do: max(a, b)$/;" operator
~> input.ex /^ defmacro _ ~> b, do: max(a, b)$/;" operator
<~> input.ex /^ defmacro a <~> _, do: max(a, b)$/;" operator
<|> input.ex /^ defmacrop a <|> b, do: max(a, b)$/;" operator
^^^ input.ex /^ defmacrop _ ^^^ _, do: max(a, b)$/;" operator
~~~ input.ex /^ defmacrop a ~~~ b, do: max(a, b)$/;" operator
24 changes: 24 additions & 0 deletions Units/parser-elixir.r/elixir-sign-operators.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
defmodule OperatorModule do
def a + b, do: max(a, b)
def a - b, do: max(a, b)
def a * b, do: max(a, b)
def a / b, do: max(a, b)
def a = b, do: max(a, b)
def a . b, do: max(a, b)

# The 13 operators bellow are ALL the operators that Elixir is CAPABLE of
# parsing and are not used by default, so the user can
def a | b, do: max(a, b)
def _ ||| b, do: max(a, b)
def a &&& _, do: max(a, b)
def a <<< b, do: max(a, b)
defp a >>> b, do: max(a, b)
defp _ <<~ _, do: max(a, b)
defp a ~>> b, do: max(a, b)
defmacro a <~ b, do: max(a, b)
defmacro _ ~> b, do: max(a, b)
defmacro a <~> _, do: max(a, b)
defmacrop a <|> b, do: max(a, b)
defmacrop _ ^^^ _, do: max(a, b)
defmacrop a ~~~ b, do: max(a, b)
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-simple.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
10 changes: 10 additions & 0 deletions Units/parser-elixir.r/elixir-simple.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MyList input.ex /^defmodule MyList do$/;" module
reverse input.ex /^ defdelegate reverse(list), to: Enum$/;" delegate
other_reverse input.ex /^ defdelegate other_reverse(list), to: Enum, as: :reverse$/;" delegate
Size input.ex /^defprotocol Size do$/;" protocol
size input.ex /^ def size(data)$/;" function
MyGuards input.ex /^defmodule Integer.MyGuards do$/;" module
is_even input.ex /^ defguard is_even(value) when is_integer(value) and rem(value, 2) == 0$/;" guard
is_odd input.ex /^ defguardp is_odd(value) when is_integer(value) and rem(value, 2) != 0$/;" guard
Size input.ex /^defimpl Size, for: BitString do$/;" implementation
size input.ex /^ def size(binary), do: byte_size(binary)$/;" function
37 changes: 37 additions & 0 deletions Units/parser-elixir.r/elixir-simple.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Most of this code is taken from the official Elixir documentation.
# With comments and modifications
# by Ivan Gonzalez Polanco <[email protected]>
#
# This code doesn't compile, since it's supposed to test de ctags elixir
# parser, not the elixir elixir parser.

#
# d delegates (defdelegate ...)
#
defmodule MyList do
defdelegate reverse(list), to: Enum
defdelegate other_reverse(list), to: Enum, as: :reverse
end

#
# p protocols (defprotocol ...)
#
defprotocol Size do
@doc "Calculates the size (and not the length!) of a data structure"
def size(data)
end

#
# g guards (defguard ...)
#
defmodule Integer.MyGuards do
defguard is_even(value) when is_integer(value) and rem(value, 2) == 0
defguardp is_odd(value) when is_integer(value) and rem(value, 2) != 0
end

#
# i implementations (defimpl ...)
#
defimpl Size, for: BitString do
def size(binary), do: byte_size(binary)
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-tests.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
3 changes: 3 additions & 0 deletions Units/parser-elixir.r/elixir-tests.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TestModule input.ex /^defmodule TestModule do$/;" module
good with spaces input.ex /^ test "good with spaces" do$/;" test
good with parens input.ex /^ test("good with parens") do$/;" test
22 changes: 22 additions & 0 deletions Units/parser-elixir.r/elixir-tests.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule TestModule do
use ExUnit.Case, async: true

test "good with spaces" do
assert 1 + 1 == 2
end

test("good with parens") do
assert 1 + 1 == 2
end
test"bad without spaces" do
assert 1 + 1 == 2
end

test "bad without 'do' word"
assert 1 + 1 == 2
end

test 'bad with single quotes' do
assert 1 + 1 == 2
end
end
2 changes: 2 additions & 0 deletions Units/parser-elixir.r/elixir-word-operators.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+K
7 changes: 7 additions & 0 deletions Units/parser-elixir.r/elixir-word-operators.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OperatorModule input.ex /^defmodule OperatorModule do$/;" module
and input.ex /^ def a and b, do: max(a, b)$/;" operator
or input.ex /^ def a or b, do: max(a, b)$/;" operator
not input.ex /^ defp a not b, do: max(a, b)$/;" operator
in input.ex /^ defmacro a in b, do: max(a, b)$/;" operator
not in input.ex /^ defmacrop a not in b, do: max(a, b)$/;" operator
when input.ex /^ defmacrop a when b, do: max(a, b)$/;" operator
8 changes: 8 additions & 0 deletions Units/parser-elixir.r/elixir-word-operators.d/input.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule OperatorModule do
def a and b, do: max(a, b)
def a or b, do: max(a, b)
defp a not b, do: max(a, b)
defmacro a in b, do: max(a, b)
defmacrop a not in b, do: max(a, b)
defmacrop a when b, do: max(a, b)
end
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The following parsers have been added:
* Diff
* DTD
* DTS
* Elixir *optlib*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent.

* Elm *optlib*
* Falcon
* Gdbinit script *optlib*
Expand Down
1 change: 1 addition & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
DTSParser, \
DosBatchParser, \
EiffelParser, \
ElixirParser, \
ElmParser, \
ErlangParser, \
FalconParser, \
Expand Down
3 changes: 2 additions & 1 deletion makefiles/optlib2c_input.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ OPTLIB2C_INPUT = \
optlib/RSpec.ctags \
optlib/cmake.ctags \
optlib/ctags-optlib.ctags \
optlib/elm.ctags \
optlib/elixir.ctags \
optlib/elm.ctags \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not touch elm.ctags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was a conflict when rebasing 09861b6 to master.
The tabs in the line optlib/elm.ctags were corrected in 806f296, but that commit happened after 09861b6, which triggered the conflict.

I should have seen and corrected the tabs, tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(trying out Github's suggestions feature, sorry if it's messy)

Suggested change
optlib/elm.ctags \
optlib/elixir.ctags \
optlib/elm.ctags \

optlib/gdbinit.ctags \
optlib/man.ctags \
optlib/markdown.ctags \
Expand Down
14 changes: 7 additions & 7 deletions misc/optlib2c
Original file line number Diff line number Diff line change
Expand Up @@ -826,22 +826,22 @@ EOF
}
if (@{$opts->{'kinddefs'}}) {
print <<EOF;
def->kindTable = $opts->{'Clangdef'}KindTable;
def->kindCount = ARRAY_SIZE($opts->{'Clangdef'}KindTable);
def->kindTable = $opts->{'Clangdef'}KindTable;
def->kindCount = ARRAY_SIZE($opts->{'Clangdef'}KindTable);
EOF
}

if (@{$opts->{'fielddefs'}}) {
print <<EOF;
def->fieldTable = $opts->{'Clangdef'}FieldTable;
def->fieldCount = ARRAY_SIZE($opts->{'Clangdef'}FieldTable);
def->fieldTable = $opts->{'Clangdef'}FieldTable;
def->fieldCount = ARRAY_SIZE($opts->{'Clangdef'}FieldTable);
EOF
}

if (@{$opts->{'extradefs'}}) {
print <<EOF;
def->xtagTable = $opts->{'Clangdef'}XtagTable;
def->xtagCount = ARRAY_SIZE($opts->{'Clangdef'}XtagTable);
def->xtagTable = $opts->{'Clangdef'}XtagTable;
def->xtagCount = ARRAY_SIZE($opts->{'Clangdef'}XtagTable);
EOF
}

Expand All @@ -854,7 +854,7 @@ EOF

if (defined $opts->{'base'}) {
print <<EOF;
def->dependencies = $opts->{'Clangdef'}Dependencies;
def->dependencies = $opts->{'Clangdef'}Dependencies;
def->dependencyCount = ARRAY_SIZE($opts->{'Clangdef'}Dependencies);
EOF
}
Expand Down
Loading