Skip to content

Commit 5ede2be

Browse files
committed
Server - fix compile time issues
1 parent 62b7f29 commit 5ede2be

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/server/beam/tau/lib/tau/hydra_synth_lang.ex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,19 @@ defmodule Tau.HydraSynthLang do
4242
end)
4343

4444
def convert_global_syntax_to_instance(code_str) do
45+
# Compile regexes at runtime
46+
hydra_global_fns_regexp =
47+
Enum.map(@hydra_global_fns_patterns, fn {el, pattern} ->
48+
{el, Regex.compile!(pattern)}
49+
end)
50+
51+
hydra_global_attrs_regexp =
52+
Enum.map(@hydra_global_attrs_patterns, fn {el, pattern} ->
53+
{el, Regex.compile!(pattern)}
54+
end)
55+
4556
code_str =
46-
Enum.reduce(@hydra_global_fns_regexp, code_str, fn {el, regexp}, res ->
57+
Enum.reduce(hydra_global_fns_regexp, code_str, fn {el, regexp}, res ->
4758
String.replace(res, regexp, "hydra.#{el}(")
4859
end)
4960

@@ -54,7 +65,7 @@ defmodule Tau.HydraSynthLang do
5465
"({___time___})"
5566
)
5667

57-
Enum.reduce(@hydra_global_attrs_regexp, code_str, fn {el, regexp}, res ->
68+
Enum.reduce(hydra_global_attrs_regexp, code_str, fn {el, regexp}, res ->
5869
String.replace(res, regexp, "hydra.#{el}")
5970
end)
6071
end

0 commit comments

Comments
 (0)