xpath_lexer Class Reference
Collaboration diagram for xpath_lexer:
[legend]

## Public Member Functions

| xpath_lexer (const char_t *query)
const char_t * | state () const
void | next ()
lexeme_t | current () const
const char_t * | current_pos () const
const xpath_lexer_string & | contents () const

## Private Attributes

const char_t * | _cur
const char_t * | _cur_lexeme_pos
xpath_lexer_string | _cur_lexeme_contents
lexeme_t | _cur_lexeme

## Detailed Description

Definition at line 7512 of file pugixml.cpp.

## Constructor & Destructor Documentation

## xpath_lexer()

xpath_lexer::xpath_lexer | ( | const char_t * | query | ) |

inline explicit

Definition at line 7521 of file pugixml.cpp.

: _cur(query)
{
next();
}

References next().

## Member Function Documentation

## contents()

const xpath_lexer_string& xpath_lexer::contents | ( |  | ) | const

inline

Definition at line 7810 of file pugixml.cpp.

{
assert(_cur_lexeme == lex_var_ref || _cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string);
return _cur_lexeme_contents;
}

References _cur_lexeme, _cur_lexeme_contents, lex_number, lex_quoted_string, lex_string, and lex_var_ref.

Referenced by xpath_parser::binary_op_t::parse(), xpath_parser::parse_path_or_unary_expression(), xpath_parser::parse_primary_expression(), and xpath_parser::parse_step().

## current()

lexeme_t xpath_lexer::current | ( |  | ) | const

inline

Definition at line 7800 of file pugixml.cpp.

{
return _cur_lexeme;
}

References _cur_lexeme.

Referenced by xpath_parser::binary_op_t::parse(), xpath_parser::parse(), xpath_parser::parse_filter_expression(), xpath_parser::parse_location_path(), xpath_parser::parse_path_or_unary_expression(), xpath_parser::parse_primary_expression(), xpath_parser::parse_relative_location_path(), and xpath_parser::parse_step().

## current_pos()

const char_t* xpath_lexer::current_pos | ( |  | ) | const

inline

Definition at line 7805 of file pugixml.cpp.

{
return _cur_lexeme_pos;
}

References _cur_lexeme_pos.

Referenced by xpath_parser::throw_error().

## next()

void xpath_lexer::next | ( |  | ) |

inline

Definition at line 7531 of file pugixml.cpp.

