Avoid parse errors for C++ attributes
Just ignore anything in between [[ and ]] in the scanner, which is better that failing with a parse error. Fixes #1158 Fixes #2286
This commit is contained in:
parent
5a96a39aa4
commit
d3759a9b36
6 changed files with 86 additions and 4 deletions
|
|
@ -596,10 +596,6 @@ static int look(Scanner *s) {
|
|||
state = 3;
|
||||
else if (c == '\\')
|
||||
return SWIG_TOKEN_BACKSLASH;
|
||||
else if (c == '[')
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
else if (c == ']')
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
else if (c == '@')
|
||||
return SWIG_TOKEN_AT;
|
||||
else if (c == '$')
|
||||
|
|
@ -637,6 +633,10 @@ static int look(Scanner *s) {
|
|||
|
||||
else if (c == '.')
|
||||
state = 100; /* Maybe a number, maybe ellipsis, just a period */
|
||||
else if (c == '[')
|
||||
state = 102; /* Maybe a bracket or a double bracket */
|
||||
else if (c == ']')
|
||||
state = 103; /* Maybe a bracket or a double bracket */
|
||||
else if (isdigit(c))
|
||||
state = 8; /* A numerical value */
|
||||
else
|
||||
|
|
@ -1358,6 +1358,31 @@ static int look(Scanner *s) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* A left bracket or a double left bracket */
|
||||
case 102:
|
||||
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
} else if (c == '[') {
|
||||
return SWIG_TOKEN_LLBRACKET;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_LBRACKET;
|
||||
}
|
||||
break;
|
||||
|
||||
/* a right bracket or a double right bracket */
|
||||
case 103:
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
} else if (c == ']') {
|
||||
return SWIG_TOKEN_RRBRACKET;
|
||||
} else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_RBRACKET;
|
||||
}
|
||||
break;
|
||||
|
||||
case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return SWIG_TOKEN_PLUS;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ extern void Scanner_locator(Scanner *, String *loc);
|
|||
#define SWIG_TOKEN_WSTRING 33 /* L"str" */
|
||||
#define SWIG_TOKEN_WCHAR 34 /* L'c' */
|
||||
#define SWIG_TOKEN_ELLIPSIS 35 /* ... */
|
||||
#define SWIG_TOKEN_LLBRACKET 36 /* [[ */
|
||||
#define SWIG_TOKEN_RRBRACKET 37 /* ]] */
|
||||
|
||||
#define SWIG_TOKEN_ILLEGAL 99
|
||||
#define SWIG_TOKEN_ERROR -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue