27
27
*/
28
28
29
29
package org. opensolaris. opengrok. analysis. javascript;
30
- import org. opensolaris. opengrok. analysis. JFlexXref;
31
- import java. io. IOException;
32
- import java. io. Writer;
33
- import java. io. Reader;
34
- import org. opensolaris. opengrok. web. Util;
35
30
31
+ import org. opensolaris. opengrok. analysis. JFlexXrefSimple;
32
+ import org. opensolaris. opengrok. util. StringUtils;
33
+ import org. opensolaris. opengrok. web. HtmlConsts;
34
+ import org. opensolaris. opengrok. web. Util;
36
35
% %
37
36
%public
38
37
%class JavaScriptXref
39
- %extends JFlexXref
38
+ %extends JFlexXrefSimple
40
39
%unicode
41
- %ignorecase
42
40
%int
43
41
%include CommonXref.lexh
44
42
%{
@@ -49,7 +47,10 @@ import org.opensolaris.opengrok.web.Util;
49
47
protected void setLineNumber(int x) { yyline = x; }
50
48
%}
51
49
52
- File = [ a- zA- Z] {FNameChar} * "." ( "js" | "properties" | "props" | "xml" | "conf" | "txt" | "htm" | "html" | "ini" | "diff" | "patch" )
50
+ File = [ a- zA- Z] {FNameChar} * "." ( [ Jj][ Ss] |
51
+ [ Pp][ Rr][ Oo][ Pp][ Ee][ Rr][ Tt][ Ii][ Ee][ Ss] | [ Pp][ Rr][ Oo][ Pp][ Ss] |
52
+ [ Xx][ Mm][ Ll] | [ Cc][ Oo][ Nn][ Ff] | [ Tt][ Xx][ Tt] | [ Hh][ Tt][ Mm][ Ll] ? |
53
+ [ Ii][ Nn][ Ii] | [ Dd][ Ii][ Ff][ Ff] | [ Pp][ Aa][ Tt][ Cc][ Hh] )
53
54
54
55
%state STRING COMMENT SCOMMENT QSTRING
55
56
@@ -84,54 +85,68 @@ File = [a-zA-Z]{FNameChar}* "." ("js"|"properties"|"props"|"xml"|"conf"|"txt"|"h
84
85
out. write(" >" );
85
86
}
86
87
87
- /*
88
- { out.write(Util.breadcrumbPath(urlPrefix+"defs=",yytext(),'.'));}
89
- */
90
- {Number} { out. write(" <span class=\" n\" >" ); out. write(yytext()); out. write(" </span>" ); }
91
-
92
- \" { yybegin(STRING );out. write(" <span class=\" s\" >\" " );}
93
- \' { yybegin(QSTRING );out. write(" <span class=\" s\" >\' " );}
94
- "/*" { yybegin(COMMENT );out. write(" <span class=\" c\" >/*" );}
95
- "//" { yybegin(SCOMMENT );out. write(" <span class=\" c\" >//" );}
88
+ {Number} {
89
+ disjointSpan(HtmlConsts . NUMBER_CLASS );
90
+ out. write(yytext());
91
+ disjointSpan(null );
92
+ }
93
+
94
+ \" {
95
+ pushSpan(STRING , HtmlConsts . STRING_CLASS );
96
+ out. write(htmlize(yytext()));
97
+ }
98
+ \' {
99
+ pushSpan(QSTRING , HtmlConsts . STRING_CLASS );
100
+ out. write(htmlize(yytext()));
101
+ }
102
+ "/*" {
103
+ pushSpan(COMMENT , HtmlConsts . COMMENT_CLASS );
104
+ out. write(yytext());
105
+ }
106
+ "//" {
107
+ pushSpan(SCOMMENT , HtmlConsts . COMMENT_CLASS );
108
+ out. write(yytext());
109
+ }
96
110
}
97
111
98
112
<STRING> {
99
- \" {WhiteSpace} \" { out. write(yytext());}
100
- \" { yybegin(YYINITIAL ); out. write(" \" </span>" ); }
101
- \\\\ { out. write(" \\\\ " ); }
102
- \\\" { out. write(" \\\" " ); }
113
+ \\ [ \"\\ ] |
114
+ \" {WhiteSpace} \" { out. write(htmlize(yytext())); }
115
+ \" {
116
+ out. write(htmlize(yytext()));
117
+ yypop();
118
+ }
103
119
}
104
120
105
121
<QSTRING> {
106
- "\\\\ " { out. write(" \\\\ " ); }
107
- "\\\' " { out. write(" \\\' " ); }
108
- \' {WhiteSpace} \' { out. write(yytext()); }
109
- \' { yybegin(YYINITIAL ); out. write(" '</span>" ); }
122
+ \\ [ \'\\ ] |
123
+ \' {WhiteSpace} \' { out. write(htmlize(yytext())); }
124
+ \' {
125
+ out. write(htmlize(yytext()));
126
+ yypop();
127
+ }
110
128
}
111
129
112
130
<COMMENT> {
113
- "*/" { yybegin( YYINITIAL ); out . write( " */</span> " ); }
131
+ "*/" { out . write(yytext()); yypop( ); }
114
132
}
115
133
116
134
<SCOMMENT> {
117
- {WhspChar} * {EOL} {
118
- yybegin( YYINITIAL ); out . write( " </span> " );
135
+ {WhspChar} * {EOL} {
136
+ yypop( );
119
137
startNewLine();
120
138
}
121
139
}
122
140
123
-
124
141
<YYINITIAL, STRING, COMMENT, SCOMMENT, QSTRING> {
125
- "&" { out. write( " &" );}
126
- "<" { out. write( " <" );}
127
- ">" { out. write( " >" );}
142
+ [ &<>\'\" ] { out. write(htmlize(yytext())); }
128
143
{WhspChar} * {EOL} { startNewLine(); }
129
144
{WhiteSpace} { out. write(yytext()); }
130
145
[ !- ~] { out. write(yycharat(0 )); }
131
146
[^\n] { writeUnicodeChar(yycharat(0 )); }
132
147
}
133
148
134
- <STRING, COMMENT, SCOMMENT, STRING, QSTRING> {
149
+ <STRING, COMMENT, SCOMMENT, QSTRING> {
135
150
{FPath}
136
151
{ out. write(Util . breadcrumbPath(urlPrefix+ " path=" ,yytext(),' /' ));}
137
152
@@ -145,12 +160,26 @@ File = [a-zA-Z]{FNameChar}* "." ("js"|"properties"|"props"|"xml"|"conf"|"txt"|"h
145
160
out. write(path);
146
161
out. write(" </a>" );}
147
162
148
- {BrowseableURI} {
149
- appendLink(yytext(), true );
150
- }
151
-
152
163
{FNameChar} + "@" {FNameChar} + "." {FNameChar} +
153
164
{
154
165
writeEMailAddress(yytext());
155
166
}
156
167
}
168
+
169
+ <STRING, SCOMMENT> {
170
+ {BrowseableURI} {
171
+ appendLink(yytext(), true );
172
+ }
173
+ }
174
+
175
+ <COMMENT> {
176
+ {BrowseableURI} {
177
+ appendLink(yytext(), true , StringUtils . END_C_COMMENT );
178
+ }
179
+ }
180
+
181
+ <QSTRING> {
182
+ {BrowseableURI} {
183
+ appendLink(yytext(), true , StringUtils . APOS_NO_BSESC );
184
+ }
185
+ }
0 commit comments