670N/A/*
670N/A * CDDL HEADER START
670N/A *
670N/A * The contents of this file are subject to the terms of the
670N/A * Common Development and Distribution License (the "License").
670N/A * You may not use this file except in compliance with the License.
670N/A *
670N/A * See LICENSE.txt included in this distribution for the specific
670N/A * language governing permissions and limitations under the License.
670N/A *
670N/A * When distributing Covered Code, include this CDDL HEADER in each
670N/A * file and include the License file at LICENSE.txt.
670N/A * If applicable, add the following below this CDDL HEADER, with the
670N/A * fields enclosed by brackets "[]" replaced with your own identifying
670N/A * information: Portions Copyright [yyyy] [name of copyright owner]
670N/A *
670N/A * CDDL HEADER END
670N/A */
670N/A
670N/A/*
1162N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
670N/A */
670N/A
670N/A/*
1058N/A * Cross reference a C++ file
670N/A */
670N/A
670N/Apackage org.opensolaris.opengrok.analysis.c;
850N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
850N/Aimport java.io.IOException;
850N/Aimport java.io.Writer;
850N/Aimport java.io.Reader;
670N/Aimport org.opensolaris.opengrok.web.Util;
670N/A
670N/A%%
670N/A%public
670N/A%class CxxXref
850N/A%extends JFlexXref
670N/A%unicode
670N/A%ignorecase
670N/A%int
670N/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; }
670N/A%}
670N/A
936N/AWhiteSpace = [ \t\f]+
1020N/AEOL = \r|\n|\r\n
670N/AIdentifier = [a-zA-Z_] [a-zA-Z0-9_]+
670N/A
670N/AURIChar = [\?\+\%\&\:\/\.\@\_\;\=\$\,\-\!\~\*\\]
670N/AFNameChar = [a-zA-Z0-9_\-\.]
1070N/AFile = [a-zA-Z]{FNameChar}* "." ([chts]|"conf"|"java"|"cpp"|"hpp"|"CC"|"txt"|"htm"|"html"|"pl"|"xml"|"cc"|"cxx"|"c++"|"hh"|"hxx"|"h++"|"diff"|"patch")
670N/APath = "/"? [a-zA-Z]{FNameChar}* ("/" [a-zA-Z]{FNameChar}*[a-zA-Z0-9])+
670N/A
1073N/ANumber = (0[xX][0-9a-fA-F]+|[0-9]+\.[0-9]+|[1-9][0-9]*)(([eE][+-]?[0-9]+)?[ufdlUFDL]*)?
670N/A
670N/A%state STRING COMMENT SCOMMENT QSTRING
670N/A
670N/A%%
670N/A<YYINITIAL>{
943N/A
943N/A{Identifier} {
943N/A String id = yytext();
1469N/A writeSymbol(id, CxxConsts.kwd, yyline, false);
943N/A}
670N/A
1163N/A"<" ({File}|{Path}|{Identifier}) ">" {
1013N/A out.write("&lt;");
1162N/A String path = yytext().substring(1, yylength() - 1);
1162N/A out.write(Util.breadcrumbPath(urlPrefix + "path=", path));
1013N/A out.write("&gt;");
1013N/A}
670N/A
974N/A/*{Hier}
974N/A { out.write(Util.breadcrumbPath(urlPrefix+"defs=",yytext(),'.'));}
670N/A*/
1013N/A{Number} { out.write("<span class=\"n\">"); out.write(yytext()); out.write("</span>"); }
670N/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"); }
670N/A}
670N/A
670N/A<STRING> {
1013N/A \" {WhiteSpace} \" { out.write(yytext()); }
1370N/A \" { yybegin(YYINITIAL); out.write("\"</span>"); spans.pop(); }
974N/A \\\\ { out.write("\\\\"); }
974N/A \\\" { out.write("\\\""); }
670N/A}
670N/A
670N/A<QSTRING> {
670N/A "\\\\" { out.write("\\\\"); }
670N/A "\\'" { out.write("\\\'"); }
1013N/A \' {WhiteSpace} \' { out.write(yytext()); }
1370N/A \' { yybegin(YYINITIAL); out.write("'</span>"); spans.pop(); }
670N/A}
670N/A
670N/A<COMMENT> {
1370N/A"*/" { yybegin(YYINITIAL); out.write("*/</span>"); spans.pop(); }
670N/A}
670N/A
670N/A<SCOMMENT> {
1370N/A{WhiteSpace}*{EOL} { yybegin(YYINITIAL); out.write("</span>"); spans.pop();
1020N/A startNewLine();}
670N/A}
670N/A
670N/A
670N/A<YYINITIAL, STRING, COMMENT, SCOMMENT, QSTRING> {
974N/A"&" {out.write( "&amp;");}
974N/A"<" {out.write( "&lt;");}
974N/A">" {out.write( "&gt;");}
1020N/A{WhiteSpace}*{EOL} { startNewLine(); }
1013N/A {WhiteSpace} { out.write(yytext()); }
974N/A [!-~] { out.write(yycharat(0)); }
974N/A . { writeUnicodeChar(yycharat(0)); }
670N/A}
670N/A
670N/A<STRING, COMMENT, SCOMMENT, STRING, QSTRING> {
670N/A{Path}
974N/A { out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
670N/A
670N/A{File}
974N/A {
1013N/A String path = yytext();
974N/A out.write("<a href=\""+urlPrefix+"path=");
1013N/A out.write(path);
1013N/A appendProject();
1013N/A out.write("\">");
1013N/A out.write(path);
1013N/A out.write("</a>");}
670N/A
670N/A("http" | "https" | "ftp" ) "://" ({FNameChar}|{URIChar})+[a-zA-Z0-9/]
974N/A {
1013N/A String url = yytext();
974N/A out.write("<a href=\"");
1472N/A out.write(Util.uriEncodeURL(url));out.write("\">");
1469N/A out.write(Util.htmlize(url));out.write("</a>");}
670N/A
670N/A{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
974N/A {
1122N/A writeEMailAddress(yytext());
974N/A }
670N/A}