0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License (the "License").
0N/A * You may not use this file except in compliance with the License.
0N/A *
0N/A * See LICENSE.txt included in this distribution for the specific
0N/A * language governing permissions and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at LICENSE.txt.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information: Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A */
0N/A
0N/A/*
1067N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A */
0N/A
0N/Apackage org.opensolaris.opengrok.analysis.plain;
850N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
937N/Aimport org.opensolaris.opengrok.util.StringUtils;
850N/Aimport java.io.IOException;
850N/Aimport java.io.Writer;
850N/Aimport java.io.Reader;
0N/Aimport org.opensolaris.opengrok.web.Util;
0N/A
0N/A%%
0N/A%public
0N/A%class XMLXref
850N/A%extends JFlexXref
0N/A%unicode
0N/A%ignorecase
0N/A%int
0N/A%{
1020N/A // TODO move this into an include file when bug #16053 is fixed
1020N/A @Override
1020N/A protected int getLineNumber() { return yyline; }
1020N/A @Override
1020N/A protected void setLineNumber(int x) { yyline = x; }
0N/A%}
936N/AWhiteSpace = [ \t\f]
1020N/AEOL = \r|\n|\r\n
0N/AURIChar = [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
0N/AFNameChar = [a-zA-Z0-9_\-\.]
0N/AFile = {FNameChar}+ "." ([a-zA-Z]+) {FNameChar}*
0N/APath = "/"? {FNameChar}+ ("/" {FNameChar}+)+[a-zA-Z0-9]
0N/A
0N/AFileChar = [a-zA-Z_0-9_\-\/]
0N/ANameChar = {FileChar}|"."
0N/A
146N/A%state TAG STRING COMMENT SSTRING CDATA
0N/A%%
0N/A
0N/A<YYINITIAL> {
1370N/A "<!--" { yybegin(COMMENT); out.write("<span class=\"c\">&lt;!--"); spans.push("c"); }
146N/A "<![CDATA[" {
146N/A yybegin(CDATA);
1370N/A out.write("&lt;<span class=\"n\">![CDATA[</span><span class=\"c\">"); spans.push("c");
146N/A }
974N/A "<" { yybegin(TAG); out.write("&lt;");}
0N/A}
0N/A
0N/A<TAG> {
1013N/A[a-zA-Z_0-9]+{WhiteSpace}*\= { out.write("<b>"); out.write(yytext()); out.write("</b>"); }
1013N/A[a-zA-Z_0-9]+ { out.write("<span class=\"n\">"); out.write(yytext()); out.write("</span>"); }
1370N/A\" { yybegin(STRING); out.write("<span class=\"s\">\""); spans.push("s"); }
1370N/A\' { yybegin(SSTRING); out.write("<span class=\"s\">'"); spans.push("s"); }
0N/A">" { yybegin(YYINITIAL); out.write("&gt;"); }
0N/A"<" { yybegin(YYINITIAL); out.write("&lt;"); }
0N/A}
0N/A
0N/A<STRING> {
1013N/A \" {WhiteSpace}* \" { out.write(yytext());}
1370N/A \" { yybegin(TAG); out.write("\"</span>"); spans.pop(); }
0N/A}
1000N/A
1000N/A<STRING, SSTRING, COMMENT, CDATA> {
974N/A "<" {out.write( "&lt;");}
974N/A ">" {out.write( "&gt;");}
0N/A}
0N/A
0N/A<SSTRING> {
1013N/A \' {WhiteSpace}* \' { out.write(yytext());}
1370N/A \' { yybegin(TAG); out.write("'</span>"); spans.pop(); }
0N/A}
0N/A
0N/A<COMMENT> {
1370N/A"-->" { yybegin(YYINITIAL); out.write("--&gt;</span>"); spans.pop(); }
0N/A}
0N/A
146N/A<CDATA> {
146N/A "]]>" {
1370N/A yybegin(YYINITIAL); out.write("<span class=\"n\">]]</span></span>&gt;"); spans.pop();
146N/A }
146N/A}
146N/A
146N/A<YYINITIAL, COMMENT, CDATA, STRING, SSTRING, TAG> {
0N/A{File}|{Path}
606N/A {
606N/A final String path = yytext();
937N/A final char separator = StringUtils.isPossiblyJavaClass(path) ? '.' : '/';
606N/A final String hyperlink =
606N/A Util.breadcrumbPath(urlPrefix + "path=", path, separator,
606N/A getProjectPostfix(), true);
606N/A out.append(hyperlink);
606N/A }
0N/A
0N/A("http" | "https" | "ftp" ) "://" ({FNameChar}|{URIChar})+[a-zA-Z0-9/]
974N/A {String s=yytext();
974N/A out.write("<a href=\"");
1472N/A out.write(Util.uriEncodeURL(s));out.write("\">");
1469N/A out.write(Util.htmlize(s));out.write("</a>");}
0N/A
0N/A{NameChar}+ "@" {NameChar}+ "." {NameChar}+
974N/A {
1122N/A writeEMailAddress(yytext());
974N/A }
0N/A
974N/A"&" {out.write( "&amp;");}
1020N/A{EOL} {startNewLine(); }
974N/A[ !-~\t\f] {out.write(yycharat(0));}
974N/A. { writeUnicodeChar(yycharat(0)); }
35N/A}