spicy
spicy copied to clipboard
Stop seems to be broken
I cannot seem to get to stop work as expected, e.g.,
# foo.spicy
module foo;
public type X = unit {
xs: uint8[] foreach {
print self.xs, $$;
if ($$==0) {
print "Stopping";
stop;
}
}
};
$ printf '\x01\x02\x00\x01\x02' | spicy-driver -d %
[], 1
[1], 2
[1, 2], 0
Stopping
[1, 2], 1
[1, 2, 1], 2
In this example I would have expected self.xs == vector(1, 2), and no further output after Stopping.
A workaround seems to be to use vector parsing &until to track whether to stop parsing,
module foo;
public type X = unit {
var xs_done: bool = False;
xs: uint8[] &until=self.xs_done foreach {
print self.xs, $$;
if ($$==0) {
print "Stopping";
self.xs_done = True;
}
}
};
$ printf '\x01\x02\x00\x01\x02' | spicy-driver -d %
[], 1
[1], 2
[1, 2], 0
Stopping