@@ -15,22 +15,22 @@ The latest released version is [`3.0.0`][release].
15
15
16
16
## Contents
17
17
18
- * [ Intro] ( #intro )
19
- * [ Syntax tree] ( #syntax-tree )
20
- * [ Where this specification fits] ( #where-this-specification-fits )
21
- * [ Types] ( #types )
22
- * [ Nodes] ( #nodes )
23
- * [ ` Node ` ] ( #node )
24
- * [ ` Parent ` ] ( #parent )
25
- * [ ` Literal ` ] ( #literal )
26
- * [ Glossary] ( #glossary )
27
- * [ Tree traversal] ( #tree-traversal )
28
- * [ Utilities] ( #utilities )
29
- * [ List of utilities] ( #list-of-utilities )
30
- * [ References] ( #references )
31
- * [ Contribute] ( #contribute )
32
- * [ Acknowledgments] ( #acknowledgments )
33
- * [ License] ( #license )
18
+ * [ Intro] ( #intro )
19
+ * [ Syntax tree] ( #syntax-tree )
20
+ * [ Where this specification fits] ( #where-this-specification-fits )
21
+ * [ Types] ( #types )
22
+ * [ Nodes] ( #nodes )
23
+ * [ ` Node ` ] ( #node )
24
+ * [ ` Parent ` ] ( #parent )
25
+ * [ ` Literal ` ] ( #literal )
26
+ * [ Glossary] ( #glossary )
27
+ * [ Tree traversal] ( #tree-traversal )
28
+ * [ Utilities] ( #utilities )
29
+ * [ List of utilities] ( #list-of-utilities )
30
+ * [ References] ( #references )
31
+ * [ Contribute] ( #contribute )
32
+ * [ Acknowledgments] ( #acknowledgments )
33
+ * [ License] ( #license )
34
34
35
35
## Intro
36
36
@@ -46,11 +46,11 @@ generate code.
46
46
47
47
Syntax trees [ come in two flavors] [ abstract-vs-concrete-trees ] :
48
48
49
- * ** concrete syntax trees** : structures that represent every detail (such as
50
- white-space in white-space insensitive languages)
51
- * ** abstract syntax trees** : structures that only represent details relating
52
- to the syntactic structure of code (such as ignoring whether a double or
53
- single quote was used in languages that support both, such as JavaScript).
49
+ * ** concrete syntax trees** : structures that represent every detail (such as
50
+ white-space in white-space insensitive languages)
51
+ * ** abstract syntax trees** : structures that only represent details relating
52
+ to the syntactic structure of code (such as ignoring whether a double or
53
+ single quote was used in languages that support both, such as JavaScript).
54
54
55
55
This specification can express both abstract and concrete syntax trees.
56
56
@@ -316,20 +316,20 @@ For example, see projects such as **[vfile][]**.
316
316
In ** preorder** (** NLR** ) is [ depth-first] [ traversal-depth ] [ tree
317
317
traversal] [ traversal ] that performs the following steps for each node * N* :
318
318
319
- 1 . ** N** : visit * N* itself
320
- 2 . ** L** : traverse * [ head] [ term-head ] * (then its * next sibling* , recursively
321
- moving forward until reaching * tail* )
322
- 3 . ** R** : traverse * [ tail] [ term-tail ] *
319
+ 1 . ** N** : visit * N* itself
320
+ 2 . ** L** : traverse * [ head] [ term-head ] * (then its * next sibling* , recursively
321
+ moving forward until reaching * tail* )
322
+ 3 . ** R** : traverse * [ tail] [ term-tail ] *
323
323
324
324
###### Postorder
325
325
326
326
In ** postorder** (** LRN** ) is [ depth-first] [ traversal-depth ] [ tree
327
327
traversal] [ traversal ] that performs the following steps for each node * N* :
328
328
329
- 1 . ** L** : traverse * [ head] [ term-head ] * (then its * next sibling* , recursively
330
- moving forward until reaching * tail* )
331
- 2 . ** R** : traverse * [ tail] [ term-tail ] *
332
- 3 . ** N** : visit * N* itself
329
+ 1 . ** L** : traverse * [ head] [ term-head ] * (then its * next sibling* , recursively
330
+ moving forward until reaching * tail* )
331
+ 2 . ** R** : traverse * [ tail] [ term-tail ] *
332
+ 3 . ** N** : visit * N* itself
333
333
334
334
###### Enter
335
335
@@ -387,9 +387,9 @@ For a given node *N* with *[children][term-child]*, a **depth-first traversal**
387
387
performs three steps, simplified to only binary trees (every node has
388
388
* [ head] [ term-head ] * and * [ tail] [ term-tail ] * , but no other children):
389
389
390
- * ** N** : visit * N* itself
391
- * ** L** : traverse * [ head] [ term-head ] *
392
- * ** R** : traverse * [ tail] [ term-tail ] *
390
+ * ** N** : visit * N* itself
391
+ * ** L** : traverse * [ head] [ term-head ] *
392
+ * ** R** : traverse * [ tail] [ term-tail ] *
393
393
394
394
These steps can be done in any order, but for non-binary trees, ** L** and ** R**
395
395
occur together.
@@ -420,95 +420,95 @@ sibling (**F**) is traversed and then finally its only child (**G**).
420
420
There are several projects that deal with nodes from specifications implementing
421
421
unist:
422
422
423
- * [ hast utilities] ( https://github.com/syntax-tree/hast#list-of-utilities )
424
- * [ mdast utilities] ( https://github.com/syntax-tree/mdast#list-of-utilities )
425
- * [ nlcst utilities] ( https://github.com/syntax-tree/nlcst#list-of-utilities )
426
- * [ xast utilities] ( https://github.com/syntax-tree/xast#list-of-utilities )
423
+ * [ hast utilities] ( https://github.com/syntax-tree/hast#list-of-utilities )
424
+ * [ mdast utilities] ( https://github.com/syntax-tree/mdast#list-of-utilities )
425
+ * [ nlcst utilities] ( https://github.com/syntax-tree/nlcst#list-of-utilities )
426
+ * [ xast utilities] ( https://github.com/syntax-tree/xast#list-of-utilities )
427
427
428
428
### List of utilities
429
429
430
- * [ ` unist-util-ancestor ` ] ( https://github.com/gorango/unist-util-ancestor )
431
- — get the common ancestor of one or more nodes
432
- * [ ` unist-util-assert ` ] ( https://github.com/syntax-tree/unist-util-assert )
433
- — assert nodes
434
- * [ ` unist-util-filter ` ] ( https://github.com/syntax-tree/unist-util-filter )
435
- — create a new tree with all nodes that pass the given function
436
- * [ ` unist-util-find ` ] ( https://github.com/blahah/unist-util-find )
437
- — find a node by condition
438
- * [ ` unist-util-find-after ` ] ( https://github.com/syntax-tree/unist-util-find-after )
439
- — find a node after another node
440
- * [ ` unist-util-find-all-after ` ] ( https://github.com/syntax-tree/unist-util-find-all-after )
441
- — find nodes after another node or index
442
- * [ ` unist-util-find-all-before ` ] ( https://github.com/syntax-tree/unist-util-find-all-before )
443
- — find nodes before another node or index
444
- * [ ` unist-util-find-all-between ` ] ( https://github.com/mrzmmr/unist-util-find-all-between )
445
- — find nodes between two nodes or positions
446
- * [ ` unist-util-find-before ` ] ( https://github.com/syntax-tree/unist-util-find-before )
447
- — find a node before another node
448
- * [ ` unist-util-flat-filter ` ] ( https://github.com/unicorn-utterances/unist-util-flat-filter )
449
- — flat map version of ` unist-util-filter `
450
- * [ ` unist-util-flatmap ` ] ( https://gitlab.com/staltz/unist-util-flatmap )
451
- — create a new tree by expanding a node into many
452
- * [ ` unist-util-generated ` ] ( https://github.com/syntax-tree/unist-util-generated )
453
- — check if a node is generated
454
- * [ ` unist-util-index ` ] ( https://github.com/syntax-tree/unist-util-index )
455
- — index nodes by property or computed key
456
- * [ ` unist-util-inspect ` ] ( https://github.com/syntax-tree/unist-util-inspect )
457
- — node inspector
458
- * [ ` unist-util-is ` ] ( https://github.com/syntax-tree/unist-util-is )
459
- — check if a node passes a test
460
- * [ ` unist-util-map ` ] ( https://github.com/syntax-tree/unist-util-map )
461
- — create a new tree by mapping nodes
462
- * [ ` unist-util-modify-children ` ] ( https://github.com/syntax-tree/unist-util-modify-children )
463
- — modify direct children of a parent
464
- * [ ` unist-util-parents ` ] ( https://github.com/syntax-tree/unist-util-parents )
465
- — ` parent ` references on nodes
466
- * [ ` unist-util-position ` ] ( https://github.com/syntax-tree/unist-util-position )
467
- — get positional info of nodes
468
- * [ ` unist-util-reduce ` ] ( https://github.com/GenerousLabs/unist-util-reduce )
469
- — recursively reduce a tree
470
- * [ ` unist-util-remove ` ] ( https://github.com/syntax-tree/unist-util-remove )
471
- — remove nodes from trees
472
- * [ ` unist-util-remove-position ` ] ( https://github.com/syntax-tree/unist-util-remove-position )
473
- — remove positional info from trees
474
- * [ ` unist-util-replace-all-between ` ] ( https://github.com/unicorn-utterances/unist-util-replace-all-between )
475
- — replace nodes between two nodes or positions
476
- * [ ` unist-util-select ` ] ( https://github.com/syntax-tree/unist-util-select )
477
- — select nodes with CSS-like selectors
478
- * [ ` unist-util-size ` ] ( https://github.com/syntax-tree/unist-util-size )
479
- — calculate the number of nodes in a tree
480
- * [ ` unist-util-source ` ] ( https://github.com/syntax-tree/unist-util-source )
481
- — get the source of a value (node or position) in a file
482
- * [ ` unist-util-stringify-position ` ] ( https://github.com/syntax-tree/unist-util-stringify-position )
483
- — stringify a node, position, or point
484
- * [ ` unist-util-visit ` ] ( https://github.com/syntax-tree/unist-util-visit )
485
- — recursively walk over nodes
486
- * [ ` unist-util-visit-parents ` ] ( https://github.com/syntax-tree/unist-util-visit-parents )
487
- — recursively walk over nodes, with a stack of parents
488
- * [ ` unist-util-visit-children ` ] ( https://github.com/syntax-tree/unist-util-visit-children )
489
- — visit direct children of a parent
490
- * [ ` unist-util-visit-all-after ` ] ( https://github.com/mrzmmr/unist-util-visit-all-after )
491
- — visit nodes after another node
492
- * [ ` unist-builder ` ] ( https://github.com/syntax-tree/unist-builder )
493
- — helper for creating trees
430
+ * [ ` unist-util-ancestor ` ] ( https://github.com/gorango/unist-util-ancestor )
431
+ — get the common ancestor of one or more nodes
432
+ * [ ` unist-util-assert ` ] ( https://github.com/syntax-tree/unist-util-assert )
433
+ — assert nodes
434
+ * [ ` unist-util-filter ` ] ( https://github.com/syntax-tree/unist-util-filter )
435
+ — create a new tree with all nodes that pass the given function
436
+ * [ ` unist-util-find ` ] ( https://github.com/blahah/unist-util-find )
437
+ — find a node by condition
438
+ * [ ` unist-util-find-after ` ] ( https://github.com/syntax-tree/unist-util-find-after )
439
+ — find a node after another node
440
+ * [ ` unist-util-find-all-after ` ] ( https://github.com/syntax-tree/unist-util-find-all-after )
441
+ — find nodes after another node or index
442
+ * [ ` unist-util-find-all-before ` ] ( https://github.com/syntax-tree/unist-util-find-all-before )
443
+ — find nodes before another node or index
444
+ * [ ` unist-util-find-all-between ` ] ( https://github.com/mrzmmr/unist-util-find-all-between )
445
+ — find nodes between two nodes or positions
446
+ * [ ` unist-util-find-before ` ] ( https://github.com/syntax-tree/unist-util-find-before )
447
+ — find a node before another node
448
+ * [ ` unist-util-flat-filter ` ] ( https://github.com/unicorn-utterances/unist-util-flat-filter )
449
+ — flat map version of ` unist-util-filter `
450
+ * [ ` unist-util-flatmap ` ] ( https://gitlab.com/staltz/unist-util-flatmap )
451
+ — create a new tree by expanding a node into many
452
+ * [ ` unist-util-generated ` ] ( https://github.com/syntax-tree/unist-util-generated )
453
+ — check if a node is generated
454
+ * [ ` unist-util-index ` ] ( https://github.com/syntax-tree/unist-util-index )
455
+ — index nodes by property or computed key
456
+ * [ ` unist-util-inspect ` ] ( https://github.com/syntax-tree/unist-util-inspect )
457
+ — node inspector
458
+ * [ ` unist-util-is ` ] ( https://github.com/syntax-tree/unist-util-is )
459
+ — check if a node passes a test
460
+ * [ ` unist-util-map ` ] ( https://github.com/syntax-tree/unist-util-map )
461
+ — create a new tree by mapping nodes
462
+ * [ ` unist-util-modify-children ` ] ( https://github.com/syntax-tree/unist-util-modify-children )
463
+ — modify direct children of a parent
464
+ * [ ` unist-util-parents ` ] ( https://github.com/syntax-tree/unist-util-parents )
465
+ — ` parent ` references on nodes
466
+ * [ ` unist-util-position ` ] ( https://github.com/syntax-tree/unist-util-position )
467
+ — get positional info of nodes
468
+ * [ ` unist-util-reduce ` ] ( https://github.com/GenerousLabs/unist-util-reduce )
469
+ — recursively reduce a tree
470
+ * [ ` unist-util-remove ` ] ( https://github.com/syntax-tree/unist-util-remove )
471
+ — remove nodes from trees
472
+ * [ ` unist-util-remove-position ` ] ( https://github.com/syntax-tree/unist-util-remove-position )
473
+ — remove positional info from trees
474
+ * [ ` unist-util-replace-all-between ` ] ( https://github.com/unicorn-utterances/unist-util-replace-all-between )
475
+ — replace nodes between two nodes or positions
476
+ * [ ` unist-util-select ` ] ( https://github.com/syntax-tree/unist-util-select )
477
+ — select nodes with CSS-like selectors
478
+ * [ ` unist-util-size ` ] ( https://github.com/syntax-tree/unist-util-size )
479
+ — calculate the number of nodes in a tree
480
+ * [ ` unist-util-source ` ] ( https://github.com/syntax-tree/unist-util-source )
481
+ — get the source of a value (node or position) in a file
482
+ * [ ` unist-util-stringify-position ` ] ( https://github.com/syntax-tree/unist-util-stringify-position )
483
+ — stringify a node, position, or point
484
+ * [ ` unist-util-visit ` ] ( https://github.com/syntax-tree/unist-util-visit )
485
+ — recursively walk over nodes
486
+ * [ ` unist-util-visit-parents ` ] ( https://github.com/syntax-tree/unist-util-visit-parents )
487
+ — recursively walk over nodes, with a stack of parents
488
+ * [ ` unist-util-visit-children ` ] ( https://github.com/syntax-tree/unist-util-visit-children )
489
+ — visit direct children of a parent
490
+ * [ ` unist-util-visit-all-after ` ] ( https://github.com/mrzmmr/unist-util-visit-all-after )
491
+ — visit nodes after another node
492
+ * [ ` unist-builder ` ] ( https://github.com/syntax-tree/unist-builder )
493
+ — helper for creating trees
494
494
495
495
## References
496
496
497
- * ** JavaScript** :
498
- [ ECMAScript Language Specification] [ javascript ] .
499
- Ecma International.
500
- * ** JSON** :
501
- [ The JavaScript Object Notation (JSON) Data Interchange Format] [ json ] ,
502
- T. Bray.
503
- IETF.
504
- * ** XML** :
505
- [ Extensible Markup Language] [ xml ] ,
506
- T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler, F. Yergeau.
507
- W3C.
508
- * ** Web IDL** :
509
- [ Web IDL] [ webidl ] ,
510
- C. McCormack.
511
- W3C.
497
+ * ** JavaScript** :
498
+ [ ECMAScript Language Specification] [ javascript ] .
499
+ Ecma International.
500
+ * ** JSON** :
501
+ [ The JavaScript Object Notation (JSON) Data Interchange Format] [ json ] ,
502
+ T. Bray.
503
+ IETF.
504
+ * ** XML** :
505
+ [ Extensible Markup Language] [ xml ] ,
506
+ T. Bray, J. Paoli, C. Sperberg-McQueen, E. Maler, F. Yergeau.
507
+ W3C.
508
+ * ** Web IDL** :
509
+ [ Web IDL] [ webidl ] ,
510
+ C. McCormack.
511
+ W3C.
512
512
513
513
## Contribute
514
514
0 commit comments