-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.typ
73 lines (57 loc) · 2.49 KB
/
spec.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import "@preview/ctheorems:1.1.3"
#import "common.typ": *
#show: ctheorems.thmrules
#set heading(numbering: "1.1")
#let title = [A formal specification of the jq language]
#set document(title: title)
#text(size: 20pt, weight: "bold", title)
#set raw(lang: "jq")
= Introduction
`jq` is a tool that provides a programming language
to efficiently process JSON data.
We call this programming language the "jq language".
This text aims to give a precise, mathematical description of the jq language, similar to
the "WebAssembly Core Specification" for WebAssembly @WebAssemblyCoreSpecification2.
It is intended to complement the user manual @jq-manual.
In some places, the behaviour described in this text diverges from `jq`.
We try to point out such differing behaviour whenever it occurs.
The first and foremost goal of this text is to allow users to
_precisely predict what their jq programs will output_.
On the other hand, this text does not try to describe how
to implement a performant interpreter for the jq language --- the focus is not
on _how_ a jq interpreter executes a jq program, but
on _what_ a jq program outputs.
This differentiates this text from the jq language description @jq-description,
which draws much stronger on the implementation of `jq` to describe the jq language.
This text does not cover all parts of the jq language;
in particular, it does not cover the module system.
However, most of the programs that use features not covered by this specification
can be translated into programs that are completely covered by this specification.
For example, a program made of several modules can be
transformed into a program that does not use modules.
/*
Note that this text only aims to specify
the behaviour of jq filters that have special syntax, such as `|`;
it does not attempt to specify
the behaviour of particular named filters, such as `reverse`.
*/
This text is structured as follows:
@tour gives an introduction to the jq language.
@syntax specifies the syntax treated in this text and transforms it to a simpler subset.
@values defines values.
@semantics defines the output of jq programs, and
@updates defines the output of jq updates.
In the appendix,
@json defines JSON values as well as some operations on them used in jq.
#include "tour.typ"
#include "syntax.typ"
#include "values.typ"
#include "semantics.typ"
#let appendix(body) = {
set heading(numbering: "A.1", supplement: [Appendix])
counter(heading).update(0)
body
}
#show: appendix
#include "json.typ"
#bibliography("literature.bib")