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