forked from alx71hub/hcb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.xsl
243 lines (197 loc) · 6.13 KB
/
html.xsl
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version='1.0'?>
<xsl:stylesheet
version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:output method='html' indent='yes'/>
<xsl:template match='bnf'>
<html>
<head>
<title>Hyperlinked C++ BNF Grammar</title>
<style type='text/css'>
body
{
font-family: Verdana, Arial;
font-size: 18;
}
h1
{
text-align: center;
font-size: 32;
}
.Credits
{
text-align: center;
}
.Section
{
font-size: 18;
text-align: right;
background-color: #FFA448;
color: black;
}
tr.RuleRow
{
}
td.RuleColumn
{
font-size: 16
}
.TerminalSymbol
{
font-family: Lucida, Courier;
font-size: 16
}
.NonTerminalSymbol
{
font-size: 16
}
.Description
{
font-size: 16
}
.Note
{
font-size: 14;
color: red
}
A:link { color: blue; }
A:visited { color: blue; }
A:hover { color: #FFA448; }
A:active { color: red; }
A.NonTerminalSymbol:link { color: green; }
A.NonTerminalSymbol:visited { color: green; }
A.NonTerminalSymbol:hover { color: blue; }
A.NonTerminalSymbol:active { color: red; }
</style>
</head>
<body>
<a name='TOP'><h1>Hyperlinked C++ BNF Grammar</h1></a>
<h2>Introduction</h2>
<p>
This is a fork from <a href="https://github.com/alx71hub/hcb">alx71hu/hcb</a>, which seemed to be abandoned. I updated the XML file with the current C++20 grammar and plan to extend it to cover the upcoming C++23 and the older grammar versions as well, back to C++11. I will keep the design by the original author until it gets messy with all the different grammar versions.
</p>
<div class='Credits'>
<p>Maintained by Nyde@Github</p>
<p>Original version by <a href='https://github.com/alx71hub/hcb'>Alessio Marchetti</a></p>
<p>Version <xsl:value-of select='@version'/></p>
<p>Last updated: <xsl:value-of select='@update'/></p>
<p>Published under GNU General Public License (GPL)</p>
</div>
<hr/>
<h2>Purpose of this document</h2>
<p>If you are a C++ developer then you sometimes need to have a look at the C++ BNF grammar. At least I do. </p>
<p>But reading a set of BNF rules is difficult since you have to jump from one rule to the next one, maybe pages away from it. </p>
<p>With this document I tried to make it easier to navigate among the BNF rules of the C++ language grammar; you can find here a hyperlinked graph whose nodes are the BNF productions of the C++ language grammar. </p>
<p>If you find errors or inconsistencies, please <a href='https://github.com/alx71hub/hcb'>log an issue</a>.</p>
<h3>The BNF non-terminal for a C++ translation unit (translation-unit) is defined <a href='#basic.link'>here</a>.</h3>
<h3>The BNF non-terminal for a C++ preprocessing file (preprocessing-file) is defined <a href='#cpp'>here</a>.</h3>
<hr/>
<h1>BNF Grammar Rules</h1>
<table><xsl:apply-templates/></table>
<hr/>
<p><a href='#TOP'>Back to top</a></p>
</body>
</html>
</xsl:template>
<xsl:template match='section'>
<tr class='Section'>
<td> </td>
<td>
<h2>
<a>
<xsl:attribute name='name'><xsl:value-of select='@id'/></xsl:attribute>
<xsl:value-of select='@id'/>
<xsl:choose>
<xsl:when test='@version'>
<br /><span class='Note'><xsl:value-of select='@version'/></span>
</xsl:when>
</xsl:choose>
</a>
</h2>
</td>
</tr>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match='rule'>
<tr class='RuleRow'>
<td class='RuleColumn'>
<a>
<xsl:attribute name='name'><xsl:value-of select='syntax'/></xsl:attribute>
<b><xsl:value-of select='syntax'/><xsl:text>:</xsl:text></b>
</a>
<xsl:choose>
<xsl:when test='@version'>
<br /><span class='Note'><xsl:value-of select='@version'/></span>
</xsl:when>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test='@issue'>
<span class='Note'>
<xsl:text>See </xsl:text>
<a>
<xsl:attribute name='href'>http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_toc.html</xsl:attribute>
<xsl:text>C++ Standard Core Language Issue</xsl:text>
</a>
<xsl:text> n. </xsl:text>
<xsl:value-of select='@issue'/>
</span>
</xsl:when>
<xsl:when test='@note and not(@issue)'>
<span class='Note'><xsl:text> ----</xsl:text><xsl:value-of select='@note'/></span>
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match='syntax'/>
<xsl:template match='alternative'>
<tr>
<td> </td>
<td>
<xsl:apply-templates/>
<xsl:if test='@issue'>
<span class='Note'>
<xsl:text>See </xsl:text>
<a>
<xsl:attribute name='href'>http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_toc.html</xsl:attribute>
<xsl:text>C++ Standard Core Language Issue</xsl:text>
</a>
<xsl:text> n. </xsl:text>
<xsl:value-of select='@issue'/>
</span>
</xsl:if>
<xsl:if test="@note and not(@issue)">
<span class='Note'><xsl:text>    </xsl:text><xsl:value-of select='@note'/></span>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match='terminal'>
<xsl:choose>
<xsl:when test="@sentence='true'">
<span class='Description'><i><xsl:value-of select='.'/></i></span>
</xsl:when>
<xsl:otherwise>
<span class='TerminalSymbol'><b><xsl:value-of select='.'/></b></span>
<xsl:if test="@optional='true'">
<sub>opt</sub>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='non-terminal'>
<a class='NonTerminalSymbol'>
<xsl:attribute name='href'>#<xsl:value-of select='.'/></xsl:attribute>
<xsl:value-of select='.'/>
</a>
<xsl:if test="@optional='true'">
<sub>opt</sub>
</xsl:if>
</xsl:template>
</xsl:stylesheet>