Debian Codegraph @

data/syntax/yacc.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language>
3 <!--
4 ========================================================================
5 YACC.XML supports syntax highlighting for Yacc/Bison source under Kate.
6
7 Copyright (C) 2004, Jan Villat <[email protected]>
8 This code is released under the LGPL as part of kdelibs/kate.
9 ========================================================================
10
11
12 == UPDATE HISTORY ==
13 2018-02-20 // Nibaldo González <[email protected]>
14
15 Fix '$' symbol, highlighted as 'dsError' by C++ (isocpp.xml).
16 Update syntax for Bison (3.0.4):
17 - Add declarations, directives in rules and the '@' variable.
18 - Allow a tag in '%union', declarations in multiple lines and
19 grammar declarations in the grammar rules section.
20 - The ';' char is not necessary to finish a rule. Allow '; |'
21 within rules.
22 Add mimetypes and extensions '*.ypp' & '*.y++'.
23
24 2007-10-01 // Sebastian Pipping <[email protected]>
25
26 Added: Extension "*.yy" for Bison
27
28 2004-05-26 // Jan Villat <[email protected]>
29
30 YACC.XML 1.00 - First released.
31
32
33 ========================================================================
34 -->
35 <language name="Yacc/Bison" version="9" kateversion="5.79" section="Sources" extensions="*.y;*.yy;*.ypp;*.y++" mimetype="text/x-yacc;text/x-bison" priority="5" author="Jan Villat ([email protected])" license="LGPL">
36
37 <highlighting>
38 <contexts>
39 <context name="Pre Start" attribute="Normal Text" lineEndContext="#stay">
40 <IncludeRules context="Comment" />
41 <DetectSpaces />
42 <Detect2Chars attribute="Content-Type Delimiter" context="C Declarations" char="%" char1="{" beginRegion="cdeclarations" column="0" />
43 <RegExpr attribute="Normal Text" context="Declarations" String="." beginRegion="declarations" lookAhead="true" />
44 </context>
45
46 <context name="C Declarations" attribute="Normal Text" lineEndContext="#stay">
47 <IncludeRules context="Comment" />
48 <Detect2Chars attribute="Content-Type Delimiter" context="#pop" char="%" char1="}" endRegion="cdeclarations" column="0" />
49 <IncludeRules context="##C++" />
50 </context>
51
52 <context name="Declarations" attribute="Normal Text" lineEndContext="#stay">
53 <IncludeRules context="Comment" />
54 <Detect2Chars attribute="Content-Type Delimiter" context="Rules" char="%" char1="%" beginRegion="rules" endRegion="declarations" />
55 <!-- Prologue Declarations -->
56 <Detect2Chars attribute="Content-Type Delimiter" context="C Declarations" char="%" char1="{" beginRegion="cdeclarations" column="0" />
57 <IncludeRules context="Grammar Declarations" />
58 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%initial-action" />
59 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%param" />
60 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%lex-param" />
61 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%parse-param" />
62 <WordDetect attribute="Directive" context="Percent Command In" String="%&lt;flag&gt;" />
63 <!-- Any word followed by '%' (End with ';' or '%') -->
64 <DetectChar attribute="Directive" context="Percent Command" char="%" />
65 </context>
66 <context name="Grammar Declarations" attribute="Normal Text" lineEndContext="#stay">
67 <WordDetect attribute="Directive" context="Union Start" String="%union" />
68 <WordDetect attribute="Directive" context="Union Start" String="%code" />
69 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%destructor" />
70 <WordDetect attribute="Directive" context="Code-Symbols Start" String="%printer" />
71 </context>
72
73 <context name="Union Start" attribute="Normal Text" lineEndContext="#stay">
74 <IncludeRules context="Comment" />
75 <DetectSpaces />
76 <DetectChar attribute="Normal Text" context="Union In" char="{" beginRegion="union" />
77 <RegExpr attribute="Normal Text" context="#pop!Union Tag" String="[^\s\{](?=\s|$|//)" />
78 </context>
79 <context name="Union Tag" attribute="Normal Text" lineEndContext="#stay">
80 <IncludeRules context="Comment" />
81 <DetectSpaces />
82 <DetectChar attribute="Normal Text" context="Union In" char="{" beginRegion="union" />
83 <RegExpr attribute="Alert" context="#pop" String="." />
84 </context>
85 <context name="Union In" attribute="Normal Text" lineEndContext="#stay">
86 <DetectChar attribute="Normal Text" context="Union InIn" char="{" />
87 <DetectChar attribute="Normal Text" context="#pop#pop" char="}" endRegion="union" />
88 <IncludeRules context="##C++" />
89 </context>
90 <context name="Union InIn" attribute="Normal Text" lineEndContext="#stay">
91 <DetectChar attribute="Normal Text" context="Union InIn" char="{" />
92 <DetectChar attribute="Normal Text" context="#pop" char="}" />
93 <IncludeRules context="##C++" />
94 </context>
95
96 <!-- '%'<decl> ('{' <Code-Symbols In> '}')+ <Percent Command In> [';'] -->
97 <context name="Code-Symbols Start" attribute="Normal Text" lineEndContext="#stay">
98 <IncludeRules context="Comment" />
99 <DetectSpaces />
100 <DetectChar attribute="Normal Text" context="Code-Symbols In" char="{" beginRegion="code-symbols" />
101 <RegExpr attribute="Alert" context="#pop" String="." />
102 </context>
103 <context name="Code-Symbols In" attribute="Normal Text" lineEndContext="#stay">
104 <DetectChar attribute="Normal Text" context="#pop#pop!Code-Symbols End" char="}" endRegion="code-symbols" />
105 <DetectChar attribute="Normal Text" context="Code-Symbols InIn" char="{" />
106 <IncludeRules context="Symbol-Variable" />
107 <IncludeRules context="##C++" />
108 </context>
109 <context name="Code-Symbols InIn" attribute="Normal Text" lineEndContext="#stay">
110 <DetectChar attribute="Normal Text" context="Code-Symbols InIn" char="{" />
111 <DetectChar attribute="Normal Text" context="#pop" char="}" />
112 <IncludeRules context="Symbol-Variable" />
113 <IncludeRules context="##C++" />
114 </context>
115 <context name="Code-Symbols End" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop!Percent Command In">
116 <IncludeRules context="Comment" />
117 <DetectSpaces />
118 <DetectChar attribute="Normal Text" context="#pop" char=";" lookAhead="true" />
119 <DetectChar attribute="Normal Text" context="Code-Symbols In" char="{" beginRegion="code-symbols" />
120 </context>
121
122 <context name="Rules" attribute="Rule" lineEndContext="#stay">
123 <IncludeRules context="Comment" />
124 <Detect2Chars attribute="Content-Type Delimiter" context="User Code" char="%" char1="%" beginRegion="code" endRegion="rules" />
125 <DetectChar attribute="Normal Text" context="Rule In" char=":" beginRegion="rule" />
126 <DetectChar attribute="Rule" context="Grammar Declaration Start" char="%" lookAhead="true" />
127 </context>
128
129 <context name="Rule In" attribute="Definition" lineEndContext="#stay">
130 <IncludeRules context="Comment" />
131 <DetectChar attribute="Normal Text" context="Rule End" char=";" endRegion="rule" />
132 <DetectChar attribute="Normal Text" context="Normal C Bloc" char="{" beginRegion="bloc" />
133 <DetectChar attribute="Normal Text" context="#stay" char="|" />
134 <IncludeRules context="StringOrChar" />
135 <RegExpr attribute="Directive" context="#stay" String="%\?(?=\{)" />
136 <WordDetect attribute="Directive" context="#stay" String="%empty" />
137 <WordDetect attribute="Directive" context="#stay" String="%prec" />
138 <WordDetect attribute="Directive" context="#stay" String="%dprec" />
139 <WordDetect attribute="Directive" context="#stay" String="%merge" />
140
141 <!-- Finish rule without the ';' character (see the 'rhses.1' rule in the 'src/parse-gram.y' file, from the Bison source) -->
142 <RegExpr attribute="Open Rule" context="#pop" String="^[\w\-\.](?=[\w\-\.]*:)" column="0" endRegion="rule" />
143 <Detect2Chars attribute="Content-Type Delimiter" context="#pop" char="%" char1="%" lookAhead="true" firstNonSpace="true" endRegion="rule" />
144 <RegExpr attribute="Directive" context="#pop" String="^%(?:union|code|destructor|printer|start|(?:no\-)?default\-prec|nterm|token|type|left|right|nonassoc|precedence)\b" lookAhead="true" column="0" endRegion="rule" />
145 </context>
146 <!-- The Bison parser allows to have ';' followed by '|', without the rule ending.
147 The problem here is that the ';' char has endRegion="rule" (although it is not very relevant). -->
148 <context name="Rule End" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop#pop">
149 <DetectSpaces />
150 <DetectChar attribute="Normal Text" context="#stay" char=";" />
151 <DetectChar attribute="Normal Text" context="#pop" char="|" />
152 <IncludeRules context="Comment" />
153 </context>
154
155 <context name="Grammar Declaration Start" attribute="Normal Text" lineEndContext="#stay">
156 <!-- In the rules section, only highlighting exact declarations -->
157 <IncludeRules context="Grammar Declarations" />
158 <WordDetect attribute="Directive" context="Percent Command In" String="%start" />
159 <WordDetect attribute="Directive" context="Percent Command In" String="%default-prec" />
160 <WordDetect attribute="Directive" context="Percent Command In" String="%no-default-prec" />
161 <WordDetect attribute="Directive" context="Percent Command In" String="%nterm" />
162 <WordDetect attribute="Directive" context="Percent Command In" String="%token" />
163 <WordDetect attribute="Directive" context="Percent Command In" String="%type" />
164 <WordDetect attribute="Directive" context="Percent Command In" String="%left" />
165 <WordDetect attribute="Directive" context="Percent Command In" String="%right" />
166 <WordDetect attribute="Directive" context="Percent Command In" String="%nonassoc" />
167 <WordDetect attribute="Directive" context="Percent Command In" String="%precedence" />
168
169 <DetectChar attribute="Rule" context="#pop" char="%" /> <!-- End when there is an invalid declaration -->
170 <DetectChar attribute="Normal Text" context="#pop" char=";" />
171 <IncludeRules context="Comment" />
172 <DetectSpaces />
173 <RegExpr attribute="Alert" context="#pop" String=".+" />
174 </context>
175
176 <context name="User Code" attribute="Normal Text" lineEndContext="#stay">
177 <IncludeRules context="##C++" />
178 </context>
179
180 <context name="Percent Command" attribute="Directive" lineEndContext="#pop!Percent Command In">
181 <IncludeRules context="Comment" />
182 <RegExpr attribute="Normal Text" context="#pop!Percent Command In" String="[^\w\-]" lookAhead="true" />
183 </context>
184 <context name="Percent Command In" attribute="Normal Text" lineEndContext="#stay">
185 <!-- This can be applied to multiple lines -->
186 <DetectChar attribute="Normal Text" context="#pop" char=";" lookAhead="true" />
187 <DetectChar attribute="Normal Text" context="#pop" char="%" lookAhead="true" firstNonSpace="true" />
188 <Detect2Chars attribute="Normal Text" context="#pop" char="%" char1="%" lookAhead="true" />
189 <IncludeRules context="StringOrChar" />
190 <DetectChar attribute="Data Type" context="PC type" char="&lt;" />
191 <IncludeRules context="Comment" />
192 </context>
193 <context name="PC type" attribute="Data Type" lineEndContext="#pop#pop">
194 <DetectChar attribute="Data Type" context="#pop" char="&gt;" />
195 </context>
196
197 <context name="Comment" attribute="Comment" lineEndContext="#stay">
198 <Detect2Chars attribute="Comment" context="CommentStar" char="/" char1="*" beginRegion="comment" />
199 <Detect2Chars attribute="Comment" context="CommentSlash" char="/" char1="/" />
200 </context>
201 <context name="CommentStar" attribute="Comment" lineEndContext="#stay">
202 <DetectSpaces />
203 <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="comment" />
204 <IncludeRules context="##Comments" />
205 </context>
206 <context name="CommentSlash" attribute="Comment" lineEndContext="#pop">
207 <DetectSpaces />
208 <IncludeRules context="##Comments" />
209 </context>
210
211 <context name="StringOrChar" attribute="Normal Text" lineEndContext="#stay">
212 <DetectChar attribute="String Char" context="Char" char="'" />
213 <DetectChar attribute="String" context="String" char="&quot;" />
214 </context>
215 <context name="String" attribute="String" lineEndContext="#pop">
216 <RegExpr attribute="Backslash Code" context="#stay" String="\\." />
217 <DetectChar attribute="String" context="#pop" char="&quot;" />
218 </context>
219 <context name="Char" attribute="String Char" lineEndContext="#pop">
220 <RegExpr attribute="Backslash Code" context="#stay" String="\\." />
221 <DetectChar attribute="String Char" context="#pop" char="'" />
222 </context>
223
224 <context name="Normal C Bloc" attribute="Normal Text" lineEndContext="#stay">
225 <DetectChar attribute="Normal Text" context="Normal C Bloc" char="{" beginRegion="bloc" />
226 <DetectChar attribute="Normal Text" context="#pop" char="}" endRegion="bloc" />
227 <IncludeRules context="Symbol-Variable" />
228 <IncludeRules context="##C++" />
229 </context>
230 <context name="Symbol-Variable" attribute="Normal Text" lineEndContext="#stay">
231 <DetectChar attribute="Directive" context="Dol" char="$" />
232 <RegExpr attribute="Directive" context="#stay" String="@\$?(?:\d+|[A-Za-z_]\w*)?" />
233 </context>
234 <context name="Dol" attribute="Normal Text" fallthroughContext="DolEnd" lineEndContext="#stay">
235 <RegExpr attribute="Data Type" context="DolEnd" String="&lt;[^&gt;]+&gt;" />
236 </context>
237 <context name="DolEnd" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop#pop">
238 <RegExpr attribute="Directive" context="#pop#pop" String="@?\d+" />
239 <DetectChar attribute="Directive" context="#pop#pop" char="$" />
240 <DetectIdentifier attribute="Directive" context="#pop#pop" />
241 </context>
242 </contexts>
243
244 <itemDatas>
245 <itemData name="Normal Text" defStyleNum="dsNormal" />
246 <itemData name="Definition" defStyleNum="dsNormal" />
247 <itemData name="Comment" defStyleNum="dsComment" />
248 <itemData name="Content-Type Delimiter" defStyleNum="dsBaseN" bold="1" />
249 <itemData name="Directive" defStyleNum="dsKeyword"/>
250 <itemData name="Rule" defStyleNum="dsString" />
251 <itemData name="Open Rule" defStyleNum="dsString" bold="1" />
252 <itemData name="Backslash Code" defStyleNum="dsString" bold="1" />
253 <itemData name="Alert" defStyleNum="dsAlert" />
254 <itemData name="String" defStyleNum="dsString"/>
255 <itemData name="String Char" defStyleNum="dsChar"/>
256 <itemData name="Data Type" defStyleNum="dsDataType"/>
257 </itemDatas>
258
259 </highlighting>
260 <general>
261 <comments>
262 <comment name="multiLine" start="/*" end="*/" region="comment" />
263 <comment name="singleLine" start="//" />
264 </comments>
265 </general>
266 </language>
267 <!-- kate: space-indent on; indent-width 2; replace-tabs on; -->