# gizlang:jslex

```gizlang
import * as Jslex from "gizlang:jslex";
```

## Types

### `JsToken`

```gizlang
type JsToken = { k: i64; s: i64; e: i64; line: i64; nl: bool; tail: bool; }
```

A token: its kind K (JS_*), its bytes S to E, its LINE, whether a line break comes before it (NL), and for a
template part whether it ends the template (TAIL).

- `k`: `i64`
- `s`: `i64`
- `e`: `i64`
- `line`: `i64`
- `nl`: `bool`
- `tail`: `bool`

### `JsTokens`

```gizlang
type JsTokens = { tokens: Vec<JsToken>; error: string; errorLine: i64; }
```

The tokens of a source, ending with JS_EOF, and its first error ("" for none) with its line.

- `tokens`: `Vec<gizlang_jslex.JsToken>`
- `error`: `string`
- `errorLine`: `i64`

## Functions

### `jsTokens`

```gizlang
function jsTokens(src: bytes): JsTokens
```

The tokens of JavaScript source SRC, in order, ending with JS_EOF. The bytes between two tokens are white space and
comments only: a reader of comments (a minifier that keeps license comments) finds them there. It reads strings, templates
(`${ }` nests), regular expressions and comments as JavaScript does; it stops at the first error, so the tokens then
end there with no JS_EOF.

Effects: fail.

## Constants

### `JS_EOF`

```gizlang
const JS_EOF = 0
```

A token kind: the end of the source (its bytes are empty).

### `JS_NAME`

```gizlang
const JS_NAME = 1
```

A token kind: a name or a keyword.

### `JS_NUM`

```gizlang
const JS_NUM = 2
```

A token kind: a number.

### `JS_STR`

```gizlang
const JS_STR = 3
```

A token kind: a string literal, quotes included.

### `JS_PUNCT`

```gizlang
const JS_PUNCT = 4
```

A token kind: a punctuator.

### `JS_TEMPLATE`

```gizlang
const JS_TEMPLATE = 5
```

A token kind: a template part: from ` or } to ${ or `.

### `JS_REGEX`

```gizlang
const JS_REGEX = 6
```

A token kind: a regular expression literal with its flags.

### `JS_PRIVATE`

```gizlang
const JS_PRIVATE = 7
```

A token kind: a private name (#x).

