1431N/A/*
1431N/A * CDDL HEADER START
1431N/A *
1431N/A * The contents of this file are subject to the terms of the
1431N/A * Common Development and Distribution License (the "License").
1431N/A * You may not use this file except in compliance with the License.
1431N/A *
1431N/A * See LICENSE.txt included in this distribution for the specific
1431N/A * language governing permissions and limitations under the License.
1431N/A *
1431N/A * When distributing Covered Code, include this CDDL HEADER in each
1431N/A * file and include the License file at LICENSE.txt.
1431N/A * If applicable, add the following below this CDDL HEADER, with the
1431N/A * fields enclosed by brackets "[]" replaced with your own identifying
1431N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1431N/A *
1431N/A * CDDL HEADER END
1431N/A */
1431N/A
1431N/A/*
1431N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
1431N/A */
1431N/A
1431N/Apackage org.opensolaris.opengrok.analysis.sql;
1431N/Aimport org.opensolaris.opengrok.analysis.JFlexXref;
1431N/Aimport java.io.IOException;
1431N/Aimport java.io.Writer;
1431N/Aimport java.io.Reader;
1431N/Aimport org.opensolaris.opengrok.web.Util;
1431N/A
1431N/A%%
1431N/A%public
1431N/A%class PLSQLXref
1431N/A%extends JFlexXref
1431N/A%unicode
1431N/A%ignorecase
1431N/A%int
1431N/A%{
1431N/A private int commentLevel;
1431N/A
1431N/A // TODO move this into an include file when bug #16053 is fixed
1431N/A @Override
1431N/A protected int getLineNumber() { return yyline; }
1431N/A @Override
1431N/A protected void setLineNumber(int x) { yyline = x; }
1431N/A%}
1431N/A
1431N/ASign = "+" | "-"
1431N/ASimpleNumber = [0-9]+ | [0-9]+ "." [0-9]* | [0-9]* "." [0-9]+
1431N/AScientificNumber = ({SimpleNumber} [eE] {Sign}? [0-9]+)
1431N/A
1431N/ANumber = {Sign}? ({SimpleNumber} | {ScientificNumber})
1431N/A
1431N/AIdentifier = [a-zA-Z] [a-zA-Z0-9_$#]*
1431N/A
1431N/AWhitespace = [ \t\f]+
1431N/AEOL = \r|\n|\r\n
1431N/A
1431N/A%state STRING QUOTED_IDENTIFIER SINGLE_LINE_COMMENT BRACKETED_COMMENT
1431N/A
1431N/A%%
1431N/A
1431N/A<YYINITIAL> {
1431N/A {Identifier} {
1431N/A String id = yytext();
1469N/A writeSymbol(id, Consts.getReservedKeywords(), yyline, true);
1431N/A }
1431N/A
1431N/A {Number} {
1431N/A out.append("<span class=\"n\">").append(yytext()).append("</span>");
1431N/A }
1431N/A
1432N/A "'" { yybegin(STRING); out.append("<span class=\"s\">'"); spans.push("s"); }
1431N/A
1432N/A \" { yybegin(QUOTED_IDENTIFIER); out.append("<span class=\"s\">\""); spans.push("s"); }
1431N/A
1432N/A "--" { yybegin(SINGLE_LINE_COMMENT); out.append("<span class=\"c\">--"); spans.push("c"); }
1431N/A
1431N/A "/*" {
1431N/A yybegin(BRACKETED_COMMENT);
1431N/A commentLevel = 1;
1432N/A out.append("<span class=\"c\">/*"); spans.push("c");
1431N/A }
1431N/A}
1431N/A
1431N/A<STRING> {
1431N/A "''" { out.append("''"); }
1432N/A "'" { yybegin(YYINITIAL); out.append("'</span>"); spans.pop(); }
1431N/A}
1431N/A
1431N/A<QUOTED_IDENTIFIER> {
1431N/A \"\" { out.append("\"\""); }
1432N/A \" { yybegin(YYINITIAL); out.append("\"</span>"); spans.pop(); }
1431N/A}
1431N/A
1431N/A<SINGLE_LINE_COMMENT> {
1431N/A {EOL} {
1431N/A yybegin(YYINITIAL);
1432N/A out.append("</span>"); spans.pop();
1431N/A startNewLine();
1431N/A }
1431N/A}
1431N/A
1431N/A<BRACKETED_COMMENT> {
1431N/A "/*" { out.append(yytext()); commentLevel++; }
1431N/A "*/" {
1431N/A commentLevel--;
1431N/A out.append(yytext());
1431N/A if (commentLevel == 0) {
1431N/A yybegin(YYINITIAL);
1431N/A out.append("</span>");
1432N/A spans.pop();
1431N/A }
1431N/A }
1431N/A}
1431N/A
1431N/A<YYINITIAL, STRING, QUOTED_IDENTIFIER, SINGLE_LINE_COMMENT, BRACKETED_COMMENT> {
1431N/A "&" { out.append( "&amp;"); }
1431N/A "<" { out.append( "&lt;"); }
1431N/A ">" { out.append( "&gt;"); }
1431N/A {EOL} { startNewLine(); }
1431N/A {Whitespace} { out.append(yytext()); }
1431N/A [ \t\f\r!-~] { out.append(yycharat(0)); }
1431N/A . { writeUnicodeChar(yycharat(0)); }
1431N/A}