# Debug Submodule

## Enumerations

| Name                                  | Description                                         |
| ------------------------------------- | --------------------------------------------------- |
| [`TokenPrintFlags`](#tokenprintflags) | Bitmask controlling which token fields are printed. |

***

### TokenPrintFlags

```cpp
enum TokenPrintFlags
```

Defined in include/rocky/debug.h:15

Bitmask controlling which token fields are printed.

| Value                   | Description |
| ----------------------- | ----------- |
| `TOK_PRINT_FLAG_KIND`   |             |
| `TOK_PRINT_FLAG_LEXEME` |             |
| `TOK_PRINT_FLAG_LINE`   |             |
| `TOK_PRINT_FLAG_COL`    |             |
| `TOK_PRINT_ALL`         |             |

## Functions

| Return         | Name                                               | Description                                                   |
| -------------- | -------------------------------------------------- | ------------------------------------------------------------- |
| `const char *` | [`token_type_str`](#token_type_str)                | Converts token kind to display string.                        |
| `const char *` | [`unary_op_str`](#unary_op_str)                    | Converts unary operator to display string.                    |
| `const char *` | [`datatype_str`](#datatype_str)                    | Converts type kind to display string.                         |
| `const char *` | [`binary_op_str`](#binary_op_str)                  | Converts binary operator to display string.                   |
| `void`         | [`print_token`](#print_token)                      | Prints token diagnostics.                                     |
| `void`         | [`print_expr`](#print_expr)                        | Prints an expression tree using ASCII connectors.             |
| `const char *` | [`stmt_kind_str`](#stmt_kind_str)                  | Converts a statement kind to a human-readable display string. |
| `void`         | [`print_stmt`](#print_stmt)                        | Prints a statement tree using ASCII connectors.               |
| `int`          | [`use_color`](#use_color) `static`                 |                                                               |
| `void`         | [`print_tree_prefix`](#print_tree_prefix) `static` |                                                               |
| `void`         | [`print_type_expr`](#print_type_expr) `static`     |                                                               |
| `void`         | [`print_children`](#print_children)                | Recursively prints a list of child expressions in tree form.  |
| `void`         | [`print_stmt_child`](#print_stmt_child) `static`   |                                                               |
| `void`         | [`print_expr_child`](#print_expr_child) `static`   |                                                               |
| `void`         | [`print_stmt_node`](#print_stmt_node) `static`     |                                                               |

***

### token\_type\_str

```cpp
const char * token_type_str(TokenKind type)
```

Defined in include/rocky/debug.h:24

Converts token kind to display string.

Converts token kind to display string.

Converts token kind to display string.

Converts token kind to display string.

***

### unary\_op\_str

```cpp
const char * unary_op_str(UnaryOp op)
```

Defined in include/rocky/debug.h:27

Converts unary operator to display string.

Converts unary operator to display string.

Converts unary operator to display string.

Converts unary operator to display string.

***

### datatype\_str

```cpp
const char * datatype_str(TypeKind t)
```

Defined in include/rocky/debug.h:30

Converts type kind to display string.

Converts type kind to display string.

Converts type kind to display string.

Converts type kind to display string.

***

### binary\_op\_str

```cpp
const char * binary_op_str(BinaryOp op)
```

Defined in include/rocky/debug.h:33

Converts binary operator to display string.

Converts binary operator to display string.

Converts binary operator to display string.

Converts binary operator to display string.

***

### print\_token

```cpp
void print_token(Token * token, TokenPrintFlags flags)
```

Defined in include/rocky/debug.h:40

Prints token diagnostics.

Prints token diagnostics.

Prints token diagnostics.

Prints token diagnostics.

#### Parameters

| Parameter | Type                                        | Description                     |
| --------- | ------------------------------------------- | ------------------------------- |
| `token`   | [`Token`](api.md#token) \*                  | [Token](api.md#token) to print. |
| `flags`   | [`TokenPrintFlags`](api.md#tokenprintflags) | Print-field bitmask.            |

***

### stmt\_kind\_str

```cpp
const char * stmt_kind_str(StmtKind kind)
```

Defined in include/rocky/debug.h:52

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

***

### use\_color

`static`

```cpp
static int use_color(void)
```

Defined in src/debug.c:26

***

### datatype\_str

```cpp
const char * datatype_str(TypeKind t)
```

Defined in src/debug.c:189

Converts type kind to display string.

Converts type kind to display string.

Converts type kind to display string.

Converts type kind to display string.

***

### stmt\_kind\_str

```cpp
const char * stmt_kind_str(StmtKind kind)
```

Defined in src/debug.c:258

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

Converts a statement kind to a human-readable display string.

***

### print\_tree\_prefix

`static`

```cpp
static void print_tree_prefix(int depth, int is_last, int sibling)
```

Defined in src/debug.c:287

***

### print\_type\_expr

`static`

```cpp
static void print_type_expr(const TypeExpr * type)
```

Defined in src/debug.c:296

***

### print\_children

```cpp
void print_children(const Expr ** children, int count, int depth, int sibling)
```

Defined in src/debug.c:347

Recursively prints a list of child expressions in tree form.

***

### print\_stmt\_child

`static`

```cpp
static void print_stmt_child(const Stmt * stmt, int depth, int is_last, int sibling)
```

Defined in src/debug.c:416

***

### print\_expr\_child

`static`

```cpp
static void print_expr_child(const Expr * expr, int depth, int is_last, int sibling)
```

Defined in src/debug.c:420

***

### print\_stmt\_node

`static`

```cpp
static void print_stmt_node(const Stmt * stmt, int depth, int is_last, int sibling)
```

Defined in src/debug.c:424
