@@ -8,23 +8,30 @@ vignette: >
8
8
%\VignetteEngine{knitr::rmarkdown}
9
9
%\VignetteEncoding{UTF-8}
10
10
---
11
+ > This vignette is partly outdated since nested structure was implemented
12
+ > completely. In particular, the serialization is now done differently.
13
+
11
14
library("dplyr")
12
15
library("purrr")
13
16
pkgload::load_all()
14
17
15
- This vignette builds on the vignette "Data Structures" and discusses how
16
- to go forward with the nested structure of the parse data. In order to
17
- compute the white space information in a nested data structure, we need
18
- a recursion. We use a [ visitor
19
- approach] ( https://en.wikipedia.org/wiki/Visitor_pattern ) to separate the
20
- algorithm (computing white space information) from the object (nested)
21
- data structure. The function ` create_filler() ` can then be used to add
22
- white space information on every level of nesting within the nested
23
- parse data if applied in combination with the visitor. ` visitor() ` takes
24
- a object to operate on and a list of functions. Each function is applied
25
- at the current level of nesting before the next level of nesting is
26
- entered.
27
18
19
+ This vignette builds on the vignette "Data Structures" and discusses how
20
+ to go forward with the nested structure of the parse data.
21
+ In order to compute the white space information in a nested data structure, we
22
+ use a [ visitor approach] ( https://en.wikipedia.org/wiki/Visitor_pattern ) to
23
+ separate the algorithm (computing white space information and later apply
24
+ transformations) from the object (nested data structure).
25
+ The function ` create_filler() ` can then be used to compute current
26
+ white space information on every level of nesting within the nested parse data
27
+ if applied in combination with the visitor. In the sequel, a parse table at
28
+ one level of nesting will be denoted with the term * nest* , which always
29
+ represents a complete expression. Our visiting functions ` pre_visit() ` and ` post_visit() ` take an object to
30
+ operate on and a list of functions. Concretely, the object is the
31
+ nested parse table. Each function is applied at each level of
32
+ nesting nesting before the next level of nesting is entered. You can find out
33
+ more about the visitor on the help file for ` visit ` (note that this function
34
+ is not exported by styler).
28
35
pre_visit
29
36
30
37
## function(pd_nested, funs) {
@@ -43,13 +50,19 @@ entered.
43
50
## .init = pd_flat)
44
51
## }
45
52
## <environment: namespace:styler>
53
+ This comes with two advantages.
46
54
47
- This comes with two advantages.
48
55
56
+ * We go through the whole structure only as many times as we call the visitor
57
+ (instead of every * _ nested() function going through it once, which is more
58
+ efficient in terms of speed.
59
+
60
+
49
61
- We don't need a \*\_ nested() version of every function we want to
50
62
apply to the parse tables, in particular the rules in R/rules.R
51
- - We go through the whole structure only once (instead of every
52
- \*\_ nested() function going through it once, which is more efficient
63
+ - We go through the whole structure only as many times as we call the visitor
64
+ (instead of every
65
+ \*\_ nested() function going through it once), which is more efficient
53
66
in terms of speed.
54
67
55
68
` create_filler() ` was adapted to also initialize indention and
0 commit comments