]>
Commit | Line | Data |
---|---|---|
60cf5fae SM |
1 | // -*- C++ -*- |
2 | // Copyright (C) 2012-2013 Red Hat Inc. | |
3 | // | |
4 | // This file is part of systemtap, and is free software. You can | |
5 | // redistribute it and/or modify it under the terms of the GNU General | |
6 | // Public License (GPL); either version 2, or (at your option) any | |
7 | // later version. | |
8 | // | |
9 | // --- | |
10 | // | |
11 | // This file incorporates code from the re2c project; please see | |
12 | // the file README.stapregex for details. | |
13 | ||
14 | #ifndef STAPREGEX_H | |
15 | #define STAPREGEX_H | |
16 | ||
17 | #include <string> | |
18 | #include <iostream> | |
60cf5fae SM |
19 | |
20 | struct systemtap_session; /* from session.h */ | |
21 | struct token; /* from parse.h */ | |
bf840782 | 22 | class translator_output; /* from translator-output.h */ |
60cf5fae SM |
23 | |
24 | namespace stapregex { | |
cd4882d7 | 25 | struct regexp; /* from stapregex-tree.h */ |
bf840782 | 26 | struct dfa; /* from stapregex-dfa.h */ |
60cf5fae SM |
27 | }; |
28 | ||
29 | struct stapdfa { | |
e5fcd199 | 30 | std::string func_name; |
60cf5fae SM |
31 | std::string orig_input; |
32 | const token *tok; | |
e5fcd199 | 33 | |
60cf5fae | 34 | stapdfa (const std::string& func_name, const std::string& re, |
cd4882d7 | 35 | const token *tok = NULL, bool do_unescape = true, bool do_tag = true); |
60cf5fae | 36 | ~stapdfa (); |
e5fcd199 SM |
37 | unsigned num_states() const; |
38 | unsigned num_tags() const; | |
39 | ||
40 | void emit_declaration (translator_output *o) const; | |
41 | void emit_matchop_start (translator_output *o) const; | |
42 | void emit_matchop_end (translator_output *o) const; | |
43 | ||
44 | void print(translator_output *o) const; | |
45 | void print(std::ostream& o) const; | |
60cf5fae | 46 | private: |
60cf5fae SM |
47 | stapregex::regexp *ast; |
48 | stapregex::dfa *content; | |
e5fcd199 | 49 | bool do_tag; |
60cf5fae SM |
50 | }; |
51 | ||
52 | std::ostream& operator << (std::ostream &o, const stapdfa& d); | |
53 | ||
54 | /* Creates a dfa if no dfa for the corresponding regex exists yet; | |
55 | retrieves the corresponding dfa from s->dfas if already there: */ | |
56 | stapdfa *regex_to_stapdfa (systemtap_session *s, const std::string& input, const token* tok); | |
57 | ||
58 | #endif | |
59 | ||
60 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |