xref: /OpenGrok/opengrok-indexer/src/main/jflex/analysis/terraform/TerraformXref.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-2020, Chris Fraire <cfraire@me.com>.
23  */
24 
25 /*
26  * Cross references a Terraform file.
27  */
28 
29 package org.opengrok.indexer.analysis.terraform;
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 TerraformXref
38 %extends TerraformLexer
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, boolean ignoreKwd)
52             throws IOException {
53         Set<String> keywords = ignoreKwd ? null : Consts.KEYWORDS;
54         return onFilteredSymbolMatched(value, yychar, keywords);
55     }
56 
57     /** Does nothing. */
58     @Override
skipSymbol()59     public void skipSymbol() {
60     }
61 
62     @Override
offerKeyword(String value)63     public void offerKeyword(String value) throws IOException {
64         onKeywordMatched(value, yychar);
65     }
66 
67     @Override
startNewLine()68     public void startNewLine() throws IOException {
69         onEndOfLineMatched("\n", yychar);
70     }
71 
72     @Override
disjointSpan(String className)73     public void disjointSpan(String className) throws IOException {
74         onDisjointSpanChanged(className, yychar);
75     }
76 
77     /** Gets the value {@code true}. */
takeAllContent()78     protected boolean takeAllContent() {
79         return true;
80     }
81 
82     /** Gets the value {@code false}. */
returnOnSymbol()83     protected boolean returnOnSymbol() {
84         return false;
85     }
86 
87     /**
88      * Gets the constant value created by JFlex to represent COMMENT.
89      */
90     @Override
COMMENT()91     public int COMMENT() {
92         return COMMENT;
93     }
94 
95     /**
96      * Gets the constant value created by JFlex to represent SCOMMENT.
97      */
98     @Override
SCOMMENT()99     public int SCOMMENT() {
100         return SCOMMENT;
101     }
102 
103     /**
104      * Gets the constant value created by JFlex to represent HERE.
105      */
106     @Override
HERE()107     public int HERE() {
108         return HERE;
109     }
110 
111     /**
112      * Gets the constant value created by JFlex to represent HEREin.
113      */
114     @Override
HEREin()115     public int HEREin() {
116         return HEREin;
117     }
118 %}
119 
120 %include ../Common.lexh
121 %include ../CommonURI.lexh
122 %include ../CommonPath.lexh
123 // Terraform.lexh comes after HCL so that Terraform macros supersede.
124 %include ../hcl/HCL.lexh
125 %include Terraform.lexh
126 
127 %%
128 // TerraformProductions.lexh comes first so that its expressions are preferred.
129 %include TerraformProductions.lexh
130 %include ../hcl/HCLProductions.lexh
131