Skip to content

Support a configurable language module#21

Open
Gazler wants to merge 1 commit into
WhatsApp:mainfrom
Gazler:feat/edb_dap_language
Open

Support a configurable language module#21
Gazler wants to merge 1 commit into
WhatsApp:mainfrom
Gazler:feat/edb_dap_language

Conversation

@Gazler

@Gazler Gazler commented Jun 19, 2026

Copy link
Copy Markdown

Erlang has a constraint that ensures there is a mapping from filename to module name:

foo.erl => -module(foo)
bar.erl => -module(bar)

This makes looking up a module based on a path name deterministic. This is not the case in other BEAM languages such as Elixir. In Elixir, there is no mapping between the file name and the module name. It is also possible for an Elixir file to contain multiple modules.

In order to allow edb to be used in Elixir, we need a way to configure the mapping from path to module. However, instead of baking in support just for Elixir, it would be ideal to have this be generic.

This commit introduces a configurable module which can be provided as start options for edb. This is implemented with a behaviour, and a default erlang implementation is provided which is just the code that previously existed. The behaviour implements init/0 and source_to_modules/3.

To allow passing this option through, the application config is required to be set before starting edb. This is should be handled by the caller.

The intention here, is for other languages to wrap edb with their own escript which provides a language implementation.

For example, an Elixir wrapper can use:

defmodule EdbElixir.CLI do
  @moduledoc false

  def main(args) do
    Application.put_env(:edb, :dap_language, EdbElixir.DapLanguage)
    :edb_main.main(args)
  end
end

Erlang has a constraint that ensures there is a mapping from filename to
module name:

```
foo.erl => -module(foo)
bar.erl => -module(bar)
```

This makes looking up a module based on a path name deterministic. This
is not the case in other BEAM languages such as Elixir. In Elixir, there
is no mapping between the file name and the module name. It is also
possible for an Elixir file to contain multiple modules.

In order to allow edb to be used in Elixir, we need a way to configure
the mapping from path to module. However, instead of baking in support
just for Elixir, it would be ideal to have this be generic.

This commit introduces a configurable module which can be provided as
start options for edb. This is implemented with a behaviour, and a
default erlang implementation is provided which is just the code that
previously existed. The behaviour implements `init/0` and
`source_to_modules/3`.

To allow passing this option through, the application config is required
to be set before starting edb. This is should be handled by the caller.

The intention here, is for other languages to wrap edb with their own
escript which provides a language implementation.

For example, an Elixir wrapper can use:

```
defmodule EdbElixir.CLI do
  @moduledoc false

  def main(args) do
    Application.put_env(:edb, :dap_language, EdbElixir.DapLanguage)
    :edb_main.main(args)
  end
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant