1275N/A/*
1275N/A * CDDL HEADER START
1275N/A *
1275N/A * The contents of this file are subject to the terms of the
1275N/A * Common Development and Distribution License (the "License").
1275N/A * You may not use this file except in compliance with the License.
1275N/A *
1275N/A * See LICENSE.txt included in this distribution for the specific
1275N/A * language governing permissions and limitations under the License.
1275N/A *
1275N/A * When distributing Covered Code, include this CDDL HEADER in each
1275N/A * file and include the License file at LICENSE.txt.
1275N/A * If applicable, add the following below this CDDL HEADER, with the
1275N/A * fields enclosed by brackets "[]" replaced with your own identifying
1275N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1275N/A *
1275N/A * CDDL HEADER END
1275N/A */
1275N/A
1275N/A/*
1275N/A * Cross reference a C# file
1275N/A * @author Christoph Hofmann - ChristophHofmann AT gmx dot de
1275N/A */
1275N/A
1275N/Apackage org.opensolaris.opengrok.analysis.csharp;
1275N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
1275N/Aimport java.io.IOException;
1275N/Aimport java.io.Writer;
1275N/Aimport java.io.Reader;
1275N/Aimport org.opensolaris.opengrok.web.Util;
1275N/A
1275N/A%%
1275N/A%public
1275N/A%class CSharpXref
1275N/A%extends JFlexXref
1275N/A%unicode
1275N/A%ignorecase
1275N/A%int
1275N/A%{
1275N/A /* Must match WhiteSpace regex */
1275N/A private final static String WHITE_SPACE = "[ \t\f\r]+";
1275N/A
1275N/A // TODO move this into an include file when bug #16053 is fixed
1275N/A @Override
1275N/A protected int getLineNumber() { return yyline; }
1275N/A @Override
1275N/A protected void setLineNumber(int x) { yyline = x; }
1275N/A%}
1275N/A
1275N/A/* Must match WHITE_SPACE constant */
1275N/AWhiteSpace = [ \t\f\r]+
1275N/AEOL = \r|\n|\r\n|\u2028|\u2029|\u000B|\u000C|\u0085
1275N/AIdentifier = [a-zA-Z_] [a-zA-Z0-9_]+
1275N/A
1275N/AURIChar = [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
1275N/AFNameChar = [a-zA-Z0-9_\-\.]
1275N/AFile = [a-zA-Z]{FNameChar}* "." ([chts]|"cs")
1275N/APath = "/"? [a-zA-Z]{FNameChar}* ("/" [a-zA-Z]{FNameChar}*[a-zA-Z0-9])+
1275N/A
1275N/ANumber = (0[xX][0-9a-fA-F]+|[0-9]+\.[0-9]+|[0-9]+)(([eE][+-]?[0-9]+)?[ufdlUFDL]*)?
1275N/A
1275N/A//ClassName = ({Identifier} ".")* {Identifier}
1275N/A//ParamName = {Identifier} | "<" {Identifier} ">"
1275N/A
1275N/A%state STRING COMMENT SCOMMENT QSTRING VSTRING
1275N/A
1275N/A%%
1275N/A<YYINITIAL>{
1275N/A
1275N/A{Identifier} {
1275N/A String id = yytext();
1469N/A writeSymbol(id, Consts.kwd, yyline - 1, false);
1275N/A}
1275N/A
1275N/A"<" ({File}|{Path}) ">" {
1275N/A out.write("&lt;");
1275N/A String path = yytext();
1275N/A path = path.substring(1, path.length() - 1);
1275N/A out.write("<a href=\""+urlPrefix+"path=");
1275N/A out.write(path);
1275N/A appendProject();
1275N/A out.write("\">");
1275N/A out.write(path);
1275N/A out.write("</a>");
1275N/A out.write("&gt;");
1275N/A}
1275N/A
1281N/A/*{Hier}
1281N/A { out.write(Util.breadcrumbPath(urlPrefix+"defs=",yytext(),'.'));}
1275N/A*/
1275N/A{Number} { out.write("<span class=\"n\">"); out.write(yytext()); out.write("</span>"); }
1275N/A
1370N/A \" { yybegin(STRING);out.write("<span class=\"s\">\""); spans.push("s"); }
1370N/A \' { yybegin(QSTRING);out.write("<span class=\"s\">\'"); spans.push("s"); }
1370N/A "/*" { yybegin(COMMENT);out.write("<span class=\"c\">/*"); spans.push("c"); }
1370N/A "//" { yybegin(SCOMMENT);out.write("<span class=\"c\">//"); spans.push("c"); }
1275N/A}
1275N/A
1275N/A<STRING> {
1275N/A \" {WhiteSpace} \" { out.write(yytext());}
1370N/A \" { yybegin(YYINITIAL); out.write("\"</span>"); spans.pop(); }
1275N/A \\\\ { out.write("\\\\"); }
1275N/A \\\" { out.write("\\\""); }
1275N/A}
1275N/A
1275N/A<QSTRING> {
1275N/A "\\\\" { out.write("\\\\"); }
1275N/A "\\\'" { out.write("\\\'"); }
1275N/A \' {WhiteSpace} \' { out.write(yytext()); }
1370N/A \' { yybegin(YYINITIAL); out.write("'</span>"); spans.pop(); }
1275N/A}
1275N/A
1275N/A<VSTRING> {
1275N/A \" {WhiteSpace} \" { out.write(yytext());}
1275N/A "\"\"" { out.write("\"\""); }
1370N/A \" { yybegin(YYINITIAL); out.write("\"</span>"); spans.pop(); }
1275N/A \\ { out.write("\\"); }
1275N/A}
1275N/A
1275N/A<COMMENT> {
1370N/A"*/" { yybegin(YYINITIAL); out.write("*/</span>"); spans.pop(); }
1275N/A}
1275N/A
1275N/A<SCOMMENT> {
1275N/A {WhiteSpace}*{EOL} {
1370N/A yybegin(YYINITIAL); out.write("</span>"); spans.pop();
1275N/A startNewLine();
1275N/A }
1275N/A}
1275N/A
1275N/A<YYINITIAL, STRING, COMMENT, SCOMMENT, QSTRING, VSTRING> {
1275N/A"&" {out.write( "&amp;");}
1275N/A"<" {out.write( "&lt;");}
1275N/A">" {out.write( "&gt;");}
1275N/A{WhiteSpace}*{EOL} { startNewLine(); }
1275N/A {WhiteSpace} { out.write(yytext()); }
1275N/A [!-~] { out.write(yycharat(0)); }
1275N/A . { writeUnicodeChar(yycharat(0)); }
1275N/A}
1275N/A
1275N/A<STRING, COMMENT, SCOMMENT, QSTRING, VSTRING> {
1275N/A{Path}
1281N/A { out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
1275N/A
1275N/A{File}
1275N/A {
1275N/A String path = yytext();
1275N/A out.write("<a href=\""+urlPrefix+"path=");
1275N/A out.write(path);
1275N/A appendProject();
1275N/A out.write("\">");
1275N/A out.write(path);
1275N/A out.write("</a>");}
1275N/A
1275N/A("http" | "https" | "ftp" ) "://" ({FNameChar}|{URIChar})+[a-zA-Z0-9/]
1275N/A {
1275N/A String url = yytext();
1275N/A out.write("<a href=\"");
1472N/A out.write(Util.uriEncodeURL(url));out.write("\">");
1469N/A out.write(Util.htmlize(url));out.write("</a>");}
1275N/A
1275N/A{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
1275N/A {
1275N/A writeEMailAddress(yytext());
1275N/A }
1275N/A}