Values
Types define the representation of information
and values the concrete instances. For example, 42
would be an instance of
type count
and 1.2.3.4
an instance of type addr
. Every value is optional
and may be nil
. For a given type, nil
is always a valid value, but it is
impossible to deduce a type from the nil
literal.
VAST uses a recursive descent approach to parse a value, using an LL(k) grammar for a unique and predictable representation of values.
Parsers
Each type has an associated value with corresponding parser. This section explains valid input for the parser of that type.
bool
The bool
type defines exactly two valid inputs, T
for true and F
for
false.
Input | Semantics |
---|---|
T | true |
F | false |
int
The int
type is 64-bit signed integer. It requires a sign in order to
distinguish it from a count
.
Input | Semantics |
---|---|
-4 | negative value |
+0 | zero |
+7 | positive value |
count
The count
type is 64-bit unsigned integer to represent "things that can be
counted."
Input | Semantics |
---|---|
0 | zero |
42 | positive value |
real
The real
type is a IEE754 double-precision floating point value.
Input | Semantics |
---|---|
-4.2 | negative value |
0.0 | zero |
3.1415 | positive value |
Scientific notation is currently not supported.
duration
The duration
type is a nanosecond-precision time span to represent negative
or positive time deltas. The parser accepts input of the form [sign]
number
unit
.
Input | Semantics |
---|---|
-3ns | 3 nanoseconds backward |
4 secs | 4 seconds forward |
+10 h | 10 hours forward |
The table lists valid suffixes an their corresponding units.
Suffix | Unit |
---|---|
ns , nsec , nsecs , nanoseconds | nanoseconds |
us , usec , usecs , microseconds | microseconds |
ms , msec , msecs , milliseconds | milliseconds |
s , sec , secs , seconds | seconds |
m , min , mins , minutes | minutes |
h , hour , hrs , hours | hours |
d , day , days | days (24 hours) |
w , week , weeks | weeks (24 * 7 hours) |
time
The time
type represents a specific point in time. Unless explicitly
specified, all time values are interpreted as UTC timestamps.
Input | Semantics |
---|---|
now | The current system time |
in 10s | now plus 10 seconds |
5m ago | now minus 5 minutes |
@1588520865 | UNIX timestamp (seconds since the UNIX epoch) |
@1588520865.123 | fractional UNIX timestamp |
2020-03-15 | 2020-03-15 at 00:00:00 UTC |
2020-03-15+03 | 2020-03-15 at 03:00:00 UTC |
2020-03-15T13 | As above, different time divider |
2020-03-15+03:24 | 2020-03-15 at 03:24:00 UTC |
2020-03-15+03:24:59 | 2020-03-15 at 03:24:59 UTC |
2020-03-15+03:24:59Z | 2020-03-15 at 03:24:59 UTC |
2020-03-15+03:24:59-8 | 2020-03-15 at 03:24:59 UTC-8 |
2020-03-15+03:24:59+3 | 2020-03-15 at 03:24:59 UTC+3 |
string
The string
type represents a sequence of characters.
Input | Semantics |
---|---|
"" | The empty string |
"foo" | The string foo |
"\"" | A string containing an escaped double quote (" ) |
"\x2a" | An escaped byte 0x2a in a string |
note
VAST currently supports only ASCII strings. Unicode support is on our roadmap.
pattern
The pattern
type represents a regular expression.
Input | Semantics |
---|---|
/./ | A regex that matches a single character |
/a*b+c/ | A regex with quantifiers |
addr
The addr
type represents an IPv4 or IPv6 address. VAST uses the IPv4-mapped
IPv6 address
representation, where the first 80 bits are zero, followed by 16 one-bits, and
then last 32 bits containing the IPv4 address.
Input | Semantics |
---|---|
0.0.0.0 | The non-routable invalid IPv4 address |
8.8.8.8 | The IPv4 address of a well-known DNS server |
::1 | The IPv6 loopback address |
2001:db8:: | A dummy IPv6 address used for documentation |
subnet
The subnet
type represents a CIDR-style definition of groups of IP addresses.
The parser accepts input of the form addr
/
prefix
, where valid prefix
are in the range [0,128].
Input | Semantics |
---|---|
10.0.0.0/8 | A private class A network |
::1/128 | IPv6 loopback address with a single address |
2001:db8::/32 | 2^96 addresses for documentation purposes |
Containers
There exist two containers types: list<T>
for an ordered list of elements, and
map<T, U>
as associative array.
In the following, x
, y
, and z
, are a instances of type T
and a
, b
,
and c
instances of type U
.
Type | Value |
---|---|
list<T> | [x, y, z] , [] |
map<T, U> | {x -> a, y -> b, z -> c} , {} |
Type inference for container instances is tricky, because it's impossible to
infer the element type from an empty container, or from a container that
contains nil
elements. Ther
note
The current implementation for container types is not yet complete: map<T, U>
is not indexable or queryable, and list
only works efficiently for
low-cardinality instances.
SI Literals
To simplify expression of large integer values, VAST supports literals with
suffixes according to the International System of Units
(SI). These
suffixes apply to type int
and count
:
Suffix | 10^X | Value |
---|---|---|
k | 3 | 1 000 |
M | 6 | 1 000 000 |
G | 9 | 1 000 000 000 |
T | 12 | 1 000 000 000 000 |
P | 15 | 1 000 000 000 000 000 |
E | 18 | 1 000 000 000 000 000 000 |
For example, 42k
is equal to 42000
, and -9G
equal to -9000000000
.
In addition to expressing numbers to the power of 10, there exists a parallel array of suffixes for expressing numbers with base 2 to represent bytes:
Suffix | 2^X | Value |
---|---|---|
Ki | 10 | 1 024 |
Mi | 20 | 1 048 576 |
Gi | 30 | 1 073 741 824 |
Ti | 40 | 1 099 511 627 776 |
Pi | 50 | 1 125 899 906 842 624 |
Ei | 60 | 1 152 921 504 606 846 976 |
For example, 8Ki
is equal to 8192
, and 64Mi
equal to 67108864
.
note
We purposefully chose
IEC-style
binary suffixes that end
in i
to avoid ambiguities of frequent abbreviations, such as "64K", which
colloquially means "64 kilo bytes" to the power of 2 but resembles more the
suffix for a value to the power of 10.