# _types

URL: /kida/api/_types/
Section: api
Description: Core types for Kida template engine.

Defines the fundamental types used throughout the Kida pipeline:

Types:
- `Token`: Single lexer output unit with type, value, and location
- `TokenType`: Enum classifying token types (operators, literals, etc.)

Constants:
- `KEYWORDS`: Frozenset of reserved words recognized by parser
- `PRECEDENCE`: Dict mapping token types to operator precedence

Thread-Safety:
All types are immutable (frozen dataclasses, enums) for safe
concurrent access during template compilation.

Token Categories:
- **Delimiters**: `BLOCK_BEGIN`, `VARIABLE_BEGIN`, etc.
- **Literals**: `STRING`, `INTEGER`, `FLOAT`
- **Identifiers**: `NAME` (variables, keywords)
- **Operators**: `ADD`, `SUB`, `MUL`, `EQ`, `AND`, etc.
- **Punctuation**: `DOT`, `COMMA`, `PIPE`, `LPAREN`, etc.
- **Special**: `EOF`, `DATA` (raw text)

Example:
    >>> from kida._types import Token, TokenType
    >>> token = Token(TokenType.NAME, "user", lineno=1, col_offset=5)
    >>> token.type == TokenType.NAME
True
    >>> token.value
    'user'

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/_types/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2F_types%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2F_types%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2F_types%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2F_types%2Findex.txt)

Module

#
`_types`

Core types for Kida template engine.

Defines the fundamental types used throughout the Kida pipeline:

Types:

- `Token`: Single lexer output unit with type, value, and location

- `TokenType`: Enum classifying token types (operators, literals, etc.)

Constants:

- `KEYWORDS`: Frozenset of reserved words recognized by parser

- `PRECEDENCE`: Dict mapping token types to operator precedence

Thread-Safety:
All types are immutable (frozen dataclasses, enums) for safe
concurrent access during template compilation.

Token Categories:

- Delimiters:`BLOCK_BEGIN`, `VARIABLE_BEGIN`, etc.

- Literals:`STRING`, `INTEGER`, `FLOAT`

- Identifiers:`NAME`(variables, keywords)

- Operators:`ADD`, `SUB`, `MUL`, `EQ`, `AND`, etc.

- Punctuation:`DOT`, `COMMA`, `PIPE`, `LPAREN`, etc.

- Special:`EOF`, `DATA`(raw text)

Example:

```
>>> from kida._types import Token, TokenType
>>> token = Token(TokenType.NAME, "user", lineno=1, col_offset=5)
>>> token.type == TokenType.NAME
```

True
>>> token.value
'user'

2Classes

## Classes

`TokenType`

1

▼

Classification of lexer tokens.

Categories:
- Delimiters: Block, variable, comment markers
…

Classification of lexer tokens.

Categories:

- Delimiters: Block, variable, comment markers

- Literals: Strings, numbers, booleans

- Identifiers: Names, keywords

- Operators: Arithmetic, comparison, logical

- Punctuation: Parentheses, brackets, dots

- Special: EOF, whitespace, data (raw text)

#### Methods

`display_name`

0

`str`

▼

Human-readable token name for error messages.

property

`def display_name(self) -> str`

##### Returns

`str`

`Token`

5

▼

A single token from the lexer.

A single token from the lexer.

#### Attributes

Name
Type
Description

`type`

`TokenType`

Classification of this token

`value`

`str`

The actual text/value of the token

`lineno`

`int`

1-based line number in source

`col_offset`

`int`

0-based column offset in source Immutable by design for thread-safety.

#### Methods

Internal Methods
1

▼

`__repr__`

0

`str`

▼

`def __repr__(self) -> str`

##### Returns

`str`
