+136
-6
lines changedFilter options
+136
-6
lines changed Original file line number Diff line number Diff line change
@@ -1911,6 +1911,34 @@ void Initializer() :
1911
1911
}
1912
1912
1913
1913
1914
+
1915
+
1916
+
/* JLS: https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.3
1917
+
1918
+
ReferenceType:
1919
+
ClassOrInterfaceType
1920
+
TypeVariable
1921
+
ArrayType
1922
+
ClassOrInterfaceType:
1923
+
ClassType
1924
+
InterfaceType
1925
+
ClassType:
1926
+
{Annotation} Identifier [TypeArguments]
1927
+
ClassOrInterfaceType . {Annotation} Identifier [TypeArguments]
1928
+
InterfaceType:
1929
+
ClassType
1930
+
TypeVariable:
1931
+
{Annotation} Identifier
1932
+
ArrayType:
1933
+
PrimitiveType Dims
1934
+
ClassOrInterfaceType Dims
1935
+
TypeVariable Dims
1936
+
Dims:
1937
+
{Annotation} [ ] {{Annotation} [ ]}
1938
+
1939
+
*/
1940
+
1941
+
1914
1942
/*
1915
1943
* Type, name and expression syntax follows.
1916
1944
* Type is the same as "UnannType" in JLS
@@ -1922,18 +1950,48 @@ void Type():
1922
1950
Token t;
1923
1951
}
1924
1952
{
1925
-
LOOKAHEAD(2) ReferenceType()
1953
+
LOOKAHEAD(PrimitiveType() Dims()) ReferenceType()
1926
1954
| PrimitiveType()
1927
1955
}
1928
1956
1957
+
void Dims() #ArrayTypeDims:
1958
+
{}
1959
+
{
1960
+
1961
+
/* @A [] @B []
1962
+
node<ASTDims> {
1963
+
it.dimSize shouldBe 2
1964
+
1965
+
child<ASTDim> {
1966
+
child<ASTAnnotation>(ignoreChildren=true) {
1967
+
it.nameImage shouldBe "A"
1968
+
}
1969
+
}
1970
+
1971
+
child<ASTDim> {
1972
+
child<ASTAnnotation>(ignoreChildren=true) {
1973
+
it.nameImage shouldBe "B"
1974
+
}
1975
+
}
1976
+
}
1977
+
*/
1978
+
1979
+
1980
+
( // LOOKAHEAD((TypeAnnotation())* "[" "]")
1981
+
((TypeAnnotation())* "[" "]") #ArrayTypeDim
1982
+
)+
1983
+
}
1984
+
1929
1985
void ReferenceType():
1930
1986
{}
1931
1987
{
1932
-
// The grammar here is mildly wrong, the annotations can be before each []
1933
-
// This will wait for #997
1934
-
PrimitiveType() (TypeAnnotation())* ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+
1935
-
|
1936
-
( ClassOrInterfaceType()) (TypeAnnotation())* ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })*
1988
+
1989
+
// TypeVariable is ambiguous with ClassOrInterfaceType
1990
+
// Unless! we add a small symbol table to the parser,
1991
+
// keeping track of the in-scope type variables (they're all
1992
+
// necessarily lexically accessible)
1993
+
( PrimitiveType() Dims() ) #ArrayType
1994
+
| ( ClassOrInterfaceType() [ LOOKAHEAD(2) Dims() ] ) #ArrayType(>1)
1937
1995
}
1938
1996
1939
1997
void ClassOrInterfaceType():
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1
+
/**
2
+
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
+
*/
4
+
/* Generated By:JJTree: Do not edit this line. ASTNullLiteral.java */
5
+
6
+
package net.sourceforge.pmd.lang.java.ast;
7
+
8
+
public class ASTArrayType extends AbstractJavaTypeNode {
9
+
public ASTArrayType(int id) {
10
+
super(id);
11
+
}
12
+
13
+
public ASTArrayType(JavaParser p, int id) {
14
+
super(p, id);
15
+
}
16
+
17
+
/**
18
+
* Accept the visitor. *
19
+
*/
20
+
@Override
21
+
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
22
+
return visitor.visit(this, data);
23
+
}
24
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1
+
/**
2
+
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
+
*/
4
+
/* Generated By:JJTree: Do not edit this line. ASTNullLiteral.java */
5
+
6
+
package net.sourceforge.pmd.lang.java.ast;
7
+
8
+
public class ASTArrayTypeDim extends AbstractJavaTypeNode {
9
+
public ASTArrayTypeDim(int id) {
10
+
super(id);
11
+
}
12
+
13
+
public ASTArrayTypeDim(JavaParser p, int id) {
14
+
super(p, id);
15
+
}
16
+
17
+
/**
18
+
* Accept the visitor. *
19
+
*/
20
+
@Override
21
+
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
22
+
return visitor.visit(this, data);
23
+
}
24
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1
+
/**
2
+
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
+
*/
4
+
/* Generated By:JJTree: Do not edit this line. ASTNullLiteral.java */
5
+
6
+
package net.sourceforge.pmd.lang.java.ast;
7
+
8
+
public class ASTArrayTypeDims extends AbstractJavaTypeNode {
9
+
public ASTArrayTypeDims(int id) {
10
+
super(id);
11
+
}
12
+
13
+
public ASTArrayTypeDims(JavaParser p, int id) {
14
+
super(p, id);
15
+
}
16
+
17
+
/**
18
+
* Accept the visitor. *
19
+
*/
20
+
@Override
21
+
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
22
+
return visitor.visit(this, data);
23
+
}
24
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4