Lexer ===== .. cpp:class:: numpy::Lexer numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use Lexer Lexer obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void advance()`` - void - df_query.h:89 - * - ``char current() const`` - char - df_query.h:80 - * - ``explicit Lexer(std::string input) : input\_(std::move(input))`` - explicit Lexer(std::string input) : - df_query.h:164 - * - ``Token next_token()`` - Token - df_query.h:166 - * - ``char peek(size_t ahead = 1) const`` - char - df_query.h:84 - * - ``Token read_identifier()`` - Token - df_query.h:99 - * - ``Token read_number()`` - Token - df_query.h:115 - * - ``Token read_string(char quote)`` - Token - df_query.h:141 - * - ``void skip_whitespace()`` - void - df_query.h:93 - :ref:`View ` * - ``Token tok(TokenType::NUMBER, num)`` - Token - df_query.h:136 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-lexer-skip_whitespace-0: .. dropdown:: skip_whitespace (np_test_5_all.cpp:976) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 966 :emphasize-lines: 11 assert_condition(type1 == "int", "Failed to detect int type"); assert_condition(type2 == "float", "Failed to detect float type"); assert_condition(type3 == "string", "Failed to detect string type"); // std::cout << " Tested value type detection" << std::endl; std::cout << " -> tests passed" << std::endl; } void np_test_io_skip_whitespace() { std::cout << "========= skip_whitespace() utility ============================"; // Test whitespace skipping std::string test = " \t\n text"; size_t pos = 0; // Skip whitespace while (pos < test.size() && std::isspace(test[pos])) { ++pos; }