100 return isalnum(
static_cast<unsigned char>(c)) || c ==
'-' || c ==
'_';
104 return static_cast<bool>(isdigit(
static_cast<unsigned char>(c)));
109token kmp_lexer::lex() {
112 const char *start = scan.
begin();
171using namespace lexer;
212 const char *dbg_name) {
219 KMP_FATAL(TraitParserError, dbg_name,
"expected '(' after trait name");
223 KMP_FATAL(TraitParserError, dbg_name,
"expected ')' after trait value");
232 const char *dbg_name);
242 const char *dbg_name) {
249 "expected trait expression after '('");
252 "expected ')' after trait expression group");
263 int max_recursion,
const char *dbg_name) {
264 if (max_recursion-- <= 0)
295 "expected trait expression after '!'");
308 const char *dbg_name) {
309 if (max_recursion-- <= 0)
334 "expected trait expression after operator");
350 const char *dbg_name) {
356 KMP_FATAL(TraitParserError, dbg_name,
"device number out of range");
370 const char *dbg_name) {
396 const char *dbg_name) {
418 const char *dbg_name) {
kmp_str_ref is a non-owning string class (similar to llvm::StringRef).
kmp_str_ref take_while(const Fn &predicate) const
Construct a new string with the longest prefix of the original string that satisfies the predicate.
size_t find_if_not(const Fn &predicate) const
Return the index of the first character in the string for which the predicate returns false.
static constexpr size_t npos
size_t length() const
Get the length of the string.
bool consume_front(kmp_str_ref prefix)
Check if the string starts with the given prefix and remove it from the string afterwards.
char * copy() const
Get an own duplicate of the string.
bool consume_integer(int &value, bool allow_zero=true, bool allow_negative=false)
Start consuming an integer from the start of the string and remove it from the string afterwards.
bool empty() const
Check if the string is empty.
const char * begin() const
Iterator support (raw pointers work as iterators for contiguous storage)
void skip_space()
Drop space from the start of the string.
void drop_front(size_t n)
Drop the first n characters from the string.
kmp_trait_context()=default
void add_clause(kmp_trait_clause *clause)
static kmp_trait_context * parse_from_spec(kmp_str_ref spec, const char *dbg_name=nullptr)
Represents a specific device number.
void set_expr(kmp_trait *trait)
Represents a (possibly negated) collection of traits that are either ANDed or ORed together.
void set_group_type(group_type new_type)
void add_expr(kmp_trait *trait)
Represents a single (possibly negated) trait.
void set_trait(kmp_trait *new_trait)
Abstract class representing either a single trait expression or a collection of trait expressions tha...
void set_negated(bool neg=true)
Represents a specific UID.
Represents a wildcard trait that matches any device.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
static bool is_word_char(char c)
static bool is_digit(char c)
static bool consume_trait_expr_group(kmp_trait_expr_group &group, kmp_lexer &lex, int max_recursion, const char *dbg_name)
static bool consume_device_number(kmp_trait_clause &clause, kmp_lexer &lex, const char *dbg_name)
static bool consume_trait_expr_group_paren(kmp_trait_expr_group &group, bool negated, kmp_lexer &lex, int max_recursion, const char *dbg_name)
static bool consume_clause(kmp_trait_clause &clause, kmp_lexer &lex, const char *dbg_name)
static bool word_is_number(const token &tok)
static void consume_list(kmp_trait_context &context, kmp_lexer &lex, const char *dbg_name)
static bool consume_trait(kmp_trait_expr_single &expr, kmp_lexer &lex, const char *dbg_name)
static kmp_str_ref consume_uid_value(kmp_lexer &lex, const char *dbg_name)
static bool consume_trait_expr(kmp_trait_expr *&expr, kmp_lexer &lex, int max_recursion, const char *dbg_name)
constexpr int MAX_RECURSION_DEPTH
static bool word_is(const token &tok, kmp_str_ref keyword)