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 * Gets Ada symbols - ignores comments, strings, keywords 27 */ 28 29 package org.opengrok.indexer.analysis.ada; 30 31 import java.io.IOException; 32 import java.util.Locale; 33 import org.opengrok.indexer.web.HtmlConsts; 34 %% 35 %public 36 %class AdaSymbolTokenizer 37 %extends AdaLexer 38 %unicode 39 %ignorecase 40 %int 41 %char 42 %include ../CommonLexer.lexh 43 %{ 44 private String lastSymbol; 45 46 /** 47 * Resets the Ada tracked state; {@inheritDoc} 48 */ 49 @Override reset()50 public void reset() { 51 super.reset(); 52 lastSymbol = null; 53 } 54 55 @Override offer(String value)56 public void offer(String value) throws IOException { 57 // noop 58 } 59 60 @Override offerSymbol(String value,int captureOffset,boolean ignoreKwd)61 public boolean offerSymbol(String value, int captureOffset, 62 boolean ignoreKwd) 63 throws IOException { 64 if (ignoreKwd || !Consts.kwd.contains(value.toLowerCase(Locale.ROOT))) { 65 lastSymbol = value; 66 onSymbolMatched(value, yychar + captureOffset); 67 return true; 68 } else { 69 lastSymbol = null; 70 } 71 return false; 72 } 73 74 @Override skipSymbol()75 public void skipSymbol() { 76 lastSymbol = null; 77 } 78 79 @Override offerKeyword(String value)80 public void offerKeyword(String value) throws IOException { 81 lastSymbol = null; 82 } 83 84 @Override startNewLine()85 public void startNewLine() throws IOException { 86 // noop 87 } 88 89 @Override disjointSpan(String className)90 public void disjointSpan(String className) throws IOException { 91 // noop 92 } 93 94 @Override phLOC()95 public void phLOC() { 96 // noop 97 } 98 takeAllContent()99 protected boolean takeAllContent() { 100 return false; 101 } 102 returnOnSymbol()103 protected boolean returnOnSymbol() { 104 return lastSymbol != null; 105 } 106 107 /** 108 * Gets the constant value created by JFlex to represent SCOMMENT. 109 */ 110 @Override SCOMMENT()111 int SCOMMENT() { return SCOMMENT; } 112 %} 113 114 %include ../Common.lexh 115 %include ../CommonURI.lexh 116 %include ../CommonPath.lexh 117 %include AdaProductions.lexh 118