227N/A/*
227N/A * CDDL HEADER START
227N/A *
227N/A * The contents of this file are subject to the terms of the
227N/A * Common Development and Distribution License (the "License").
227N/A * You may not use this file except in compliance with the License.
227N/A *
227N/A * See LICENSE.txt included in this distribution for the specific
227N/A * language governing permissions and limitations under the License.
227N/A *
227N/A * When distributing Covered Code, include this CDDL HEADER in each
227N/A * file and include the License file at LICENSE.txt.
227N/A * If applicable, add the following below this CDDL HEADER, with the
227N/A * fields enclosed by brackets "[]" replaced with your own identifying
227N/A * information: Portions Copyright [yyyy] [name of copyright owner]
227N/A *
227N/A * CDDL HEADER END
227N/A */
227N/A
227N/A/*
5680N/A * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
227N/A */
5680N/A
5680N/A/*
5680N/A * Cross reference a Lisp file
227N/A */
227N/A
227N/Apackage org.opensolaris.opengrok.analysis.lisp;
6428N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
6428N/Aimport java.io.IOException;
3957N/Aimport java.io.Writer;
844N/Aimport java.io.Reader;
6428N/Aimport org.opensolaris.opengrok.web.Util;
3957N/A%%
6428N/A%public
227N/A%class LispXref
6428N/A%extends JFlexXref
2974N/A%unicode
6428N/A%ignorecase
6428N/A%int
6428N/A%{
6693N/A private int nestedComment;
6428N/A
6693N/A @Override
5680N/A public void reInit(char[] buf, int len) {
6693N/A super.reInit(buf, len);
6693N/A nestedComment = 0;
6693N/A }
6693N/A
5680N/A // TODO move this into an include file when bug #16053 is fixed
227N/A @Override
6428N/A protected int getLineNumber() { return yyline; }
5680N/A @Override
3957N/A protected void setLineNumber(int x) { yyline = x; }
3914N/A%}
3914N/A
6428N/AWhiteSpace = [ \t\f]+
227N/AEOL = \r|\n|\r\n
1938N/AIdentifier = [\-\+\*\!\@\$\%\&\/\?\.\,\:\{\}\=a-zA-Z0-9_\<\>]+
1938N/A
3817N/AURIChar = [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
6605N/AFNameChar = [a-zA-Z0-9_\-\.]
6957N/AFile = [a-zA-Z] {FNameChar}+ "." ([a-zA-Z]+)
3914N/APath = "/"? [a-zA-Z]{FNameChar}* ("/" [a-zA-Z]{FNameChar}*[a-zA-Z0-9])+
3914N/A
3817N/ANumber = ([0-9]+\.[0-9]+|[0-9][0-9]*|"#" [boxBOX] [0-9a-fA-F]+)
%state STRING COMMENT SCOMMENT
%%
<YYINITIAL>{
{Identifier} {
String id = yytext();
writeSymbol(id, Consts.kwd, yyline);
}
{Number} { out.write("<span class=\"n\">");
out.write(yytext());
out.write("</span>"); }
\" { yybegin(STRING);out.write("<span class=\"s\">\"");}
";" { yybegin(SCOMMENT);out.write("<span class=\"c\">;");}
}
<STRING> {
\" {WhiteSpace} \" { out.write(yytext()); }
\" { yybegin(YYINITIAL); out.write("\"</span>"); }
\\\\ { out.write("\\\\"); }
\\\" { out.write("\\\""); }
}
<YYINITIAL, COMMENT> {
"#|" { yybegin(COMMENT);
if (nestedComment++ == 0) { out.write("<span class=\"c\">"); }
out.write("#|");
}
}
<COMMENT> {
"|#" { out.write("|#");
if (--nestedComment == 0) {
yybegin(YYINITIAL);
out.write("</span>");
}
}
}
<SCOMMENT> {
{WhiteSpace}*{EOL} {
yybegin(YYINITIAL); out.write("</span>");
startNewLine();
}
}
<YYINITIAL, STRING, COMMENT, SCOMMENT> {
"&" {out.write( "&amp;");}
"<" {out.write( "&lt;");}
">" {out.write( "&gt;");}
{WhiteSpace}*{EOL} { startNewLine(); }
{WhiteSpace} { out.write(yytext()); }
[!-~] { out.write(yycharat(0)); }
. { writeUnicodeChar(yycharat(0)); }
}
<STRING, COMMENT, SCOMMENT> {
{Path}
{ out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
{File}
{
String path = yytext();
out.write("<a href=\""+urlPrefix+"path=");
out.write(path);
appendProject();
out.write("\">");
out.write(path);
out.write("</a>");}
("http" | "https" | "ftp" ) "://" ({FNameChar}|{URIChar})+[a-zA-Z0-9/]
{
String url = yytext();
out.write("<a href=\"");
out.write(url);out.write("\">");
out.write(url);out.write("</a>");}
{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
{
writeEMailAddress(yytext());
}
}