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