Skip to content

Commit

Permalink
Improve the documentation a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
forell committed May 5, 2024
1 parent 54f7933 commit deae1b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions examples/Modules/Main.dbl
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
```
/
├─ Main
│ ├─ Main (this file)
│ ├─ A
│ ├─ Main (this file)
│ ├─ A (imports B/C/D, resolving to /Main/B/C/D)
│ ├─ B
│ │  ├─ A
│ │  └─ C
│ │  └─ D
│ │  └─ D (imports A, resolving to /Main/B/A)
│ └─ C
├─ List
```
Modules under `/Main/` are local to this example and follow its directory
structure. Additionaly, the module `/List` from the standard library is
imported. *)
imported.

Relative imports refer to the module which is the closest to the importing
module, working upwards through the hierarchy. In this example the module
`/Main/B/C/D` imports the relative path `A`, and the nearest matching
module is `/Main/B/A`. *)

import List

Expand Down
8 changes: 6 additions & 2 deletions src/Parser/Import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ let find_mod prefix (p : Raw.import_path) =
| IPRelative(p, n) -> find_mod_rel prefix (p, n)

(** Find and parse imported module relative to the path [prefix] and add it
to the [mods] map with the absolute mod identifier as the key.
to the module graph [mods] with the absolute mod identifier as the map key.
Each vertex in the map stores a list of definition and the module's
dependencies (graph edges).
Previously imported modules can be passed in the [imported] parameter
to avoid including them twice. *)
to avoid including them twice. These modules will not be added to the
graph, but edges from other vertices may point to them. *)
let rec parse_import ~imported prefix mods (import : Raw.import) =
let path, new_name =
match import.data with
Expand Down

0 comments on commit deae1b5

Please sign in to comment.