Skip to content

Commit a33ba77

Browse files
authored
Support for negative values in noise generators (#35)
1 parent c0f4e15 commit a33ba77

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

datamodel/noise/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const (
2626
)
2727

2828
var (
29-
genReg = regexp.MustCompile(`(?P<func_name>\w+)\((?P<args>(?:\w+=[0-9\.]+,?\s*)*)\)\s+as\s+(?P<type_name>[\w:]+)`)
30-
argsReg = regexp.MustCompile(`(\w+)=([0-9\.]+)`)
29+
genReg = regexp.MustCompile(`(?P<func_name>\w+)\((?P<args>(?:\w+=-?[0-9\.]+,?\s*)*)\)\s+as\s+(?P<type_name>[\w:]+)`)
30+
argsReg = regexp.MustCompile(`(\w+)=(-?[0-9\.]+)`)
3131
)
3232

3333
// ParseDef parses generator function definitions from a string format.

datamodel/noise/parser_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ func TestParseDef(t *testing.T) {
4949
},
5050
err: "",
5151
},
52+
{
53+
in: "foo(a=-1) as int",
54+
exp: &Func{
55+
Name: "foo",
56+
Args: map[string]float64{"a": -1},
57+
Type: "int",
58+
},
59+
err: "",
60+
},
5261
{
5362
in: "foo(a=bar) as int",
5463
exp: nil,

0 commit comments

Comments
 (0)