Skip to content

Commit 380bb0e

Browse files
committed
Fix Scala {Number}, and use in tokenizer
Also, link identifiers of length=1 per Lubos.
1 parent a6a5de8 commit 380bb0e

File tree

6 files changed

+156
-56
lines changed

6 files changed

+156
-56
lines changed

Diff for: LICENSE-scala.txt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Scala Language Specification
2+
============================
3+
Authors and Contributors
4+
Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak
5+
Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors,
6+
Lukas Rytz, Michel Schinz, Erik Stenman, Matthias Zenger
7+
8+
Markdown Conversion by Iain McGinniss.
9+
10+
Scala License
11+
=============
12+
Copyright (c) 2002- EPFL
13+
Copyright (c) 2011- Lightbend, Inc.
14+
15+
All rights reserved.
16+
17+
Redistribution and use in source and binary forms, with or without
18+
modification, are permitted provided that the following conditions are met:
19+
20+
Redistributions of source code must retain the above copyright notice, this
21+
list of conditions and the following disclaimer.
22+
23+
Redistributions in binary form must reproduce the above copyright notice,
24+
this list of conditions and the following disclaimer in the documentation
25+
and/or other materials provided with the distribution.
26+
27+
Neither the name of the EPFL nor the names of its contributors may be used
28+
to endorse or promote products derived from this software without specific
29+
prior written permission.
30+
31+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
32+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41+
POSSIBILITY OF SUCH DAMAGE.

Diff for: src/org/opensolaris/opengrok/analysis/scala/Consts.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
public class Consts{
3232
public static final Set<String> kwd = new HashSet<String>() ;
3333
static {
34-
//Note that keywords with 1 letter will be ignored since we need at least 2 chars per identifier
3534
kwd.add("abstract");
3635
kwd.add("case");
3736
kwd.add("catch");
@@ -70,6 +69,7 @@ public class Consts{
7069
kwd.add("while");
7170
kwd.add("with");
7271
kwd.add("yield");
73-
}
7472

73+
kwd.add("_"); // "Lexical syntax ... reserved words"
74+
}
7575
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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) 2006, 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+
27+
Number = [\-]? ({integerLiteral} | {floatingPointLiteral})
28+
/*
29+
* Numeric Literal ::= [‘-’] integerLiteral
30+
* | [‘-’] floatingPointLiteral
31+
*
32+
* integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’]
33+
* decimalNumeral ::= ‘0’ | nonZeroDigit {digit}
34+
* hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit {hexDigit}
35+
* digit ::= ‘0’ | nonZeroDigit
36+
* nonZeroDigit ::= ‘1’ | … | ‘9’
37+
* hexDigit ::= ‘0’ | … | ‘9’ | ‘A’ | … | ‘F’ | ‘a’ | … | ‘f’
38+
*/
39+
integerLiteral = ({decimalNumeral} | {hexNumeral}) [Ll]?
40+
decimalNumeral = ([0] | {nonZeroDigit} {digit}*)
41+
hexNumeral = [0][xX] {hexDigit}+
42+
digit = [0-9]
43+
nonZeroDigit = [1-9]
44+
hexDigit = [0-9A-Fa-f]
45+
46+
/*
47+
* floatingPointLiteral ::=
48+
* digit {digit} ‘.’ digit {digit} [exponentPart] [floatType]
49+
* | ‘.’ digit {digit} [exponentPart] [floatType]
50+
* | digit {digit} exponentPart [floatType]
51+
* | digit {digit} [exponentPart] floatType
52+
* exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit {digit}
53+
* floatType ::= ‘F’ | ‘f’ | ‘D’ | ‘d’
54+
*/
55+
floatingPointLiteral = ({digit}+ "." {digit}+ {exponentPart}? {floatType}? |
56+
"." {digit}+ {exponentPart}? {floatType}? |
57+
{digit}+ {exponentPart} {floatType}? |
58+
{digit}+ {exponentPart}? {floatType})
59+
exponentPart = [Ee] [\+\-]? {digit}+
60+
floatType = [FfDd]

Diff for: src/org/opensolaris/opengrok/analysis/scala/ScalaSymbolTokenizer.lex

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
/*
26-
* Gets Java symbols - ignores comments, strings, keywords
26+
* Gets Scala symbols - ignores comments, strings, keywords
2727
*/
2828

2929
package org.opensolaris.opengrok.analysis.scala;
@@ -41,10 +41,10 @@ super(in);
4141
%include CommonTokenizer.lexh
4242
%char
4343

44-
Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
45-
4644
%state STRING COMMENT SCOMMENT QSTRING
4745

46+
%include Common.lexh
47+
%include Scala.lexh
4848
%%
4949

5050
<YYINITIAL> {
@@ -53,6 +53,7 @@ Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
5353
setAttribs(id, yychar, yychar + yylength());
5454
return yystate(); }
5555
}
56+
{Number} {}
5657
\" { yybegin(STRING); }
5758
\' { yybegin(QSTRING); }
5859
"/*" { yybegin(COMMENT); }
@@ -73,9 +74,10 @@ Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
7374
}
7475

7576
<SCOMMENT> {
76-
\n { yybegin(YYINITIAL);}
77+
{EOL} { yybegin(YYINITIAL);}
7778
}
7879

7980
<YYINITIAL, STRING, COMMENT, SCOMMENT, QSTRING> {
81+
{WhiteSpace} |
8082
[^] {}
8183
}

Diff for: src/org/opensolaris/opengrok/analysis/scala/ScalaXref.lex

+1-4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@ import org.opensolaris.opengrok.web.Util;
5252
protected void setLineNumber(int x) { yyline = x; }
5353
%}
5454

55-
Identifier = [a-zA-Z_] [a-zA-Z0-9_]+
56-
5755
File = [a-zA-Z]{FNameChar}* "." ("scala"|"properties"|"props"|"xml"|"conf"|"txt"|"htm"|"html"|"ini"|"jnlp"|"jad"|"diff"|"patch")
5856

59-
Number = (0[xX][0-9a-fA-F]+|[0-9]+\.[0-9]+|[0-9]+)(([eE][+-]?[0-9]+)?[ufdlUFDL]*)?
60-
6157
JavadocWithClassArg = "@throws" | "@exception"
6258
JavadocWithParamNameArg = "@param"
6359

@@ -69,6 +65,7 @@ ParamName = {Identifier} | "<" {Identifier} ">"
6965
%include Common.lexh
7066
%include CommonURI.lexh
7167
%include CommonPath.lexh
68+
%include Scala.lexh
7269
%%
7370
<YYINITIAL>{
7471

0 commit comments

Comments
 (0)