Commit 05588d8
Replace 'import' with 'from ... import type1, type2, ...' syntax (#457)
* Replace 'import' syntax with 'from ... import type1, type2, ...'
The old 'import module' statement is replaced by explicit per-type imports:
from module.path [<annots>] [as alias] import type1 [<annots>], type2, ...
Key changes:
- New AST node 'imported_type' carries name, arity params, and per-type annot
- 'import.alias' is now 'string option' (no annotation on alias)
- Two-phase validation: Imports.load checks structure; check_type_refs
validates all qualified type refs (a.b) against the explicit import list
and checks arity
- New 'Imported_type' annotation position (node_kind)
- atdgen: fatal error if any import statements are present, pointing to atdml
- atdpy: auto-escape Python keywords in module alias names (e.g. class -> class_)
- All backends updated; all test ATD files converted to new syntax
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Update documentation and changelog for 'from ... import' syntax
- CHANGES.md: replace the old import entry with the new from...import entry
- atd-language-reference.rst: update keywords list, grammar, and the
Import declarations section to describe the new syntax
- atdml-reference.rst: rewrite Import declarations section
- atdts.rst: rewrite Import declarations section
- atdpy.rst: rewrite Import annotations section including auto-escaping
of Python keywords in alias names
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 4d2be5d commit 05588d8
File tree
33 files changed
+448
-250
lines changed- atdcat/test
- atdgen/src
- atdml
- src/lib
- tests
- atdpy
- src/lib
- test/atd-input
- atdts
- src/lib
- test/gen-expect-tests
- atd/src
- doc
33 files changed
+448
-250
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 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 | + | |
50 | 59 | | |
51 | 60 | | |
52 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| 186 | + | |
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
| |||
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| 213 | + | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| |||
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| |||
128 | 136 | | |
129 | 137 | | |
130 | 138 | | |
131 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
| |||
204 | 214 | | |
205 | 215 | | |
206 | 216 | | |
| 217 | + | |
207 | 218 | | |
208 | 219 | | |
209 | 220 | | |
| |||
251 | 262 | | |
252 | 263 | | |
253 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
254 | 268 | | |
255 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
256 | 272 | | |
257 | 273 | | |
258 | 274 | | |
| |||
268 | 284 | | |
269 | 285 | | |
270 | 286 | | |
| 287 | + | |
271 | 288 | | |
272 | 289 | | |
273 | 290 | | |
| |||
277 | 294 | | |
278 | 295 | | |
279 | 296 | | |
| 297 | + | |
280 | 298 | | |
281 | 299 | | |
282 | 300 | | |
| |||
287 | 305 | | |
288 | 306 | | |
289 | 307 | | |
| 308 | + | |
290 | 309 | | |
291 | 310 | | |
292 | 311 | | |
| |||
298 | 317 | | |
299 | 318 | | |
300 | 319 | | |
| 320 | + | |
301 | 321 | | |
302 | 322 | | |
303 | 323 | | |
| |||
318 | 338 | | |
319 | 339 | | |
320 | 340 | | |
| 341 | + | |
321 | 342 | | |
322 | 343 | | |
323 | 344 | | |
| |||
521 | 542 | | |
522 | 543 | | |
523 | 544 | | |
524 | | - | |
| 545 | + | |
525 | 546 | | |
526 | 547 | | |
527 | 548 | | |
528 | 549 | | |
529 | | - | |
| 550 | + | |
530 | 551 | | |
531 | 552 | | |
532 | 553 | | |
533 | 554 | | |
| 555 | + | |
534 | 556 | | |
535 | 557 | | |
536 | | - | |
| 558 | + | |
537 | 559 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 41 | + | |
45 | 42 | | |
46 | | - | |
| 43 | + | |
47 | 44 | | |
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
52 | | - | |
| 49 | + | |
53 | 50 | | |
54 | 51 | | |
55 | 52 | | |
56 | 53 | | |
57 | | - | |
| 54 | + | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
61 | | - | |
| 58 | + | |
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
68 | 81 | | |
69 | 82 | | |
70 | 83 | | |
| |||
197 | 210 | | |
198 | 211 | | |
199 | 212 | | |
| 213 | + | |
200 | 214 | | |
201 | 215 | | |
202 | 216 | | |
| |||
212 | 226 | | |
213 | 227 | | |
214 | 228 | | |
215 | | - | |
| 229 | + | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
| 281 | + | |
266 | 282 | | |
267 | 283 | | |
268 | 284 | | |
| |||
297 | 313 | | |
298 | 314 | | |
299 | 315 | | |
| 316 | + | |
300 | 317 | | |
301 | 318 | | |
302 | 319 | | |
| |||
320 | 337 | | |
321 | 338 | | |
322 | 339 | | |
323 | | - | |
| 340 | + | |
324 | 341 | | |
325 | 342 | | |
326 | 343 | | |
| |||
0 commit comments