Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 46 additions & 33 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,52 +446,65 @@ encoded as a little-endian unsigned 8-bit integer, the
following options would be included after the element.

```language-fql
3548[u8,le]
3548[u8]
```

Similarly, if a variable should only match against
a big-endian 32-bit floats then the following options would
be included after the `num` type.
big-endian 32-bit floats then the following options would be
included after the `num` type.

```language-fql
<num[f32,be]>
```

### Element Options
### Value Encoding

The tables below show which options are supported for the
`int` and `num` types when used as values. These options
control how the data is serialized and unserialized.
The table below shows options for the `int` and `num` types.
These options control how data is [encoded](#data-encoding)
as a value.

<div>

| Int Option | Description |
|:-----------|:----------------|
| `be` | Big endian |
| `le` | Little endian |
| `u8` | Unsigned 8-bit |
| `u16` | Unsigned 16-bit |
| `u32` | Unsigned 32-bit |
| `u64` | Unsigned 64-bit |
| `i8` | Signed 8-bit |
| `i16` | Signed 16-bit |
| `i32` | Signed 32-bit |
| `i64` | Signed 64-bit |
| Value Option | Argument | Description |
|:-------------|:---------|:---------------------------------------|
| `width` | `int` | Bit width: `8`, `16`, `32`, `64`, `80` |
| `bigendian` | none | Use big endian encoding |
| `unsigned` | none | Use unsigned encoding |

</div>

Options are one of the more verbose parts of FQL. To avoid
obscuring the structure of a query, `int` and `num` options
are given shorter aliases.

<div>

| Int Alias Option | Actual Option |
|:-------------------|:--------------------|
| `be` | `bigendian` |
| `i8` | `width:8` |
| `i16` | `width:16` |
| `i32` | `width:32` |
| `i64` | `width:64` |
| `u8` | `unsigned,width:8` |
| `u16` | `unsigned,width:16` |
| `u32` | `unsigned,width:32` |
| `u64` | `unsigned,width:64` |

</div>

<div>

| Num Option | Description |
|:-----------|:--------------|
| `be` | Big endian |
| `le` | Little endian |
| `f32` | 32-bit |
| `f64` | 64-bit |
| `f80` | 80-bit |
| Num Alias Option | Actual Option |
|:-------------------|:--------------------|
| `be` | `bigendian` |
| `f32` | `width:32` |
| `f64` | `width:64` |
| `f80` | `width:80` |

</div>

### Query Options
### Queries

Query options are specified on the line before the query.
For instance, to specify that a range-read query should read
Expand All @@ -509,12 +522,12 @@ specify the option's behavior.

<div>

| Query Option | Argument | Description |
|:-------------|:---------|:-----------------------------------|
| `reverse` | none | Range read in reverse order |
| `limit` | int | Maximum number of results |
| `mode` | name | Range read mode: want_all, iterator, exact, small, medium, large, serial |
| `snapshot` | none | Use snapshot read |
| Query Option | Argument | Description |
|:-------------|:---------|:-----------------------------------------|
| `reverse` | none | Range read in reverse order |
| `limit` | `int` | Maximum number of results |
| `mode` | name | Range read mode: `want_all`, `iterator`, `exact`, `small`, `medium`, `large`, `serial` |
| `snapshot` | none | Use snapshot read |
| `strict` | none | Error when a read key-values doesn't conform to the schema |

</div>
Expand Down
48 changes: 23 additions & 25 deletions docs/js/fql.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,7 @@
/\d*/,
/e?/,
/\d*/,
],
beginScope: {
1: 'accent',
2: 'number',
3: 'accent',
4: 'number',
5: 'accent',
6: 'number',
},
};

const BLEN = {
begin: [
/-?/,
/\d+/,
/\.?/,
/\d*/,
/e?/,
/\d*/,
/kb/,
/(kb|mb|gb)?/, // allow a byte-unit to appear after numbers.
],
beginScope: {
1: 'accent',
Expand Down Expand Up @@ -143,7 +124,6 @@
'max',
'count',
'be',
'le',
'i8',
'i16',
'i32',
Expand All @@ -155,9 +135,19 @@
'f32',
'f64',
'f80',
'bigendian',
'width',
'unsigned',
'reverse',
'limit',
'mode',
'want_all',
'iterator',
'exact',
'small',
'medium',
'large',
'serial',
'snapshot',
'strict',
'rand',
Expand All @@ -173,7 +163,6 @@
$$pattern: /[^,:]+/,
keyword: [
'be',
'le',
'i8',
'i16',
'i32',
Expand All @@ -185,6 +174,9 @@
'f32',
'f64',
'f80',
'endian',
'width',
'unsigned',
'reverse',
'limit',
'mode',
Expand All @@ -207,6 +199,14 @@
],
};

const INLINEOPT = {
scope: 'options',
begin: /(?=\b(?:width|unsigned)\b)/,
end: /(?=\s|$)/,
keywords: OPTIONS.keywords,
contains: OPTIONS.contains,
};

const VARIABLE = {
scope: 'variable',
begin: /</,
Expand Down Expand Up @@ -273,7 +273,6 @@
UUID,
VSTAMP,
BYTES,
BLEN,
NUMBER,
OPTIONS,
],
Expand All @@ -292,7 +291,6 @@
UUID,
VSTAMP,
BYTES,
BLEN,
NUMBER,
OPTIONS,
],
Expand All @@ -315,12 +313,12 @@
VALUE,
VARIABLE,
MAYBEMORE,
INLINEOPT,
KEYWORD,
STRING,
UUID,
VSTAMP,
BYTES,
BLEN,
NUMBER,
OPTIONS,
{ // Highlight lone bar & semicolon for inline text.
Expand Down