Skip to content

Commit

Permalink
Refine Parser skipping over C++11 style { ... } member initialize…
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Jan 4, 2019
1 parent 3da3c7a commit 2cf75e5
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/main/java/org/bytedeco/javacpp/tools/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1840,9 +1840,16 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
tokens.next();
}
if (tokens.get().match(':')) {
int count = 0;
for (Token token = tokens.next(); !token.match(Token.EOF); token = tokens.next()) {
if (token.match('(')) {
count++;
} else if (token.match(')')) {
count--;
}

// consider { ... } preceded by an identifier as an initializer list
if (!token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
if (count == 0 && !token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
tokens.next();
break;
}
Expand Down Expand Up @@ -1958,9 +1965,16 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
}
}
if (tokens.get().match(':')) {
int count = 0;
for (Token token = tokens.next(); !token.match(Token.EOF); token = tokens.next()) {
if (token.match('(')) {
count++;
} else if (token.match(')')) {
count--;
}

// consider { ... } preceded by an identifier as an initializer list
if (!token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
if (count == 0 && !token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
tokens.next();
break;
}
Expand Down Expand Up @@ -2008,9 +2022,16 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
}
dcl.signature = dcl.javaName + params.signature;
if (tokens.get().match(':')) {
int count = 0;
for (Token token = tokens.next(); !token.match(Token.EOF); token = tokens.next()) {
if (token.match('(')) {
count++;
} else if (token.match(')')) {
count--;
}

// consider { ... } preceded by an identifier as an initializer list
if (!token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
if (count == 0 && !token.match(Token.IDENTIFIER) && tokens.get(1).match('{')) {
tokens.next();
break;
}
Expand Down

0 comments on commit 2cf75e5

Please sign in to comment.