JASSv2
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
JASS::parser_query Class Reference

Simple interface to parsing queries. More...

#include <parser_query.h>

Collaboration diagram for JASS::parser_query:
Collaboration graph
[legend]

Public Types

enum  parser_type { query, raw }
 Which parser to use. More...
 

Public Member Functions

 parser_query (allocator &memory)
 Constructor. More...
 
template<typename STRING_TYPE >
void parse (query_term_list &parsed_query, const STRING_TYPE &query, parser_type which_parser=parser_type::query)
 parse and return the list of query tokens. More...
 

Static Public Member Functions

static void unittest (void)
 Unit test this class.
 

Private Types

enum  token_status { eof_token, bad_token, valid_token }
 the parser returns whether the next token is valid or not. More...
 

Private Member Functions

token_status get_next_token (slice &token)
 Return the next parsed token from the source query, this parser does case folding and sp on. More...
 
token_status get_next_token_raw (slice &token)
 Return the next parsed token from the source query, this parser assumes the tokens are already normalised (case folded, puncutation removed, and so on). Seperators are whitespace. More...
 

Static Private Member Functions

static std::string unittest_test_one (parser_query *parser, allocator &memory, const std::string &query)
 Unit test this class.
 

Private Attributes

allocatormemory
 All memory associated with the query.
 
uint8_t * current
 Currtne locaton (in the input query string) of the parser during parsing.
 
uint8_t * end_of_query
 Pointer to the end of the inoput query string.
 
uint8_t * buffer_pos
 Loction where the next token will be written during tokenization and normaloisation.
 
uint8_t * buffer_end
 End of the normalised token buffer.
 

Detailed Description

Simple interface to parsing queries.

Member Enumeration Documentation

◆ parser_type

Which parser to use.

Enumerator
query 

Unicode parsing with case folding and alphanumeric seperation.

raw 

ASCII parsing asuming only whitespace seperates tokens.

◆ token_status

the parser returns whether the next token is valid or not.

Enumerator
eof_token 

At the end of porcessing tokens so not a valid token.

bad_token 

The token is a bad token (for example, it might have an invalid UTF8 character in it).

valid_token 

The token is a valid token.

Constructor & Destructor Documentation

◆ parser_query()

JASS::parser_query::parser_query ( allocator memory)
inline

Constructor.

Parameters
memory[in] all allocations happen in the memory object.

Member Function Documentation

◆ get_next_token()

parser_query::token_status JASS::parser_query::get_next_token ( slice token)
private

Return the next parsed token from the source query, this parser does case folding and sp on.

Parameters
token[in] a slice of the token.

◆ get_next_token_raw()

parser_query::token_status JASS::parser_query::get_next_token_raw ( slice token)
private

Return the next parsed token from the source query, this parser assumes the tokens are already normalised (case folded, puncutation removed, and so on). Seperators are whitespace.

Parameters
token[in] a slice of the token.

◆ parse()

template<typename STRING_TYPE >
void JASS::parser_query::parse ( query_term_list parsed_query,
const STRING_TYPE &  query,
parser_type  which_parser = parser_type::query 
)
inline

parse and return the list of query tokens.

Template Parameters
STRING_TYPEeither a std::string or JASS::string (or other string type)
Parameters
parsed_query[out] The parsed query once parsed.
query[in] The query to be parsed.

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