Overpass API regression suite coverage (Nova Scotia) / overpass_api/frontend/tokenizer_utils.h

overpass_api/frontend/tokenizer_utils.h

7 of 7 instrumented lines run by the suite (100.0%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#ifndef DE__OSM3S___OVERPASS_API__FRONTEND__TOKENIZER_UTILS_H
20#define DE__OSM3S___OVERPASS_API__FRONTEND__TOKENIZER_UTILS_H
22#include "decode_text.h"
23#include "../core/datatypes.h"
24#include "../../expat/map_ql_input.h"
27#include <string>
30std::string get_text_token(Tokenizer_Wrapper& token, Error_Output* error_output,
31 std::string type_of_token);
32std::string get_identifier_token(Tokenizer_Wrapper& token, Error_Output* error_output,
33 std::string type_of_token);
35void process_after(Tokenizer_Wrapper& token, Error_Output* error_output, bool after);
37void clear_until_after(Tokenizer_Wrapper& token, Error_Output* error_output,
38 std::string target_1, bool after = true);
40void clear_until_after(Tokenizer_Wrapper& token, Error_Output* error_output,
41 std::string target_1, std::string target_2, bool after = true);
43void clear_until_after(Tokenizer_Wrapper& token, Error_Output* error_output,
44 std::string target_1, std::string target_2, std::string target_3, bool after = true);
46void clear_until_after(Tokenizer_Wrapper& token, Error_Output* error_output,
47 std::string target_1, std::string target_2, std::string target_3, std::string target_4,
48 bool after = true);
50void clear_until_after(Tokenizer_Wrapper& token, Error_Output* error_output,
51 std::string target_1, std::string target_2, std::string target_3, std::string target_4,
52 std::string target_5, bool after = true);
55struct Token_Node
57 Token_Node(const std::string& token_, std::pair< uint, uint > line_col_)
5848268532 q : token(token_), line_col(line_col_), lhs(0), rhs(0) {}
60 std::string token;
61 std::pair< uint, uint > line_col;
62 uint lhs;
63 uint rhs;
64};
67int operator_priority(const std::string& operator_name, bool unary);
70struct Token_Node_Ptr;
73struct Token_Tree
75 Token_Tree(Tokenizer_Wrapper& token, Error_Output* error_output, bool parenthesis_expected);
76 Token_Tree(const Token_Node_Ptr& root, const Token_Node_Ptr& exclude);
78 std::vector< Token_Node > tree;
80private:
81 uint add_tree_node(const Token_Node_Ptr& root, const Token_Node_Ptr& exclude);
82};
85struct Token_Node_Ptr
8772348532 q Token_Node_Ptr(const Token_Tree& tree_, uint pos_ = 0) : tree(&tree_), pos(pos_) {}
8926580202 q const Token_Node& operator*() const { return tree->tree[pos]; }
90180581532 q const Token_Node* operator->() const { return &tree->tree[pos]; }
9137632515 q Token_Node_Ptr lhs() const { return Token_Node_Ptr(*tree, tree->tree[pos].lhs); }
9230800511 q Token_Node_Ptr rhs() const { return Token_Node_Ptr(*tree, tree->tree[pos].rhs); }
94 const std::string* function_name() const;
95 bool assert_is_function(Error_Output* error_output) const;
96 bool assert_has_input_set(Error_Output* error_output, bool expected) const;
97 bool assert_has_arguments(Error_Output* error_output, bool expected) const;
99322 q bool operator==(const Token_Node_Ptr& rhs) const { return tree == rhs.tree && pos == rhs.pos; }
101private:
102 const Token_Tree* tree;
103 uint pos;
104};
107Token_Node_Ptr find_leftmost_token(Token_Node_Ptr tree_it);
108Token_Node_Ptr find_leftmost_but_one_token(Token_Node_Ptr tree_it);
111#endif