{
const char_t* cur = _cur;
while (PUGI__IS_CHARTYPE(*cur, ct_space)) ++cur;
// save lexeme position for error reporting
_cur_lexeme_pos = cur;
switch (*cur)
{
case 0:
_cur_lexeme = lex_eof;
break;
case '>':
if (*(cur+1) == '=')
{
cur += 2;
_cur_lexeme = lex_greater_or_equal;
}
else
{
cur += 1;
_cur_lexeme = lex_greater;
}
break;
case '<':
if (*(cur+1) == '=')
{
cur += 2;
_cur_lexeme = lex_less_or_equal;
}
else
{
cur += 1;
_cur_lexeme = lex_less;
}
break;
case '!':
if (*(cur+1) == '=')
{
cur += 2;
_cur_lexeme = lex_not_equal;
}
else
{
_cur_lexeme = lex_none;
}
break;
case '=':
cur += 1;
_cur_lexeme = lex_equal;
break;
case '+':
cur += 1;
_cur_lexeme = lex_plus;
break;
case '-':
cur += 1;
_cur_lexeme = lex_minus;
break;
case '*':
cur += 1;
_cur_lexeme = lex_multiply;
break;
case '|':
cur += 1;
_cur_lexeme = lex_union;
break;
case '$':
cur += 1;
if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol))
{
_cur_lexeme_contents.begin = cur;
while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
if (cur[0] == ':' && PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // qname
{
cur++; // :
while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
}
_cur_lexeme_contents.end = cur;
_cur_lexeme = lex_var_ref;
}
else
{
_cur_lexeme = lex_none;
}
break;
case '(':
cur += 1;
_cur_lexeme = lex_open_brace;
break;
case ')':
cur += 1;
_cur_lexeme = lex_close_brace;
break;
case '[':
cur += 1;
_cur_lexeme = lex_open_square_brace;
break;
case ']':
cur += 1;
_cur_lexeme = lex_close_square_brace;
break;
case ',':
cur += 1;
_cur_lexeme = lex_comma;
break;
case '/':
if (*(cur+1) == '/')
{
cur += 2;
_cur_lexeme = lex_double_slash;
}
else
{
cur += 1;
_cur_lexeme = lex_slash;
}
break;
case '.':
if (*(cur+1) == '.')
{
cur += 2;
_cur_lexeme = lex_double_dot;
}
else if (PUGI__IS_CHARTYPEX(*(cur+1), ctx_digit))
{
_cur_lexeme_contents.begin = cur; // .
++cur;
while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++;
_cur_lexeme_contents.end = cur;
_cur_lexeme = lex_number;
}
else
{
cur += 1;
_cur_lexeme = lex_dot;
}
break;
case '@':
cur += 1;
_cur_lexeme = lex_axis_attribute;
break;
case '"':
case '\'':
{
char_t terminator = *cur;
++cur;
_cur_lexeme_contents.begin = cur;
while (*cur && *cur != terminator) cur++;
_cur_lexeme_contents.end = cur;
if (!*cur)
_cur_lexeme = lex_none;
else
{
cur += 1;
_cur_lexeme = lex_quoted_string;
}
break;
}
case ':':
if (*(cur+1) == ':')
{
cur += 2;
_cur_lexeme = lex_double_colon;
}
else
{
_cur_lexeme = lex_none;
}
break;
default:
if (PUGI__IS_CHARTYPEX(*cur, ctx_digit))
{
_cur_lexeme_contents.begin = cur;
while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++;
if (*cur == '.')
{
cur++;
while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++;
}
_cur_lexeme_contents.end = cur;
_cur_lexeme = lex_number;
}
else if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol))
{
_cur_lexeme_contents.begin = cur;
while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
if (cur[0] == ':')
{
if (cur[1] == '*') // namespace test ncname:*
{
cur += 2; // :*
}
else if (PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // namespace test qname
{
cur++; // :
while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
}
}
_cur_lexeme_contents.end = cur;
_cur_lexeme = lex_string;
}
else
{
_cur_lexeme = lex_none;
}
}
_cur = cur;
}

References _cur, _cur_lexeme, _cur_lexeme_contents, _cur_lexeme_pos, xpath_lexer_string::begin, ct_space, ctx_digit, ctx_start_symbol, ctx_symbol, xpath_lexer_string::end, lex_axis_attribute, lex_close_brace, lex_close_square_brace, lex_comma, lex_dot, lex_double_colon, lex_double_dot, lex_double_slash, lex_eof, lex_equal, lex_greater, lex_greater_or_equal, lex_less, lex_less_or_equal, lex_minus, lex_multiply, lex_none, lex_not_equal, lex_number, lex_open_brace, lex_open_square_brace, lex_plus, lex_quoted_string, lex_slash, lex_string, lex_union, lex_var_ref, PUGI__IS_CHARTYPE, and PUGI__IS_CHARTYPEX.

Referenced by xpath_parser::parse_expression_rec(), xpath_parser::parse_filter_expression(), xpath_parser::parse_location_path(), xpath_parser::parse_path_or_unary_expression(), xpath_parser::parse_primary_expression(), xpath_parser::parse_relative_location_path(), xpath_parser::parse_step(), and xpath_lexer().

## state()

const char_t* xpath_lexer::state | ( |  | ) | const

inline

Definition at line 7526 of file pugixml.cpp.

{
return _cur;
}

References _cur.

Referenced by xpath_parser::parse_path_or_unary_expression().

## Member Data Documentation

## _cur

const char_t* xpath_lexer::_cur

private

Definition at line 7514 of file pugixml.cpp.

Referenced by next(), and state().

## _cur_lexeme

lexeme_t xpath_lexer::_cur_lexeme

private

Definition at line 7518 of file pugixml.cpp.

