xref: /OpenGrok/opengrok-indexer/src/main/jflex/analysis/vb/VBXref.lex (revision d219b4cea555a12b602d2d5518daa22134ad4879)
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) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
22  * Portions Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
23  */
24 
25 /*
26  * Cross reference a VB file
27  */
28 
29 package org.opengrok.indexer.analysis.vb;
30 
31 import java.io.IOException;
32 import org.opengrok.indexer.analysis.JFlexSymbolMatcher;
33 import org.opengrok.indexer.web.HtmlConsts;
34 %%
35 %public
36 %class VBXref
37 %extends JFlexSymbolMatcher
38 %unicode
39 %ignorecase
40 %int
41 %char
42 %include ../CommonLexer.lexh
43 %include ../CommonXref.lexh
44 %{
45     @Override
yypop()46     public void yypop() throws IOException {
47         onDisjointSpanChanged(null, yychar);
48         super.yypop();
49     }
50 
chkLOC()51     protected void chkLOC() {
52         switch (yystate()) {
53             case COMMENT:
54                 break;
55             default:
56                 phLOC();
57                 break;
58         }
59     }
60 %}
61 
62 File = [a-zA-Z]{FNameChar}* "." ("vb"|"cls"|"frm"|"vbs"|"bas"|"ctl")
63 
64 %state  STRING COMMENT
65 
66 %include ../Common.lexh
67 %include ../CommonURI.lexh
68 %include ../CommonPath.lexh
69 %include VB.lexh
70 %%
71 <YYINITIAL>{
72 
73 {Identifier} {
74     chkLOC();
75     String id = yytext();
76     onFilteredSymbolMatched(id, yychar, Consts.reservedKeywords, false);
77 }
78 
79 "<" ({File}|{FPath}) ">" {
80         chkLOC();
81         onNonSymbolMatched("<", yychar);
82         String path = yytext();
83         path = path.substring(1, path.length() - 1);
84         onFilelikeMatched(path, yychar + 1);
85         onNonSymbolMatched(">", yychar + 1 + path.length());
86 }
87 
88 /*{Hier}
89         { onPathlikeMatched(yytext(), '.', false, yychar); }
90 */
91  {Number}        {
92     chkLOC();
93     onDisjointSpanChanged(HtmlConsts.NUMBER_CLASS, yychar);
94     onNonSymbolMatched(yytext(), yychar);
95     onDisjointSpanChanged(null, yychar);
96  }
97 
98  \"   {
99     chkLOC();
100     yypush(STRING);
101     onDisjointSpanChanged(HtmlConsts.STRING_CLASS, yychar);
102     onNonSymbolMatched(yytext(), yychar);
103  }
104  \'   {
105     yypush(COMMENT);
106     onDisjointSpanChanged(HtmlConsts.COMMENT_CLASS, yychar);
107     onNonSymbolMatched(yytext(), yychar);
108  }
109 }
110 
111 <STRING> {
112  \"\" |
113  \" {WhspChar}+ \"    { chkLOC(); onNonSymbolMatched(yytext(), yychar); }
114  \"     {
115     chkLOC();
116     onNonSymbolMatched(yytext(), yychar);
117     yypop();
118  }
119  {WhspChar}*{EOL}    {
120     onDisjointSpanChanged(null, yychar);
121     onEndOfLineMatched(yytext(), yychar);
122     onDisjointSpanChanged(HtmlConsts.STRING_CLASS, yychar);
123  }
124 }
125 
126 <COMMENT> {
127   {WhspChar}*{EOL} {
128     yypop();
129     onEndOfLineMatched(yytext(), yychar);
130   }
131 }
132 
133 
134 <YYINITIAL, STRING, COMMENT> {
135 {WhspChar}*{EOL}    { onEndOfLineMatched(yytext(), yychar); }
136  [[\s]--[\n]]    { onNonSymbolMatched(yytext(), yychar); }
137  [^\n]      { chkLOC(); onNonSymbolMatched(yytext(), yychar); }
138 }
139 
140 <STRING, COMMENT> {
141  {FPath}    {
142     chkLOC();
143     onPathlikeMatched(yytext(), '/', false, yychar);
144  }
145 
146 {File}
147         {
148         chkLOC();
149         String path = yytext();
150         onFilelikeMatched(path, yychar);
151  }
152 
153 {BrowseableURI}    {
154           chkLOC();
155           onUriMatched(yytext(), yychar);
156         }
157 
158 {FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
159         {
160           chkLOC();
161           onEmailAddressMatched(yytext(), yychar);
162         }
163 }
164