Skip to content

Commit e498034

Browse files
committed
Fix FortranSymbolTokenizer number bug
1 parent f14f432 commit e498034

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
23+
*/
24+
25+
Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
26+
Label = [0-9]+
27+
28+
Number = ([0-9]+\.[0-9]+|[0-9][0-9]* | [0][xX] [0-9a-fA-F]+ )([uUdDlL]+)?

src/org/opensolaris/opengrok/analysis/fortran/FortranSymbolTokenizer.lex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ super(in);
4040
%include CommonTokenizer.lexh
4141
%char
4242

43-
Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
44-
Label = [0-9]+
45-
4643
// (OK to exclude LSTRING state used in FortranXref.)
4744
%state STRING COMMENT SCOMMENT QSTRING
4845

4946
%include Common.lexh
47+
%include Fortran.lexh
5048
%%
5149

5250
<YYINITIAL> {
@@ -57,14 +55,17 @@ Label = [0-9]+
5755
setAttribs(id, yychar, yychar + yylength());
5856
return yystate(); }
5957
}
58+
59+
{Number} {}
60+
6061
\" { yybegin(STRING); }
6162
\' { yybegin(QSTRING); }
6263
\! { yybegin(SCOMMENT); }
6364
}
6465

6566
<STRING> {
66-
\" { yybegin(YYINITIAL); }
6767
\\[\"\\] {}
68+
\" { yybegin(YYINITIAL); }
6869
}
6970

7071
<QSTRING> {

src/org/opensolaris/opengrok/analysis/fortran/FortranXref.lex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,14 @@ import org.opensolaris.opengrok.web.Util;
4747
protected void setLineNumber(int x) { yyline = x; }
4848
%}
4949

50-
Identifier = [a-zA-Z_] [a-zA-Z0-9_]+
51-
Label = [0-9]+
52-
5350
File = [a-zA-Z]{FNameChar}* ".inc"
5451

55-
Number = ([0-9]+\.[0-9]+|[0-9][0-9]*|"0x" [0-9a-fA-F]+ )([udl]+)?
56-
5752
%state STRING COMMENT SCOMMENT QSTRING LCOMMENT
5853

5954
%include Common.lexh
6055
%include CommonURI.lexh
6156
%include CommonPath.lexh
57+
%include Fortran.lexh
6258
%%
6359
<YYINITIAL>{
6460
^{Label} {
@@ -73,7 +69,12 @@ Number = ([0-9]+\.[0-9]+|[0-9][0-9]*|"0x" [0-9a-fA-F]+ )([udl]+)?
7369

7470
{Identifier} {
7571
String id = yytext();
76-
writeSymbol(id, Consts.kwd, yyline, false);
72+
// For historical reasons, FortranXref doesn't link identifiers of length=1
73+
if (id.length() > 1) {
74+
writeSymbol(id, Consts.kwd, yyline, false);
75+
} else {
76+
out.write(id);
77+
}
7778
}
7879

7980
"<" ({File}|{FPath}) ">" {
@@ -110,16 +111,16 @@ Number = ([0-9]+\.[0-9]+|[0-9][0-9]*|"0x" [0-9a-fA-F]+ )([udl]+)?
110111
}
111112

112113
<STRING> {
114+
\\[\"\\] |
113115
\" {WhiteSpace} \" { out.write(htmlize(yytext()));}
114116
\" {
115117
out.write(htmlize(yytext()));
116118
yypop();
117119
}
118-
\\[\"\\] { out.write(htmlize(yytext())); }
119120
}
120121

121122
<QSTRING> {
122-
\\[\'\\] { out.write(htmlize(yytext())); }
123+
\\[\'\\] |
123124
\' {WhiteSpace} \' { out.write(htmlize(yytext())); }
124125
\' {
125126
out.write(htmlize(yytext()));

test/org/opensolaris/opengrok/analysis/fortran/sample.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
197197
*
198198
* Test the input parameters.
199199
*
200-
INFO = 0
200+
INFO = 0 + 0xFFFF - 0XFF - 0xFF00
201201
IF( N.LT.0 ) THEN
202202
INFO = -1
203203
ELSE IF( NRHS.LT.0 ) THEN

test/org/opensolaris/opengrok/analysis/fortran/sample_xref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
<a class="l" name="197" href="#197">197</a><span class="c">*</span>
206206
<a class="l" name="198" href="#198">198</a><span class="c">* Test the input parameters.</span>
207207
<a class="l" name="199" href="#199">199</a><span class="c">*</span>
208-
<a class="hl" name="200" href="#200">200</a> <a href="/source/s?defs=INFO" class="intelliWindow-symbol" data-definition-place="undefined-in-file">INFO</a> = <span class="n">0</span>
208+
<a class="hl" name="200" href="#200">200</a> <a href="/source/s?defs=INFO" class="intelliWindow-symbol" data-definition-place="undefined-in-file">INFO</a> = <span class="n">0</span> + <span class="n">0xFFFF</span> - <span class="n">0XFF</span> - <span class="n">0xFF00</span>
209209
<a class="l" name="201" href="#201">201</a> <b>IF</b>( N.<b>LT</b>.<span class="n">0</span> ) <b>THEN</b>
210210
<a class="l" name="202" href="#202">202</a> <a href="/source/s?defs=INFO" class="intelliWindow-symbol" data-definition-place="undefined-in-file">INFO</a> = -<span class="n">1</span>
211211
<a class="l" name="203" href="#203">203</a> <b>ELSE</b> <b>IF</b>( <a href="/source/s?defs=NRHS" class="intelliWindow-symbol" data-definition-place="undefined-in-file">NRHS</a>.<b>LT</b>.<span class="n">0</span> ) <b>THEN</b>

0 commit comments

Comments
 (0)