Cross Reference: PythonXref.lex
xref
: /
opengrok-jel
/
src
/
org
/
opensolaris
/
opengrok
/
analysis
/
python
/
PythonXref.lex
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
1028
N/A
/*
1028
N/A
* CDDL HEADER START
1028
N/A
*
1028
N/A
* The contents of this file are subject to the terms of the
1028
N/A
* Common Development and Distribution License (the "License").
1028
N/A
* You may not use this file except in compliance with the License.
1028
N/A
*
1028
N/A
* See
LICENSE.txt
included in this distribution for the specific
1028
N/A
* language governing permissions and limitations under the License.
1028
N/A
*
1028
N/A
* When distributing Covered Code, include this CDDL HEADER in each
1028
N/A
* file and include the License file at
LICENSE.txt
.
1028
N/A
* If applicable, add the following below this CDDL HEADER, with the
1028
N/A
* fields enclosed by brackets "[]" replaced with your own identifying
1028
N/A
* information: Portions Copyright [yyyy] [name of copyright owner]
1028
N/A
*
1028
N/A
* CDDL HEADER END
1028
N/A
*/
1028
N/A
1028
N/A
/*
1058
N/A
* Copyright (c) 2010, Oracle
and
/
or
its affiliates. All rights reserved.
1028
N/A
*/
1028
N/A
1028
N/A
/*
1028
N/A
* Cross reference a Python file
1028
N/A
*/
1028
N/A
1028
N/A
package
org
.
opensolaris
.
opengrok
.
analysis
.
python
;
1028
N/A
import
org
.
opensolaris
.
opengrok
.
analysis
.
JFlexXref
;
1028
N/A
import
java
.
io
.
IOException
;
1028
N/A
import
java
.
io
.
Writer
;
1028
N/A
import
java
.
io
.
Reader
;
1028
N/A
import
org
.
opensolaris
.
opengrok
.
web
.
Util
;
1028
N/A
1028
N/A
%%
1028
N/A
%
public
1028
N/A
%
class
PythonXref
1028
N/A
%
extends
JFlexXref
1028
N/A
%
unicode
1028
N/A
%
ignorecase
1028
N/A
%
int
1028
N/A
%{
1028
N/A
// TODO move this into an include file when bug #16053 is fixed
1028
N/A
@
Override
1028
N/A
protected
int
getLineNumber
() {
return
yyline
; }
1028
N/A
@
Override
1028
N/A
protected
void
setLineNumber
(
int
x) {
yyline
= x; }
1028
N/A
%}
1028
N/A
1028
N/A
WhiteSpace
= [ \t\f]+
1028
N/A
EOL
= \r|\n|\r\n
1028
N/A
Identifier
= [a-
zA
-
Z_
] [a-
zA
-
Z0
-
9
_]+
1028
N/A
1028
N/A
URIChar
= [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
1028
N/A
FNameChar
= [a-
zA
-
Z0
-
9
_\-\.]
1072
N/A
File
= [a-
zA
-Z]{
FNameChar
}*
"."
(
"py"
|
"pm"
|
"conf"
|
"txt"
|
"htm"
|
"html"
|
"xml"
|
"ini"
|
"diff"
|
"patch"
)
1028
N/A
Path
=
"/"
? [a-
zA
-Z]{
FNameChar
}* (
"/"
[a-
zA
-Z]{
FNameChar
}*[a-
zA
-
Z0
-
9
])+
1028
N/A
1073
N/A
Number
= (0[
xX
][0-
9
a-
fA
-F]+|[0-
9
]+\.[0-
9
]+|[0-
9
]+)(([
eE
][+-]?[0-
9
]+)?[
loxbLOXBjJ
]*)?
1028
N/A
1028
N/A
%
state
STRING
LSTRING
SCOMMENT
QSTRING
LQSTRING
1028
N/A
1028
N/A
%%
1028
N/A
<
YYINITIAL
>{
1028
N/A
1028
N/A
{
Identifier
} {
1028
N/A
String
id
=
yytext
();
1469
N/A
writeSymbol
(
id
,
Consts
.
kwd
,
yyline
,
false
);
1028
N/A
}
1028
N/A
1028
N/A
"<"
({
File
}|{
Path
})
">"
{
1028
N/A
out
.
write
(
"<"
);
1028
N/A
String
path
=
yytext
();
1028
N/A
path
=
path
.
substring
(
1
,
path
.
length
() -
1
);
1028
N/A
out
.
write
(
"<a href=\""
+
urlPrefix
+
"path="
);
1028
N/A
out
.
write
(
path
);
1028
N/A
appendProject
();
1028
N/A
out
.
write
(
"\">"
);
1028
N/A
out
.
write
(
path
);
1028
N/A
out
.
write
(
"</a>"
);
1028
N/A
out
.
write
(
">"
);
1028
N/A
}
1028
N/A
1028
N/A
{
Number
} {
out
.
write
(
"<span class=\"n\">"
);
out
.
write
(
yytext
());
out
.
write
(
"</span>"
); }
1028
N/A
1370
N/A
\
" { yybegin(STRING);out.write("
<
span
class
=\
"s\">\""
);
spans
.
push
(
"s"
); }
1370
N/A
\
"\"\" { yybegin(LSTRING);out.write("
<
span
class
=\
"s\">\"\"\""
);
spans
.
push
(
"s"
); }
1370
N/A
\
' { yybegin(QSTRING);out.write("<span class=\"s\">\'"); spans.push("s"); }
1370
N/A
\'\'\' { yybegin(LQSTRING);out.write("<span class=\"s\">\'\'\'"); spans.push("s"); }
1370
N/A
"#" { yybegin(SCOMMENT);out.write("<span class=\"c\">#"); spans.push("c"); }
1028
N/A
}
1028
N/A
1028
N/A
<STRING> {
1370
N/A
\" { yybegin(YYINITIAL); out.write("\"</span>"); spans.pop(); }
1028
N/A
\\\\ { out.write("\\\\"); }
1028
N/A
\\\" { out.write("\\\""); }
1028
N/A
{WhiteSpace}*{EOL} {
1370
N/A
yybegin(YYINITIAL); out.write("</span>"); spans.pop();
1028
N/A
startNewLine();
1028
N/A
}
1028
N/A
}
1028
N/A
1028
N/A
<QSTRING> {
1028
N/A
"\\\\" { out.write("\\\\"); }
1028
N/A
"\\\'" { out.write("\\\'"); }
1028
N/A
\' {WhiteSpace} \' { out.write(yytext()); }
1370
N/A
\' { yybegin(YYINITIAL); out.write("'
</
span
>
"); spans.pop(); }
1028
N/A
{WhiteSpace}*{EOL} {
1370
N/A
yybegin(YYINITIAL); out.write("
</
span
>
"); spans.pop();
1028
N/A
startNewLine();
1028
N/A
}
1028
N/A
}
1028
N/A
1028
N/A
<LSTRING> {
1028
N/A
\" {WhiteSpace} \" { out.write(yytext());}
1370
N/A
\"\"\" { yybegin(YYINITIAL); out.write("
\
"\"\"</span>"
);
spans
.
pop
(); }
1028
N/A
\\\\ {
out
.
write
(
"\\\\"
); }
1028
N/A
\\\
" { out.write("
\\\
""
); }
1028
N/A
}
1028
N/A
1028
N/A
<
LQSTRING
> {
1028
N/A
"\\\\"
{
out
.
write
(
"\\\\"
); }
1028
N/A
"\\\'"
{
out
.
write
(
"\\\'"
); }
1028
N/A
\
' {WhiteSpace} \' { out.write(yytext()); }
1370
N/A
\'\'\' { yybegin(YYINITIAL); out.write("'
''
</
span
>
"); spans.pop(); }
1028
N/A
}
1028
N/A
1028
N/A
<SCOMMENT> {
1028
N/A
{WhiteSpace}*{EOL} {
1370
N/A
yybegin(YYINITIAL); out.write("
</
span
>
"); spans.pop();
1028
N/A
startNewLine();
1028
N/A
}
1028
N/A
}
1028
N/A
1028
N/A
1028
N/A
<YYINITIAL, STRING, SCOMMENT, QSTRING , LSTRING, LQSTRING> {
1028
N/A
"
&
" {out.write( "
&
amp
;
");}
1028
N/A
"
<
" {out.write( "
&
lt
;
");}
1028
N/A
"
>
" {out.write( "
&
gt
;
");}
1028
N/A
{WhiteSpace}*{EOL} { startNewLine(); }
1028
N/A
{WhiteSpace} { out.write(yytext()); }
1028
N/A
[!-~] { out.write(yycharat(0)); }
1028
N/A
. { writeUnicodeChar(yycharat(0)); }
1028
N/A
}
1028
N/A
1028
N/A
<STRING, SCOMMENT, STRING, QSTRING , LSTRING, LQSTRING> {
1028
N/A
{Path}
1028
N/A
{ out.write(Util.breadcrumbPath(urlPrefix+"
path
=
",yytext(),'/'));}
1028
N/A
1028
N/A
{File}
1028
N/A
{
1028
N/A
String path = yytext();
1028
N/A
out.write("
<a
href
=\
""
+
urlPrefix
+
"path="
);
1028
N/A
out
.
write
(
path
);
1028
N/A
appendProject
();
1028
N/A
out
.
write
(
"\">"
);
1028
N/A
out
.
write
(
path
);
1028
N/A
out
.
write
(
"</a>"
);}
1028
N/A
1028
N/A
(
"http"
|
"https"
|
"ftp"
)
"://"
({
FNameChar
}|{
URIChar
})+[a-
zA
-
Z0
-
9
/]
1028
N/A
{
1028
N/A
String
url
=
yytext
();
1028
N/A
out
.
write
(
"<a href=\""
);
1472
N/A
out
.
write
(
Util
.
uriEncodeURL
(
url
));
out
.
write
(
"\">"
);
1469
N/A
out
.
write
(
Util
.
htmlize
(
url
));
out
.
write
(
"</a>"
);}
1028
N/A
1028
N/A
{
FNameChar
}+
"@"
{
FNameChar
}+
"."
{
FNameChar
}+
1028
N/A
{
1122
N/A
writeEMailAddress
(
yytext
());
1028
N/A
}
1028
N/A
}