@@ -120,46 +120,33 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
120
120
%include Sh.lexh
121
121
%%
122
122
<STRING> {
123
- "$" {Identifier} {
123
+ "$" {Identifier} {
124
124
String id = yytext();
125
- // For historical reasons, ShXref will not link identifiers of length=1
126
- // (or of length=2 with a leading '$')
127
- if (id. length() > 2 ) {
128
- out. write(" <a href=\" " );
129
- out. write(urlPrefix);
130
- out. write(" refs=" );
131
- out. write(id);
132
- appendProject();
133
- out. write(" \" >" );
134
- out. write(id);
135
- out. write(" </a>" );
136
- } else {
137
- out. write(id);
138
- }
125
+ out. write(" <a href=\" " );
126
+ out. write(urlPrefix);
127
+ out. write(" refs=" );
128
+ out. write(id);
129
+ appendProject();
130
+ out. write(" \" >" );
131
+ out. write(id);
132
+ out. write(" </a>" );
139
133
}
140
134
141
135
/* This rule matches associative arrays inside strings,
142
136
for instance "${array["string"]}". Push a new STRING
143
137
state on the stack to prevent premature exit from the
144
138
STRING state. */
145
- \$\{ {Identifier} \[\" {
139
+ \$\{ {Identifier} \[\" {
146
140
out. write(htmlize(yytext()));
147
141
pushSpan(STRING , HtmlConsts . STRING_CLASS );
148
142
}
149
143
}
150
144
151
145
<YYINITIAL, SUBSHELL, BACKQUOTE, BRACEGROUP> {
152
- \$ ? {Identifier} {
146
+ \$ ? {Identifier} {
153
147
String id = yytext();
154
- // For historical reasons, ShXref will not link identifiers of length=1
155
- int minlength = 1 ;
156
- if (id. startsWith(" $" )) ++ minlength;
157
- if (id. length() > minlength) {
158
- writeSymbol(id, Consts . shkwd, yyline);
159
- } else {
160
- out. write(id);
161
- }
162
- }
148
+ writeSymbol(id, Consts . shkwd, yyline);
149
+ }
163
150
164
151
{Number} {
165
152
String lastClassName = getDisjointSpanClassName();
@@ -168,11 +155,11 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
168
155
disjointSpan(lastClassName);
169
156
}
170
157
171
- \$ ? \" {
158
+ \$ ? \" {
172
159
pushSpan(STRING , HtmlConsts . STRING_CLASS );
173
160
out. write(htmlize(yytext()));
174
161
}
175
- \$ ? \' {
162
+ \$ ? \' {
176
163
pushSpan(QSTRING , HtmlConsts . STRING_CLASS );
177
164
out. write(htmlize(yytext()));
178
165
}
@@ -182,7 +169,7 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
182
169
}
183
170
184
171
// Recognize here-documents. At least a subset of them.
185
- "<<" "-" ? {WhspChar} * {Identifier} {WhspChar} * {
172
+ "<<" "-" ? {WhspChar} * {Identifier} {WhspChar} * {
186
173
String text = yytext();
187
174
out. write(htmlize(text));
188
175
@@ -193,21 +180,29 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
193
180
194
181
// Any sequence of more than two < characters should not start HEREDOC. Use
195
182
// this rule to catch them before the HEREDOC rule.
196
- "<<" "<" + {
183
+ "<<" "<" + {
197
184
out. write(htmlize(yytext()));
198
185
}
199
186
200
- {Unary_op} |
187
+ {Unary_op_req_lookahead} / \W {
188
+ out. write(yytext());
189
+ }
190
+ {Unary_op_req_lookahead} $ {
191
+ out. write(yytext());
192
+ }
193
+ {WhiteSpace} {Unary_op_char} / ")" {
194
+ out. write(yytext());
195
+ }
201
196
{Binary_op} {
202
197
out. write(yytext());
203
198
}
204
199
}
205
200
206
201
<STRING> {
207
202
\\ [ \"\$\`\\ ] |
208
- \" {WhspChar} * \" { out. write(htmlize(yytext())); }
203
+ \" {WhspChar} * \" { out. write(htmlize(yytext())); }
209
204
\" { out. write(htmlize(yytext())); yypop(); }
210
- \$\( {
205
+ \$\( {
211
206
pushSpan(SUBSHELL , null );
212
207
out. write(yytext());
213
208
}
@@ -220,16 +215,16 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
220
215
* to ksh man page http://www2.research.att.com/~gsf/man/man1/ksh-man.html#Command%20Substitution
221
216
* the opening brace must be followed by a blank.
222
217
*/
223
- "${" / {WhspChar} | {EOL} {
218
+ "${" / {WhspChar} | {EOL} {
224
219
pushSpan(BRACEGROUP , null );
225
220
out. write(yytext());
226
221
}
227
222
}
228
223
229
224
<QSTRING> {
230
225
\\ [ \' ] |
231
- \' {WhspChar} * \' { out. write(htmlize(yytext())); }
232
- \' { out. write(htmlize(yytext())); yypop(); }
226
+ \' {WhspChar} * \' { out. write(htmlize(yytext())); }
227
+ \' { out. write(htmlize(yytext())); yypop(); }
233
228
}
234
229
235
230
<SCOMMENT> {
@@ -244,7 +239,7 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
244
239
}
245
240
246
241
<BACKQUOTE> {
247
- ` { out. write(yytext()); yypop(); }
242
+ [ ` ] { out. write(yytext()); yypop(); }
248
243
}
249
244
250
245
<BRACEGROUP> {
@@ -253,45 +248,45 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
253
248
* the closing brace must be on beginning of line, or it must be preceded by
254
249
* a semi-colon and (optionally) whitespace.
255
250
*/
256
- ^ {WhspChar} * \} { out. write(yytext()); yypop(); }
257
- ; {WhspChar} * \} { out. write(yytext()); yypop(); }
251
+ ^ {WhspChar} * \} { out. write(yytext()); yypop(); }
252
+ ; {WhspChar} * \} { out. write(yytext()); yypop(); }
258
253
}
259
254
260
255
<HEREDOC> {
261
- [^\n] + {
256
+ [^\n] + {
262
257
String line = yytext();
263
258
if (isHeredocStopWord(line)) {
264
259
yypop();
265
260
}
266
261
out. write(htmlize(line));
267
262
}
268
263
269
- {EOL} { startNewLine(); }
264
+ {EOL} { startNewLine(); }
270
265
}
271
266
272
267
<YYINITIAL, SUBSHELL, BACKQUOTE, BRACEGROUP> {
273
268
/* Don't enter new state if special character is escaped. */
274
269
\\ [ `\)\(\{\"\'\$\#\\ ] { out. write(htmlize(yytext())); }
275
270
276
271
/* $# should not start a comment. */
277
- "$#" { out. write(yytext()); }
272
+ "$#" { out. write(yytext()); }
278
273
279
- \$ ? \( { pushSpan(SUBSHELL , null ); out. write(yytext()); }
280
- ` { pushSpan(BACKQUOTE , null ); out. write(yytext()); }
274
+ \$ ? \( { pushSpan(SUBSHELL , null ); out. write(yytext()); }
275
+ [ ` ] { pushSpan(BACKQUOTE , null ); out. write(yytext()); }
281
276
282
277
/* Bug #15661: Recognize ksh command substitution within strings. According
283
278
* to ksh man page http://www2.research.att.com/~gsf/man/man1/ksh-man.html#Command%20Substitution
284
279
* the opening brace must be followed by a blank. Make the initial dollar sign
285
280
* optional so that we get the nesting right and don't terminate the brace
286
281
* group too early if the ${ cmd; } expression contains nested { cmd; } groups.
287
282
*/
288
- \$ ? \{ / {WhspChar} | {EOL} {
283
+ \$ ? \{ / {WhspChar} | {EOL} {
289
284
pushSpan(BRACEGROUP , null ); out. write(yytext());
290
285
}
291
286
}
292
287
293
288
<YYINITIAL, SUBSHELL, BACKQUOTE, BRACEGROUP, STRING, SCOMMENT, QSTRING> {
294
- {File} {
289
+ {File} {
295
290
String path = yytext();
296
291
out. write(" <a href=\" " + urlPrefix+ " path=" );
297
292
out. write(path);
@@ -301,19 +296,18 @@ File = {FNameChar}+ "." ([a-zA-Z]+)
301
296
out. write(" </a>" );
302
297
}
303
298
304
- {RelaxedMiddleFPath}
305
- { out. write(Util . breadcrumbPath(urlPrefix+ " path=" ,yytext(),' /' ));}
299
+ {RelaxedMiddleFPath} {
300
+ out. write(Util . breadcrumbPath(urlPrefix + " path=" , yytext(), ' /' )); }
306
301
307
302
[ &<>\'\" ] { out. write(htmlize(yytext())); }
308
303
{WhspChar} * {EOL} { startNewLine(); }
309
- {WhiteSpace} { out. write(yytext()); }
310
- [ !- ~] { out. write(yycharat(0 )); }
311
- [^\n] { writeUnicodeChar(yycharat(0 )); }
304
+ {WhiteSpace} { out. write(yytext()); }
305
+ [ !- ~] { out. write(yycharat(0 )); }
306
+ [^\n] { writeUnicodeChar(yycharat(0 )); }
312
307
}
313
308
314
309
<STRING, SCOMMENT, QSTRING> {
315
- {FNameChar} + "@" {FNameChar} + "." {FNameChar} +
316
- {
310
+ {FNameChar} + "@" {FNameChar} + "." {FNameChar} + {
317
311
writeEMailAddress(yytext());
318
312
}
319
313
}
0 commit comments