Home | History | Annotate | Download | only in quic

Lines Matching defs:lex

531 static int lex_init(struct lexer *lex, const char *in, size_t in_len)
536 lex->p = in;
537 lex->term_end = in;
538 lex->end = in + in_len;
542 static int lex_do(struct lexer *lex)
544 const char *p = lex->term_end, *end = lex->end, *term_end;
550 lex->p = end;
551 lex->term_end = end;
558 lex->p = p;
559 lex->term_end = term_end;
563 static int lex_eot(struct lexer *lex)
565 return lex->p == lex->term_end;
568 static int lex_peek_char(struct lexer *lex)
570 return lex_eot(lex) ? -1 : *lex->p;
573 static int lex_skip_char(struct lexer *lex)
575 if (lex_eot(lex))
578 ++lex->p;
582 static int lex_match(struct lexer *lex, const char *s, size_t s_len)
584 if ((size_t)(lex->term_end - lex->p) != s_len)
587 if (memcmp(lex->p, s, s_len))
593 static void lex_get_rest(struct lexer *lex, const char **str, size_t *str_l)
595 *str = lex->p;
596 *str_l = lex->term_end - lex->p;
599 static int lex_extract_to(struct lexer *lex, char c,
602 const char *p = lex->p, *term_end = lex->term_end, *s;
611 lex->p = ++s;
653 static int lex_fail(struct lexer *lex
659 lex->p = lex->term_end = lex->end;
686 struct lexer lex = { 0 };
694 if (!lex_init(&lex, filter, strlen(filter)))
697 while (lex_do(&lex)) {
698 c = lex_peek_char(&lex);
701 lex_skip_char(&lex);
703 c = lex_peek_char(&lex);
705 return lex_fail(&lex, "expected alphanumeric name or '*'"
708 return lex_fail(&lex, "expected +/- or alphanumeric name or '*'");
713 if (lex_match(&lex, "*", 1)) {
718 if (!lex_extract_to(&lex, ':', &cat, &cat_l))
719 return lex_fail(&lex, "expected ':' after category name");
721 lex_get_rest(&lex, &event, &event_l);
723 return lex_fail(&lex, "expected alphanumeric category name or '*'");
725 return lex_fail(&lex, "expected alphanumeric event name or '*'");