forked from jasder/antlr
ignore :: in C++ arg declarations; add test.
This commit is contained in:
parent
5aae2edb24
commit
4f3c7738f3
|
@ -61,6 +61,9 @@ public class TestScopeParsing extends BaseJavaTest {
|
|||
"char *[3] foo = {1,2,3}", "foo:char *[3]={1,2,3}", // not valid C really, C is "type name" however so this is cool (this was broken in 4.5 anyway)
|
||||
"String[] headers", "headers:String[]",
|
||||
|
||||
// C++
|
||||
"std::vector<std::string> x", "x:std::vector<std::string>", // yuck. Don't choose :: as the : of a declaration
|
||||
|
||||
// python/ruby style
|
||||
"i", "i",
|
||||
"i,j", "i, j",
|
||||
|
|
|
@ -103,12 +103,14 @@ public class ScopeParser {
|
|||
|
||||
String declarator = decl.a.substring(0, rightEdgeOfDeclarator + 1);
|
||||
Pair<Integer, Integer> p;
|
||||
if (decl.a.indexOf(':') != -1) {
|
||||
// declarator has type appear after the name
|
||||
String text = decl.a;
|
||||
text = text.replaceAll("::","");
|
||||
if ( text.contains(":") ) {
|
||||
// declarator has type appearing after the name like "x:T"
|
||||
p = _parsePostfixDecl(attr, declarator, action, g);
|
||||
}
|
||||
else {
|
||||
// declarator has type appear before the name
|
||||
// declarator has type appearing before the name like "T x"
|
||||
p = _parsePrefixDecl(attr, declarator, action, g);
|
||||
}
|
||||
int idStart = p.a;
|
||||
|
|
Loading…
Reference in New Issue