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) 2005, 2021, Oracle and/or its affiliates. All rights reserved. 22 * Portions Copyright (c) 2017, Chris Fraire <cfraire@me.com>. 23 */ 24 25 package org.opengrok.indexer.analysis.plain; 26 27 import org.opengrok.indexer.analysis.JFlexSymbolMatcher; 28 %% 29 %public 30 %class PlainXref 31 %extends JFlexSymbolMatcher 32 %unicode 33 %ignorecase 34 %int 35 %char 36 %include ../CommonLexer.lexh 37 %include ../CommonXref.lexh 38 39 File = {FNameChar}+ "." ([a-zA-Z]+) {FNameChar}* 40 41 %include ../Common.lexh 42 %include ../CommonURI.lexh 43 %include ../CommonPath.lexh 44 %include ../CommonLaxFPath.lexh 45 %% 46 {File} | {RelaxedMiddleFPath} 47 { 48 phLOC(); 49 String s=yytext(); 50 onFilelikeMatched(s, yychar); 51 } 52 53 {BrowseableURI} { 54 phLOC(); 55 onUriMatched(yytext(), yychar); 56 } 57 58 {FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+ 59 { 60 phLOC(); 61 onEmailAddressMatched(yytext(), yychar); 62 } 63 64 // Bug #13362: If there's a very long sequence that matches {FNameChar}+, 65 // parsing the file will take forever because of all the backtracking. With 66 // this rule, we avoid much of the backtracking and speed up the parsing 67 // (in some cases from hours to seconds!). This rule will not interfere with 68 // the rules above because JFlex always picks the longest match. 69 {FNameChar}+ { phLOC(); onNonSymbolMatched(yytext(), yychar); } 70 71 {WhspChar}*{EOL} { onEndOfLineMatched(yytext(), yychar); } 72 [[\s]--[\n]] { onNonSymbolMatched(yytext(), yychar); } 73 [^\n] { phLOC(); onNonSymbolMatched(yytext(), yychar); } 74