]> sourceware.org Git - systemtap.git/blame - parse.h
testsuite: split additional_scripts.exp at installtest_p point
[systemtap.git] / parse.h
CommitLineData
2f1a1aea 1// -*- C++ -*-
ef36f781 2// Copyright (C) 2005-2014 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>
fe410f52 15#include <vector>
2f1a1aea 16#include <iostream>
2f1a1aea 17#include <stdexcept>
2f1a1aea 18
1b1b4ceb 19struct stapfile;
101b0805 20struct probe;
1b1b4ceb 21
2f1a1aea
FCE
22struct source_loc
23{
2203b032 24 stapfile* file;
2f1a1aea
FCE
25 unsigned line;
26 unsigned column;
27};
28
0323ed4d 29std::ostream& operator << (std::ostream& o, const source_loc& loc);
2f1a1aea 30
6e213f58
DS
31enum parse_context
32 {
33 con_unknown, con_probe, con_global, con_function, con_embedded
34 };
35
36
dff50e09 37enum token_type
2f1a1aea 38 {
54dfabe9 39 tok_junk, tok_identifier, tok_operator, tok_string, tok_number,
6e213f58 40 tok_embedded, tok_keyword
2f1a1aea
FCE
41 };
42
0fefb486 43
2f1a1aea
FCE
44struct token
45{
46 source_loc location;
47 token_type type;
48 std::string content;
16fc963f
SM
49 std::string msg; // for tok_junk
50 void make_junk (std::string msg);
534aad8b 51 const token* chain; // macro invocation that produced this token
a340930f
JL
52 friend class parser;
53 friend class lexer;
54private:
82c6d474 55 token(): chain(0) {}
a340930f
JL
56 token(const token& other):
57 location(other.location), type(other.type), content(other.content),
58 msg(other.msg), chain(other.chain) {}
2f1a1aea
FCE
59};
60
0fefb486 61
56099f08
FCE
62std::ostream& operator << (std::ostream& o, const token& t);
63
2f1a1aea 64
fe410f52
SM
65typedef enum { ctx_library, ctx_local } macro_ctx;
66
67/* structs from session.h: */
dc38c0ae 68struct systemtap_session;
fe410f52
SM
69struct macrodecl {
70 const token* tok; // NB: macrodecl owns its token
71 std::string name;
72 std::vector<std::string> formal_args;
73 std::vector<const token*> body;
74 macro_ctx context;
75
76 // Used for identifying subclasses that represent e.g. parameter bindings.
77 virtual bool is_closure() { return false; }
78
79 macrodecl () : tok(0), context(ctx_local) { }
f4072542 80 virtual ~macrodecl ();
fe410f52
SM
81};
82
dc38c0ae 83
f8405ea5
JS
84enum parse_flag
85 {
86 pf_guru = 1,
87 pf_no_compatible = 2,
88 pf_squash_errors = 4,
89 };
90
91
ba48c27a 92stapfile* parse (systemtap_session& s,const std::string& n, std::istream& i, unsigned flags);
f8405ea5 93stapfile* parse (systemtap_session& s, const std::string& n, unsigned flags);
2b066ec1 94
f8405ea5 95stapfile* parse_library_macros (systemtap_session& s, const std::string& n);
2b066ec1 96
101b0805
JS
97probe* parse_synthetic_probe (systemtap_session &s, std::istream& i, const token* tok);
98
2b066ec1 99#endif // PARSE_H
73267b89
JS
100
101/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.135634 seconds and 5 git commands to generate.