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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//! Reading an entry's `= "…"` value as the thing it names.
//!
//! Every typed option in this grammar is written as a STRING and re-parsed: `crate = "a::b"` into a
//! [`syn::Path`], `rename = "Name"` into a [`syn::Ident`]. Going through a literal is what keeps a
//! raw identifier spellable, and re-parsing is what makes a value that cannot BE the thing a
//! refusal here rather than a failure somewhere downstream in an expansion.
//!
//! The two were separate functions before this layer existed. They differ only in the type asked
//! for and the sentence used when the answer is no.
//!
//! Part of the layer every `ingraph` derive parses on; `Record` is its first consumer.
/// An entry's `= "…"` value, as the string literal itself.
///
/// For the values that are NOT Rust: a column name, a table name, a schema. Those reach a
/// `CREATE TABLE` verbatim rather than through an ident, so there is nothing here to re-parse —
/// whether a store can HOLD the name is a separate question, answered by `column` once the value has
/// been read. The LITERAL rather than its contents, because it carries the span a refusal about the
/// name reports at.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, or a non-string.
pub
/// An entry's `= "…"` value, taken as a string literal and re-parsed as `T`.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, a non-string, or a string
/// that is not a `T`.
pub
/// A string literal read as the RUST FIELD NAME it holds, tolerating a name rustc reserves.
///
/// # A field legally called `r#type` has to be nameable
///
/// The string-kind schema-words law says a Rust KEYWORD is an ordinary schema name — that is why a
/// column's `rename` is carried as a literal and never parsed. This is the other side of the same
/// law: the positions that name a field of somebody's struct must be able to name a field that IS
/// a keyword, and [`parse_literal`] cannot, because `syn`'s `Ident` parser refuses `type` exactly
/// as rustc's grammar does.
///
/// So BOTH spellings are the field. `"type"` is the word an author reaches for, because it is what
/// the schema and the database call the column; `"r#type"` is what the declaring struct had to
/// write to name it in Rust. Neither is a different field from the other, and both are read as the
/// RAW identifier — which is what the emission has to spell, `type` being unwritable bare.
///
/// The FENCE is unchanged: what is not an identifier under either spelling is still refused, with
/// the caller's own sentence and at the literal's own span.
///
/// It takes the LITERAL rather than the entry, unlike [`parse_literal`]: the positions that read a
/// field name read the string first, because a value that is not a string at all earns the
/// position's own shape sentence before this reader is asked anything.
///
/// # Errors
/// `refusal`, spanned at the literal, when it names no field under either spelling.
pub
/// An entry's `= "…"` value, or the `= ["…", "…"]` list of them, as the string literals themselves.
///
/// The ONE-OR-SEVERAL shape, for a word whose subject is a list that is usually one long: `emits =
/// "…"` and `emits = ["…", "…"]` are the same declaration at two arities, and a grammar that made
/// the singular spell a one-element list would be asking most declarations to write punctuation for
/// a plural they do not have.
///
/// The literals rather than their contents, for [`literal`]'s reason — and per ELEMENT, so a list
/// whose third entry is unreadable refuses at the third entry.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, a non-string, or a list
/// element that is not a string.
pub
/// An entry's `= N` value, as the integer literal itself.
///
/// The one value in this grammar written BARE, and the rule above is why rather than an exception to
/// it: what the strings buy is a raw identifier and a re-parse into Rust, and a COUNT is neither —
/// `depth = "16"` would be a number spelled as text so that it could be turned back into a number.
/// The literal rather than its value, because it carries the span a refusal about the count reports
/// at and because how wide a count may be is the caller's question.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, or a non-integer.
pub
/// An entry's `= 1.0` value, as the decimal literal itself.
///
/// BARE for [`integer`]'s reason, and a DECIMAL rather than a count because what it reads is a
/// RATIO — a coefficient in a fold, not a number of rows. `1` is refused with the position's own
/// sentence rather than widened into `1.0`: two spellings of one value would be two shapes every
/// later reader has to remember, and the correction is one keystroke.
///
/// A NEGATIVE one IS read, and that is measured rather than assumed: syn parses a leading minus as
/// part of the literal in value position, so `-1.0` arrives here as a `LitFloat` whose
/// `base10_parse` answers `-1.0`. Whether a negative is legal is therefore the caller's rule and
/// never this reader's silence.
///
/// The literal rather than its value, because it carries the span a refusal about the ratio reports
/// at, and because WHICH ratios are legal is the caller's question.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, or one that is not a decimal
/// literal.
pub
/// An entry's `= true` / `= false` value, as the boolean literal itself.
///
/// BARE for [`integer`]'s reason, one type over: what a string literal buys is a raw identifier and
/// a re-parse into Rust, and a FLAG is neither — `rrf = "false"` would be a boolean spelled as text
/// so that it could be turned back into a boolean, and a typo in it would be a string nobody checks.
///
/// The literal rather than its value, because it carries the span a refusal about the flag reports
/// at.
///
/// # Errors
/// `refusal`, spanned at whatever could not be read — a missing value, or a non-boolean.
pub