parser

A program or compiler phase that reads text and builds a structured form from it, such as a syntax tree or a typed object.

In more detail

Inside a compiler, the parser turns tokens into an abstract syntax tree. The same word is used for code that reads external data, such as JSON.parse turning text into a value. Parsing untrusted data also means checking it and rejecting anything that does not fit the expected shape.

Example

function parseWebhook(raw: unknown): WebhookEvent turns unknown input into a trusted type or throws

Related terms

Taught in

References