]>
Commit | Line | Data |
---|---|---|
2f1a1aea | 1 | // -*- C++ -*- |
30263a73 | 2 | // Copyright (C) 2005-2010 Red Hat Inc. |
5811366a | 3 | // Copyright (C) 2007 Bull S.A.S |
69c68955 FCE |
4 | // |
5 | // This file is part of systemtap, and is free software. You can | |
6 | // redistribute it and/or modify it under the terms of the GNU General | |
7 | // Public License (GPL); either version 2, or (at your option) any | |
8 | // later version. | |
9 | ||
2f1a1aea | 10 | |
2b066ec1 FCE |
11 | #ifndef PARSE_H |
12 | #define PARSE_H | |
13 | ||
2f1a1aea | 14 | #include <string> |
2f1a1aea | 15 | #include <iostream> |
2f1a1aea | 16 | #include <stdexcept> |
2f1a1aea | 17 | |
1b1b4ceb RA |
18 | struct stapfile; |
19 | ||
2f1a1aea FCE |
20 | struct source_loc |
21 | { | |
2203b032 | 22 | stapfile* file; |
2f1a1aea FCE |
23 | unsigned line; |
24 | unsigned column; | |
25 | }; | |
26 | ||
0323ed4d | 27 | std::ostream& operator << (std::ostream& o, const source_loc& loc); |
2f1a1aea | 28 | |
6e213f58 DS |
29 | enum parse_context |
30 | { | |
31 | con_unknown, con_probe, con_global, con_function, con_embedded | |
32 | }; | |
33 | ||
34 | ||
dff50e09 | 35 | enum token_type |
2f1a1aea | 36 | { |
54dfabe9 | 37 | tok_junk, tok_identifier, tok_operator, tok_string, tok_number, |
6e213f58 | 38 | tok_embedded, tok_keyword |
2f1a1aea FCE |
39 | }; |
40 | ||
0fefb486 | 41 | |
2f1a1aea FCE |
42 | struct token |
43 | { | |
44 | source_loc location; | |
45 | token_type type; | |
46 | std::string content; | |
16fc963f SM |
47 | std::string msg; // for tok_junk |
48 | void make_junk (std::string msg); | |
534aad8b | 49 | const token* chain; // macro invocation that produced this token |
2f1a1aea FCE |
50 | }; |
51 | ||
0fefb486 | 52 | |
56099f08 FCE |
53 | std::ostream& operator << (std::ostream& o, const token& t); |
54 | ||
2f1a1aea FCE |
55 | |
56 | struct parse_error: public std::runtime_error | |
57 | { | |
177a8ead | 58 | const token* tok; |
cd7116b8 | 59 | bool skip_some; |
dff50e09 | 60 | parse_error (const std::string& msg): |
cd7116b8 | 61 | runtime_error (msg), tok (0), skip_some (true) {} |
dff50e09 | 62 | parse_error (const std::string& msg, const token* t): |
cd7116b8 | 63 | runtime_error (msg), tok (t), skip_some (true) {} |
dff50e09 | 64 | parse_error (const std::string& msg, bool skip): |
cd7116b8 | 65 | runtime_error (msg), tok (0), skip_some (skip) {} |
2f1a1aea FCE |
66 | }; |
67 | ||
68 | ||
dc38c0ae DS |
69 | struct systemtap_session; |
70 | ||
c18f07f8 JS |
71 | stapfile* parse (systemtap_session& s, std::istream& i, bool privileged); |
72 | stapfile* parse (systemtap_session& s, const std::string& n, bool privileged); | |
2b066ec1 FCE |
73 | |
74 | ||
75 | #endif // PARSE_H | |
73267b89 JS |
76 | |
77 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |