Scan the next token SYNOPSYS Scan the next token from the input. lex->term is set to the scanned token type. lex->beg and lex->end are set to the beginnig and to the end of the token. RETURN N/A */
| 1323 | N/A |
| 1324 | */ |
| 1325 | static void |
| 1326 | my_xpath_lex_scan(MY_XPATH *xpath, |
| 1327 | MY_XPATH_LEX *lex, const char *beg, const char *end) |
| 1328 | { |
| 1329 | int ch, ctype, length; |
| 1330 | for ( ; beg < end && *beg == ' ' ; beg++) ; // skip leading spaces |
| 1331 | lex->beg= beg; |
| 1332 | |
| 1333 | if (beg >= end) |
| 1334 | { |
| 1335 | lex->end= beg; |
| 1336 | lex->term= MY_XPATH_LEX_EOF; // end of line reached |
| 1337 | return; |
| 1338 | } |
| 1339 | |
| 1340 | // Check ident, or a function call, or a keyword |
| 1341 | if ((length= xpath->cs->cset->ctype(xpath->cs, &ctype, |
| 1342 | (const uchar*) beg, |
| 1343 | (const uchar*) end)) > 0 && |
| 1344 | ((ctype & (_MY_L | _MY_U)) || *beg == '_')) |
| 1345 | { |
| 1346 | // scan untill the end of the idenfitier |
| 1347 | for (beg+= length; |
| 1348 | (length= xpath->cs->cset->ctype(xpath->cs, &ctype, |
| 1349 | (const uchar*) beg, |
| 1350 | (const uchar*) end)) > 0 && |
| 1351 | ((ctype & (_MY_L | _MY_U | _MY_NMR)) || |
| 1352 | *beg == '_' || *beg == '-' || *beg == '.') ; |
| 1353 | beg+= length) /* no op */; |
| 1354 | lex->end= beg; |
| 1355 | |
| 1356 | if (beg < end) |
| 1357 | { |
| 1358 | if (*beg == '(') |
| 1359 | { |
| 1360 | /* |
| 1361 | check if a function call, e.g.: count(/a/b) |
| 1362 | or a nodetype test, e.g.: /a/b/text() |
| 1363 | */ |
| 1364 | if ((xpath->func= my_xpath_function(lex->beg, beg))) |
| 1365 | lex->term= MY_XPATH_LEX_FUNC; |
| 1366 | else |
| 1367 | lex->term= my_xpath_keyword(xpath, my_nodetype_names, |
| 1368 | lex->beg, beg); |
| 1369 | return; |
| 1370 | } |
| 1371 | // check if an axis specifier, e.g.: /a/b/child::* |
| 1372 | else if (*beg == ':' && beg + 1 < end && beg[1] == ':') |
| 1373 | { |
| 1374 | lex->term= my_xpath_keyword(xpath, my_axis_names, |
| 1375 | lex->beg, beg); |
| 1376 | return; |
| 1377 | } |
| 1378 | } |
| 1379 | // check if a keyword |
| 1380 | lex->term= my_xpath_keyword(xpath, my_keyword_names, |
| 1381 | lex->beg, beg); |
| 1382 | return; |
no test coverage detected