stapregex-parse.h - systemtap
Data types defined
Functions defined
Macros defined
Source code
#ifndef STAPREGEX_PARSE_H
#define STAPREGEX_PARSE_H
#include <iostream>
#include <string>
namespace stapregex {
struct range; struct regexp;
void print_escaped(std::ostream& o, char c);
struct cursor {
const std::string *input;
bool do_unescape;
unsigned pos; unsigned last_pos;
bool finished;
bool has(unsigned n);
cursor();
cursor(const std::string *input, bool do_unescape = false);
char peek();
char next();
private:
char next_c;
char last_c;
void get_unescaped();
};
class regex_parser {
public:
regex_parser (const std::string& input, bool do_unescape = true)
: input(input), do_unescape(do_unescape),
do_tag(false), num_tags(~0) {}
regexp *parse (bool do_tag = true);
private:
std::string input;
bool do_unescape;
cursor cur;
bool do_tag;
unsigned num_tags;
void parse_error (const std::string& msg, unsigned pos);
void parse_error (const std::string& msg);
bool isspecial (char c);
void expect (char expected);
private: regexp *parse_expr ();
regexp *parse_term ();
regexp *parse_factor ();
regexp *parse_char_range ();
unsigned parse_number ();
};
range *named_char_class (const std::string& name);
range *stapregex_getrange (cursor& cur);
};
#endif