Referenced by contents(), current(), and next().

## _cur_lexeme_contents

xpath_lexer_string xpath_lexer::_cur_lexeme_contents

private

Definition at line 7516 of file pugixml.cpp.

Referenced by contents(), and next().

## _cur_lexeme_pos

const char_t* xpath_lexer::_cur_lexeme_pos

private

Definition at line 7515 of file pugixml.cpp.

Referenced by current_pos(), and next().

The documentation for this class was generated from the following file:

- pugixml.cpp

PUGI__IS_CHARTYPE
#define PUGI__IS_CHARTYPE(c, ct)
Definition: pugixml.cpp:1195
lex_less
@ lex_less
Definition: pugixml.cpp:7469
PUGI__IS_CHARTYPEX
#define PUGI__IS_CHARTYPEX(c, ct)
Definition: pugixml.cpp:1196
ct_space
@ ct_space
Definition: pugixml.cpp:1130
xpath_lexer_string::end
const char_t * end
Definition: pugixml.cpp:7498
xpath_lexer::next
void next()
Definition: pugixml.cpp:7531
lex_axis_attribute
@ lex_axis_attribute
Definition: pugixml.cpp:7488
lex_quoted_string
@ lex_quoted_string
Definition: pugixml.cpp:7480
lex_close_brace
@ lex_close_brace
Definition: pugixml.cpp:7479
lex_double_dot
@ lex_double_dot
Definition: pugixml.cpp:7490
lex_dot
@ lex_dot
Definition: pugixml.cpp:7489
lex_comma
@ lex_comma
Definition: pugixml.cpp:7487
lex_union
@ lex_union
Definition: pugixml.cpp:7476
lex_plus
@ lex_plus
Definition: pugixml.cpp:7473
xpath_lexer::_cur
const char_t * _cur
Definition: pugixml.cpp:7514
ctx_start_symbol
@ ctx_start_symbol
Definition: pugixml.cpp:1162
lex_none
@ lex_none
Definition: pugixml.cpp:7466
lex_equal
@ lex_equal
Definition: pugixml.cpp:7467
xpath_lexer::_cur_lexeme_pos
const char_t * _cur_lexeme_pos
Definition: pugixml.cpp:7515
lex_not_equal
@ lex_not_equal
Definition: pugixml.cpp:7468
lex_eof
@ lex_eof
Definition: pugixml.cpp:7492
lex_number
@ lex_number
Definition: pugixml.cpp:7481
lex_double_colon
@ lex_double_colon
Definition: pugixml.cpp:7491
lex_open_brace
@ lex_open_brace
Definition: pugixml.cpp:7478
ctx_symbol
@ ctx_symbol
Definition: pugixml.cpp:1164
lex_close_square_brace
@ lex_close_square_brace
Definition: pugixml.cpp:7485
lex_greater_or_equal
@ lex_greater_or_equal
Definition: pugixml.cpp:7472
xpath_lexer_string::begin
const char_t * begin
Definition: pugixml.cpp:7497
lex_multiply
@ lex_multiply
Definition: pugixml.cpp:7475
lex_string
@ lex_string
Definition: pugixml.cpp:7486
lex_minus
@ lex_minus
Definition: pugixml.cpp:7474
lex_open_square_brace
@ lex_open_square_brace
Definition: pugixml.cpp:7484
xpath_lexer::_cur_lexeme_contents
xpath_lexer_string _cur_lexeme_contents
Definition: pugixml.cpp:7516
xpath_lexer::_cur_lexeme
lexeme_t _cur_lexeme
Definition: pugixml.cpp:7518
lex_var_ref
@ lex_var_ref
Definition: pugixml.cpp:7477
lex_greater
@ lex_greater
Definition: pugixml.cpp:7470
lex_slash
@ lex_slash
Definition: pugixml.cpp:7482
lex_less_or_equal
@ lex_less_or_equal
Definition: pugixml.cpp:7471
ctx_digit
@ ctx_digit
Definition: pugixml.cpp:1163
lex_double_slash
@ lex_double_slash
Definition: pugixml.cpp:7483