27
27
*/
28
28
29
29
package org. opensolaris. opengrok. analysis. lua;
30
- import org. opensolaris. opengrok. analysis. JFlexXref;
30
+
31
+ import org. opensolaris. opengrok. analysis. JFlexXrefSimple;
32
+ import org. opensolaris. opengrok. web. HtmlConsts;
31
33
import org. opensolaris. opengrok. web. Util;
32
34
33
35
/**
34
36
* @author Evan Kinney
35
37
*/
36
-
37
38
% %
38
39
%public
39
40
%class LuaXref
40
- %extends JFlexXref
41
+ %extends JFlexXrefSimple
41
42
%unicode
42
- %ignorecase
43
43
%int
44
44
%include CommonXref.lexh
45
45
%{
@@ -50,7 +50,8 @@ import org.opensolaris.opengrok.web.Util;
50
50
protected void setLineNumber(int x) { yyline = x; }
51
51
%}
52
52
53
- File = [ a- zA- Z] {FNameChar} * "." ( "lua" | "txt" | "htm" | "html" | "diff" | "patch" )
53
+ File = [ a- zA- Z] {FNameChar} * "." ( [ Ll][ Uu][ Aa] | [ Tt][ Xx][ Tt] |
54
+ [ Hh][ Tt][ Mm][ Ll] ? | [ Dd][ Ii][ Ff][ Ff] | [ Pp][ Aa][ Tt][ Cc][ Hh] )
54
55
55
56
%state STRING LSTRING COMMENT SCOMMENT QSTRING
56
57
@@ -64,12 +65,31 @@ File = [a-zA-Z]{FNameChar}* "." ("lua"|"txt"|"htm"|"html"|"diff"|"patch")
64
65
String id = yytext();
65
66
writeSymbol(id, Consts . kwd, yyline);
66
67
}
67
- {Number} { out. write(" <span class=\" n\" >" ); out. write(yytext()); out. write(" </span>" ); }
68
- \" { yybegin(STRING ); out. write(" <span class=\" s\" >\" " ); }
69
- "[[" { yybegin(LSTRING ); out. write(" <span class=\" s\" >[[" ); }
70
- \' { yybegin(QSTRING ); out. write(" <span class=\" s\" >\' " ); }
71
- "--[[" { yybegin(COMMENT ); out. write(" <span class=\" c\" >--[[" ); }
72
- "--" { yybegin(SCOMMENT ); out. write(" <span class=\" c\" >--" ); }
68
+ {Number} {
69
+ disjointSpan(HtmlConsts . NUMBER_CLASS );
70
+ out. write(yytext());
71
+ disjointSpan(null );
72
+ }
73
+ \" {
74
+ pushSpan(STRING , HtmlConsts . STRING_CLASS );
75
+ out. write(htmlize(yytext()));
76
+ }
77
+ "[[" {
78
+ pushSpan(LSTRING , HtmlConsts . STRING_CLASS );
79
+ out. write(yytext());
80
+ }
81
+ \' {
82
+ pushSpan(QSTRING , HtmlConsts . STRING_CLASS );
83
+ out. write(htmlize(yytext()));
84
+ }
85
+ "--[[" {
86
+ pushSpan(COMMENT , HtmlConsts . COMMENT_CLASS );
87
+ out. write(htmlize(yytext()));
88
+ }
89
+ "--" {
90
+ pushSpan(SCOMMENT , HtmlConsts . COMMENT_CLASS );
91
+ out. write(htmlize(yytext()));
92
+ }
73
93
}
74
94
75
95
"<" ( {File} | {FPath} ) ">" {
@@ -87,35 +107,48 @@ File = [a-zA-Z]{FNameChar}* "." ("lua"|"txt"|"htm"|"html"|"diff"|"patch")
87
107
88
108
<STRING> {
89
109
\\ [ \"\\ ] |
90
- \" {WhiteSpace} \" { out. write(yytext()); }
91
- \" { yybegin(YYINITIAL ); out. write(" \" </span>" ); }
110
+ \" {WhiteSpace} \" { out. write(htmlize(yytext())); }
111
+ \" {
112
+ out. write(htmlize(yytext()));
113
+ yypop();
114
+ }
92
115
}
93
116
94
117
<QSTRING> {
95
118
\\ [ \'\\ ] |
96
- \' {WhiteSpace} \' { out. write(yytext()); }
97
- \' { yybegin(YYINITIAL ); out. write(" '</span>" ); }
119
+ \' {WhiteSpace} \' { out. write(htmlize(yytext())); }
120
+ \' {
121
+ out. write(htmlize(yytext()));
122
+ yypop();
123
+ }
98
124
}
99
125
100
126
<LSTRING> {
101
127
\\ [ \"\\ ] |
102
- \" {WhiteSpace} \" { out. write(yytext());}
103
- "]]" { yybegin(YYINITIAL ); out. write(" ]]</span>" ); }
128
+ \" {WhiteSpace} \" { out. write(htmlize(yytext())); }
129
+ "]]" {
130
+ out. write(htmlize(yytext()));
131
+ yypop();
132
+ }
104
133
}
105
134
106
135
<COMMENT> {
107
- "--]]" { yybegin(YYINITIAL ); out. write(" --]]</span>" ); }
136
+ "]]" {
137
+ out. write(yytext());
138
+ yypop();
139
+ }
108
140
}
109
141
110
142
<SCOMMENT> {
111
- {WhspChar} * {EOL} { yybegin(YYINITIAL ); out. write(" </span>" ); startNewLine(); }
143
+ {WhspChar} * {EOL} {
144
+ yypop();
145
+ startNewLine();
146
+ }
112
147
}
113
148
114
149
<YYINITIAL, STRING, LSTRING, COMMENT, SCOMMENT, QSTRING> {
115
- "&" { out. write( " &" ); }
116
- "<" { out. write( " <" ); }
117
- ">" { out. write( " >" ); }
118
- {WhspChar} * {EOL} { startNewLine(); }
150
+ [ &<>\'\" ] { out. write(htmlize(yytext())); }
151
+ {WhspChar} * {EOL} { startNewLine(); }
119
152
{WhiteSpace} { out. write(yytext()); }
120
153
[ !- ~] { out. write(yytext()); }
121
154
[^\n] { writeUnicodeChar(yycharat(0 )); }
0 commit comments