Debian Codegraph @

src/tinyxpath/tokenlist.cpp

raw symbols SCIP
1 /*
2 www.sourceforge.net/projects/tinyxpath
3 Copyright (c) 2002-2004 Yves Berquin ([email protected])
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24
25 /**
26 \file tokenlist.cpp
27 \author Yves Berquin
28 XPath Syntax analyzer for TinyXPath project : token list handling
29 */
30
31 #include "tokenlist.h"
32
33 namespace TinyXPath
34 {
35
36 /// Decodes an XPath expression, further manipulating a token list
37 /// \n On input, we have a list of basic lexical tokens. We only merge here the
38 /// multiple tokens : like '::' or '!='. We also delete whitespace tokens
39 void token_list::v_tokenize_expression ()
40 {
41 v_set_current_top ();
42 while (ltp_get (1))
43 {
44 switch (ltp_get (0) -> lex_get_value ())
45 {
46 case lex_colon :
47 if (ltp_get (1) -> lex_get_value () == lex_colon)
48 {
49 v_replace_current (lex_2_colon, "::");
50 v_delete_next ();
51 }
52 else
53 v_inc_current (1);
54 break;
55 case lex_slash :
56 if (ltp_get (1) -> lex_get_value () == lex_slash)
57 {
58 v_replace_current (lex_2_slash, "//");
59 v_delete_next ();
60 }
61 else
62 v_inc_current (1);
63 break;
64 case lex_exclam :
65 if (ltp_get (1) -> lex_get_value () == lex_equal)
66 {
67 v_replace_current (lex_not_equal, "!=");
68 v_delete_next ();
69 }
70 else
71 v_inc_current (1);
72 break;
73 case lex_lt :
74 if (ltp_get (1) -> lex_get_value () == lex_equal)
75 {
76 v_replace_current (lex_lt_equal, "<=");
77 v_delete_next ();
78 }
79 else
80 v_inc_current (1);
81 break;
82 case lex_gt :
83 if (ltp_get (1) -> lex_get_value () == lex_equal)
84 {
85 v_replace_current (lex_gt_equal, ">=");
86 v_delete_next ();
87 }
88 else
89 v_inc_current (1);
90 break;
91 case lex_dot :
92 if (ltp_get (1) -> lex_get_value () == lex_dot)
93 {
94 v_replace_current (lex_2_dot, "..");
95 v_delete_next ();
96 }
97 else
98 v_inc_current (1);
99 break;
100 case lex_space :
101 v_delete_current ();
102 break;
103 default :
104 v_inc_current (1);
105 break;
106 } // switch
107 } // while
108 }
109
110 }