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, Chris Fraire <cfraire@me.com>. 22 */ 23 package org.opengrok.indexer.analysis; 24 25 import java.io.IOException; 26 27 /** 28 * Represents an API for JFlex lexers that produce multiple types of derived 29 * OpenGrok documents (e.g., cross-reference documents [xrefs] or Lucene search 30 * documents [tokenizers]) from the same JFlex productions. 31 */ 32 public interface JFlexJointLexer extends JFlexStackingLexer { 33 34 /** 35 * Passes non-symbolic fragment for processing. 36 * @param value the excised fragment 37 * @throws IOException if an error occurs while accepting 38 */ offer(String value)39 void offer(String value) throws IOException; 40 41 /** 42 * Passes a text fragment that is syntactically a symbol for processing. 43 * @param value the excised symbol 44 * @param captureOffset the offset from yychar where {@code value} began 45 * @param ignoreKwd a value indicating whether keywords should be ignored 46 * @return true if the {@code value} was not in keywords or if the 47 * {@code ignoreKwd} was true 48 * @throws IOException if an error occurs while accepting 49 */ offerSymbol(String value, int captureOffset, boolean ignoreKwd)50 boolean offerSymbol(String value, int captureOffset, boolean ignoreKwd) 51 throws IOException; 52 53 /** 54 * Indicates that something unusual happened where normally a symbol would 55 * have been offered. 56 */ skipSymbol()57 void skipSymbol(); 58 59 /** 60 * Passes a text fragment that is syntactically a keyword symbol for 61 * processing. 62 * @param value the excised symbol 63 * @throws IOException if an error occurs while accepting 64 */ offerKeyword(String value)65 void offerKeyword(String value) throws IOException; 66 67 /** 68 * Indicates that the current line is ended. 69 * @throws IOException if an error occurs when handling the EOL 70 */ startNewLine()71 void startNewLine() throws IOException; 72 73 /** 74 * Indicates the closing of an open tag and the opening -- if 75 * {@code className} is non-null -- of a new one. 76 * @param className the class name for the new tag or {@code null} just to 77 * close an open tag. 78 * @throws IOException if an output error occurs 79 */ disjointSpan(String className)80 void disjointSpan(String className) throws IOException; 81 82 /** 83 * Indicates that eligible source code was encountered for physical 84 * lines-of-code count (physical LOC). 85 */ phLOC()86 void phLOC(); 87 } 88