Skip to content

Commit f48985d

Browse files
committed
Fix ocannl_config parsing
1 parent 5104527 commit f48985d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
## [0.5.0] -- current
1+
## [0.5.1] -- current
2+
3+
## Added
4+
5+
- Automatic transfers to host from the context that most recently updated a node.
6+
7+
## Fixed
8+
9+
- Added `#` as alternative to `~~` for comment lines in `ocannl_config` files, and a bug in parsing.
10+
11+
## [0.5.0] -- 2024-12-18
212

313
### Added
414

arrayjit/lib/utils.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ let config_file_args =
120120
in
121121
Stdio.printf "\nWelcome to OCANNL! Reading configuration defaults from %s.\n%!" fname;
122122
config_lines
123-
|> List.filter ~f:(Fn.non @@ String.is_prefix ~prefix:"~~")
123+
|> List.filter ~f:(fun l ->
124+
not (String.is_prefix ~prefix:"~~" l || String.is_prefix ~prefix:"#" l))
124125
|> List.map ~f:(String.split ~on:'=')
125126
|> List.filter_map ~f:(function
126127
| [] -> None
128+
| [ s ] when String.is_empty s -> None
127129
| key :: [ v ] ->
128130
let key =
129131
String.(
@@ -133,9 +135,9 @@ let config_file_args =
133135
if String.is_prefix key ~prefix:"ocannl" then String.drop_prefix key 6 else key
134136
in
135137
Some (String.strip ~drop:(equal_char '_') key, v)
136-
| _ ->
138+
| l ->
137139
failwith @@ "OCANNL: invalid syntax in the config file " ^ fname
138-
^ ", should have a single '=' on each non-empty line")
140+
^ ", should have a single '=' on each non-empty line, found: " ^ String.concat l)
139141
|> Hashtbl.of_alist_exn (module String)
140142
| Some _ ->
141143
Stdio.printf "\nWelcome to OCANNL! Configuration defaults file is disabled.\n%!";

0 commit comments

Comments
 (0)