PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ yysyntax_error()

static int yysyntax_error ( YYSIZE_T yymsg_alloc,
char **  yymsg,
yytype_int16 yyssp,
int  yytoken 
)
static

Definition at line 1244 of file lwin_wkt_parse.c.

References YY_, YY_NULLPTR, YYCASE_, yycheck, YYEMPTY, YYLAST, YYNTOKENS, yypact, yypact_value_is_default, YYSIZE_T, YYSTACK_ALLOC_MAXIMUM, yystrlen(), yytable, yytable_value_is_error, YYTERROR, yytname, and yytnamerr().

1246 {
1247  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1248  YYSIZE_T yysize = yysize0;
1249  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1250  /* Internationalized format string. */
1251  const char *yyformat = YY_NULLPTR;
1252  /* Arguments of yyformat. */
1253  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1254  /* Number of reported tokens (one for the "unexpected", one per
1255  "expected"). */
1256  int yycount = 0;
1257 
1258  /* There are many possibilities here to consider:
1259  - If this state is a consistent state with a default action, then
1260  the only way this function was invoked is if the default action
1261  is an error action. In that case, don't check for expected
1262  tokens because there are none.
1263  - The only way there can be no lookahead present (in yychar) is if
1264  this state is a consistent state with a default action. Thus,
1265  detecting the absence of a lookahead is sufficient to determine
1266  that there is no unexpected or expected token to report. In that
1267  case, just report a simple "syntax error".
1268  - Don't assume there isn't a lookahead just because this state is a
1269  consistent state with a default action. There might have been a
1270  previous inconsistent state, consistent state with a non-default
1271  action, or user semantic action that manipulated yychar.
1272  - Of course, the expected token list depends on states to have
1273  correct lookahead information, and it depends on the parser not
1274  to perform extra reductions after fetching a lookahead from the
1275  scanner and before detecting a syntax error. Thus, state merging
1276  (from LALR or IELR) and default reductions corrupt the expected
1277  token list. However, the list is correct for canonical LR with
1278  one exception: it will still contain any token that will not be
1279  accepted due to an error action in a later state.
1280  */
1281  if (yytoken != YYEMPTY)
1282  {
1283  int yyn = yypact[*yyssp];
1284  yyarg[yycount++] = yytname[yytoken];
1285  if (!yypact_value_is_default (yyn))
1286  {
1287  /* Start YYX at -YYN if negative to avoid negative indexes in
1288  YYCHECK. In other words, skip the first -YYN actions for
1289  this state because they are default actions. */
1290  int yyxbegin = yyn < 0 ? -yyn : 0;
1291  /* Stay within bounds of both yycheck and yytname. */
1292  int yychecklim = YYLAST - yyn + 1;
1293  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1294  int yyx;
1295 
1296  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1297  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1298  && !yytable_value_is_error (yytable[yyx + yyn]))
1299  {
1300  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1301  {
1302  yycount = 1;
1303  yysize = yysize0;
1304  break;
1305  }
1306  yyarg[yycount++] = yytname[yyx];
1307  {
1308  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1309  if (! (yysize <= yysize1
1310  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1311  return 2;
1312  yysize = yysize1;
1313  }
1314  }
1315  }
1316  }
1317 
1318  switch (yycount)
1319  {
1320 # define YYCASE_(N, S) \
1321  case N: \
1322  yyformat = S; \
1323  break
1324  YYCASE_(0, YY_("syntax error"));
1325  YYCASE_(1, YY_("syntax error, unexpected %s"));
1326  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1327  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1328  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1329  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1330 # undef YYCASE_
1331  }
1332 
1333  {
1334  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1335  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1336  return 2;
1337  yysize = yysize1;
1338  }
1339 
1340  if (*yymsg_alloc < yysize)
1341  {
1342  *yymsg_alloc = 2 * yysize;
1343  if (! (yysize <= *yymsg_alloc
1344  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1345  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1346  return 1;
1347  }
1348 
1349  /* Avoid sprintf, as that infringes on the user's name space.
1350  Don't have undefined behavior even if the translation
1351  produced a string with the wrong number of "%s"s. */
1352  {
1353  char *yyp = *yymsg;
1354  int yyi = 0;
1355  while ((*yyp = *yyformat) != '\0')
1356  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1357  {
1358  yyp += yytnamerr (yyp, yyarg[yyi++]);
1359  yyformat += 2;
1360  }
1361  else
1362  {
1363  yyp++;
1364  yyformat++;
1365  }
1366  }
1367  return 0;
1368 }
#define YYCASE_(N, S)
#define YY_NULLPTR
#define yypact_value_is_default(Yystate)
static YYSIZE_T yystrlen(const char *yystr)
#define YYTERROR
#define YYEMPTY
static const yytype_uint8 yycheck[]
#define yytable_value_is_error(Yytable_value)
#define YYNTOKENS
#define YYSTACK_ALLOC_MAXIMUM
static const char *const yytname[]
#define YY_(Msgid)
static YYSIZE_T yytnamerr(char *yyres, const char *yystr)
#define YYSIZE_T
static const yytype_int16 yypact[]
#define YYLAST
static const yytype_uint16 yytable[]
Here is the call graph for this function: