@@ -20,21 +20,18 @@ struct GrammarGenerator {
20
20
/// - parameters:
21
21
/// - tokenChoice: ``TokenChoice`` to describe
22
22
/// - backticks: Whether to wrap the token choice in backticks
23
- private func grammar( for tokenChoice: TokenChoice , backticked: Bool = true ) -> String {
24
- var description : String
23
+ private func grammar( for tokenChoice: TokenChoice ) -> String {
25
24
switch tokenChoice {
26
25
case . keyword( let keyword) :
27
- description = " ' \( keyword. spec. name) ' "
26
+ return " ` '\( keyword. spec. name) '` "
28
27
case . token( let token) :
29
28
let tokenSpec = token. spec
30
29
if let tokenText = tokenSpec. text {
31
- description = " ' \( tokenText) ' "
30
+ return " ` '\( tokenText) '` "
32
31
} else {
33
- description = " < \( tokenSpec. varOrCaseName) > "
32
+ return " ` <\( tokenSpec. varOrCaseName) >` "
34
33
}
35
34
}
36
-
37
- return backticked ? " ` \( description) ` " : description
38
35
}
39
36
40
37
private func grammar( for child: Child ) -> String {
@@ -77,9 +74,9 @@ struct GrammarGenerator {
77
74
78
75
if case . token( let choices, _, _) = child. kind {
79
76
if choices. count == 1 {
80
- return " \( generator. grammar ( for: choices. first!, backticked : false ) ) "
77
+ return " \( generator. grammar ( for: choices. first!) ) "
81
78
} else {
82
- return choices. map { " - \( generator. grammar ( for: $0, backticked : false ) ) " } . joined ( separator: " \n " )
79
+ return choices. map { " - \( generator. grammar ( for: $0) ) " } . joined ( separator: " \n " )
83
80
}
84
81
} else {
85
82
return " "
0 commit comments