1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20/* 21 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. 22 * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. 23 * Portions Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>. 24 */ 25 26/* 27 * Number and Identifier must be defined in the specific SQL dialect's .lexh 28 * file. Otherwise, JointSQL.lexh has the definitions shared among dialects. 29 * The subclass must override getDialectKeywords() to return the appropriate 30 * Set for the dialect. 31 */ 32 33%state STRING QUOTED_IDENTIFIER SINGLE_LINE_COMMENT BRACKETED_COMMENT 34 35%% 36 37<YYINITIAL> { 38 {Identifier} { 39 chkLOC(); 40 if (offerSymbol(yytext(), 0, false) && returnOnSymbol()) { 41 return yystate(); 42 } 43 } 44 45 {Number} { 46 chkLOC(); 47 onDisjointSpanChanged(HtmlConsts.NUMBER_CLASS, yychar); 48 offer(yytext()); 49 onDisjointSpanChanged(null, yychar); 50 } 51 52 [nN]? "'" { 53 chkLOC(); 54 String capture = yytext(); 55 String prefix = capture.substring(0, capture.length() - 1); 56 String rest = capture.substring(prefix.length()); 57 offer(prefix); 58 yypush(STRING); 59 onDisjointSpanChanged(HtmlConsts.STRING_CLASS, yychar); 60 offer(rest); 61 } 62 63 \" { 64 chkLOC(); 65 yypush(QUOTED_IDENTIFIER); 66 onDisjointSpanChanged(HtmlConsts.STRING_CLASS, yychar); 67 offer(yytext()); 68 } 69 70 "--" { 71 yypush(SINGLE_LINE_COMMENT); 72 onDisjointSpanChanged(HtmlConsts.COMMENT_CLASS, yychar); 73 offer(yytext()); 74 } 75} 76 77<STRING> { 78 "''" { 79 chkLOC(); 80 offer(yytext()); 81 } 82 "'" { 83 chkLOC(); 84 offer(yytext()); 85 yypop(); 86 } 87} 88 89<QUOTED_IDENTIFIER> { 90 \"\" { 91 chkLOC(); 92 offer(yytext()); 93 } 94 \" { 95 chkLOC(); 96 offer(yytext()); 97 yypop(); 98 } 99} 100 101<SINGLE_LINE_COMMENT> { 102 {WhspChar}*{EOL} { 103 yypop(); 104 onEndOfLineMatched(yytext(), yychar); 105 } 106} 107 108<YYINITIAL, BRACKETED_COMMENT> { 109 "/*" { 110 if (commentLevel++ == 0) { 111 yypush(BRACKETED_COMMENT); 112 onDisjointSpanChanged(HtmlConsts.COMMENT_CLASS, yychar); 113 } 114 offer(yytext()); 115 } 116} 117 118<BRACKETED_COMMENT> { 119 "*/" { 120 offer(yytext()); 121 if (--commentLevel == 0) { 122 yypop(); 123 } 124 } 125} 126 127<YYINITIAL, STRING, QUOTED_IDENTIFIER, SINGLE_LINE_COMMENT, BRACKETED_COMMENT> { 128 {WhspChar}*{EOL} { 129 onEndOfLineMatched(yytext(), yychar); 130 } 131 [[\s]--[\n]] { 132 offer(yytext()); 133 } 134 [^\n] { 135 chkLOC(); 136 offer(yytext()); 137 } 138} 139 140<STRING> { 141 {BrowseableURI} { 142 chkLOC(); 143 if (takeAllContent()) { 144 onUriMatched(yytext(), yychar, SQLUtils.STRINGLITERAL_APOS_DELIMITER); 145 } 146 } 147} 148 149<QUOTED_IDENTIFIER, SINGLE_LINE_COMMENT> { 150 {BrowseableURI} { 151 chkLOC(); 152 if (takeAllContent()) { 153 onUriMatched(yytext(), yychar); 154 } 155 } 156} 157 158<BRACKETED_COMMENT> { 159 {BrowseableURI} { 160 if (takeAllContent()) { 161 onUriMatched(yytext(), yychar, StringUtils.END_C_COMMENT); 162 } 163 } 164} 165