Handle ellipsis as a token in the scanner
This is more correct (previously SWIG incorrectly accepted 3 periods with whitespace between as an ellipsis) and helps avoid conflicts in the grammar.
This commit is contained in:
parent
6db66bc350
commit
98e1251772
4 changed files with 62 additions and 48 deletions
|
|
@ -636,7 +636,7 @@ static int look(Scanner *s) {
|
|||
}
|
||||
|
||||
else if (c == '.')
|
||||
state = 100; /* Maybe a number, maybe just a period */
|
||||
state = 100; /* Maybe a number, maybe ellipsis, just a period */
|
||||
else if (isdigit(c))
|
||||
state = 8; /* A numerical value */
|
||||
else
|
||||
|
|
@ -1330,19 +1330,34 @@ static int look(Scanner *s) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* A period or maybe a floating point number */
|
||||
/* A period or an ellipsis or maybe a floating point number */
|
||||
|
||||
case 100:
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return (0);
|
||||
if (isdigit(c))
|
||||
state = 81;
|
||||
else if (c == '.')
|
||||
state = 101;
|
||||
else {
|
||||
retract(s, 1);
|
||||
return SWIG_TOKEN_PERIOD;
|
||||
}
|
||||
break;
|
||||
|
||||
/* An ellipsis */
|
||||
|
||||
case 101:
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return (0);
|
||||
if (c == '.') {
|
||||
return SWIG_TOKEN_ELLIPSIS;
|
||||
} else {
|
||||
retract(s, 2);
|
||||
return SWIG_TOKEN_PERIOD;
|
||||
}
|
||||
break;
|
||||
|
||||
case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */
|
||||
if ((c = nextchar(s)) == 0)
|
||||
return SWIG_TOKEN_PLUS;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ extern void Scanner_locator(Scanner *, String *loc);
|
|||
#define SWIG_TOKEN_BOOL 32 /* true or false */
|
||||
#define SWIG_TOKEN_WSTRING 33 /* L"str" */
|
||||
#define SWIG_TOKEN_WCHAR 34 /* L'c' */
|
||||
#define SWIG_TOKEN_ELLIPSIS 35 /* ... */
|
||||
|
||||
#define SWIG_TOKEN_ILLEGAL 99
|
||||
#define SWIG_TOKEN_ERROR -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue