Public Member Functions | Private Attributes
xpath_lexer Class Reference
Collaboration diagram for xpath_lexer:
Collaboration graph
[legend]

List of all members.

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_stringcontents () 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 ( const char_t *  query) [inline, explicit]

Definition at line 7521 of file pugixml.cpp.

References next().

                                                         : _cur(query)
                {
                        next();
                }

Member Function Documentation

const xpath_lexer_string& xpath_lexer::contents ( ) const [inline]
lexeme_t xpath_lexer::current ( ) const [inline]
const char_t* xpath_lexer::current_pos ( ) const [inline]

Definition at line 7805 of file pugixml.cpp.

References _cur_lexeme_pos.

Referenced by xpath_parser::throw_error().

                {
                        return _cur_lexeme_pos;
                }
void xpath_lexer::next ( ) [inline]

Definition at line 7531 of file pugixml.cpp.

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().

                {
                        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;
                }
const char_t* xpath_lexer::state ( ) const [inline]

Definition at line 7526 of file pugixml.cpp.

References _cur.

Referenced by xpath_parser::parse_path_or_unary_expression().

                {
                        return _cur;
                }

Member Data Documentation

const char_t* xpath_lexer::_cur [private]

Definition at line 7514 of file pugixml.cpp.

Referenced by next(), and state().

Definition at line 7518 of file pugixml.cpp.

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

Definition at line 7516 of file pugixml.cpp.

Referenced by contents(), and next().

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:

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001