xref: /OpenGrok/opengrok-indexer/src/main/jflex/analysis/ruby/RubyXref.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) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
22  * Portions Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
23  */
24 
25 /*
26  * Cross reference a Ruby file
27  */
28 
29 package org.opengrok.indexer.analysis.ruby;
30 
31 import java.io.IOException;
32 import java.util.Set;
33 import java.util.regex.Pattern;
34 import org.opengrok.indexer.web.HtmlConsts;
35 %%
36 %public
37 %class RubyXref
38 %extends RubyLexer
39 %unicode
40 %int
41 %char
42 %include ../CommonLexer.lexh
43 %include ../CommonXref.lexh
44 %{
45     @Override
offer(String value)46     public void offer(String value) throws IOException {
47         onNonSymbolMatched(value, yychar);
48     }
49 
50     @Override
offerSymbol(String value,int captureOffset,boolean ignoreKwd)51     public boolean offerSymbol(String value, int captureOffset,
52             boolean ignoreKwd) throws IOException {
53         if (nameLength(value) <= 0) {
54             onNonSymbolMatched(value, yychar);
55             return false;
56         }
57         Set<String> keywords = ignoreKwd ? null : Consts.kwd;
58         return onFilteredSymbolMatched(value, yychar, keywords);
59     }
60 
61     @Override
skipSymbol()62     public void skipSymbol() {
63         // noop
64     }
65 
66     @Override
offerKeyword(String value)67     public void offerKeyword(String value) throws IOException {
68         onKeywordMatched(value, yychar);
69     }
70 
71     @Override
startNewLine()72     public void startNewLine() throws IOException {
73         onEndOfLineMatched("\n", yychar);
74     }
75 
76     @Override
disjointSpan(String className)77     public void disjointSpan(String className) throws IOException {
78         onDisjointSpanChanged(className, yychar);
79     }
80 
81     /**
82      * If the state is YYINITIAL, then transitions to INTRA; otherwise does
83      * nothing, because other transitions would have saved the state.
84      */
maybeIntraState()85     public void maybeIntraState() {
86         if (yystate() == YYINITIAL) yybegin(INTRA);
87     }
88 
takeAllContent()89     protected boolean takeAllContent() {
90         return true;
91     }
92 
returnOnSymbol()93     protected boolean returnOnSymbol() {
94         return false;
95     }
96 
skipLink(String s,Pattern p)97     protected void skipLink(String s, Pattern p) { /* noop */ }
98 
99     /**
100      * Gets the constant value created by JFlex to represent QUOxLxN.
101      */
102     @Override
QUOxLxN()103     int QUOxLxN() { return QUOxLxN; }
104 
105     /**
106      * Gets the constant value created by JFlex to represent QUOxN.
107      */
108     @Override
QUOxN()109     int QUOxN() { return QUOxN; }
110 
111     /**
112      * Gets the constant value created by JFlex to represent QUOxL.
113      */
114     @Override
QUOxL()115     int QUOxL() { return QUOxL; }
116 
117     /**
118      * Gets the constant value created by JFlex to represent QUO.
119      */
120     @Override
QUO()121     int QUO() { return QUO; }
122 
123     /**
124      * Gets the constant value created by JFlex to represent HEREinxN.
125      */
126     @Override
HEREinxN()127     int HEREinxN() { return HEREinxN; }
128 
129     /**
130      * Gets the constant value created by JFlex to represent HERExN.
131      */
132     @Override
HERExN()133     int HERExN() { return HERExN; }
134 
135     /**
136      * Gets the constant value created by JFlex to represent HEREin.
137      */
138     @Override
HEREin()139     int HEREin() { return HEREin; }
140 
141     /**
142      * Gets the constant value created by JFlex to represent HERE.
143      */
144     @Override
HERE()145     int HERE() { return HERE; }
146 
147     /**
148      * Gets the constant value created by JFlex to represent SCOMMENT.
149      */
150     @Override
SCOMMENT()151     int SCOMMENT() { return SCOMMENT; }
152 
153     /**
154      * Gets the constant value created by JFlex to represent POD.
155      */
156     @Override
POD()157     int POD() { return POD; }
158 %}
159 
160 %include ../Common.lexh
161 %include ../CommonURI.lexh
162 %include ../CommonPath.lexh
163 %include RubyProductions.lexh
164