]>
sourceware.org Git - systemtap.git/blob - parse.h
2 // Copyright (C) 2005-2007 Red Hat Inc.
3 // Copyright (C) 2007 Bull S.A.S
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
31 std::ostream
& operator << (std::ostream
& o
, const source_loc
& loc
);
35 con_unknown
, con_probe
, con_global
, con_function
, con_embedded
41 tok_junk
, tok_identifier
, tok_operator
, tok_string
, tok_number
,
42 tok_embedded
, tok_keyword
54 std::ostream
& operator << (std::ostream
& o
, const token
& t
);
57 struct parse_error
: public std::runtime_error
61 parse_error (const std::string
& msg
):
62 runtime_error (msg
), tok (0), skip_some (true) {}
63 parse_error (const std::string
& msg
, const token
* t
):
64 runtime_error (msg
), tok (t
), skip_some (true) {}
65 parse_error (const std::string
& msg
, bool skip
):
66 runtime_error (msg
), tok (0), skip_some (skip
) {}
70 struct systemtap_session
;
75 token
* scan (bool wildcard
=false);
76 lexer (std::istream
&, const std::string
&, systemtap_session
&);
77 std::string
get_input_contents ();
78 void set_current_file (stapfile
* f
);
83 void input_put (const std::string
&);
84 int input_peek (unsigned n
=0);
86 std::string input_name
;
87 std::string input_contents
;
88 int input_pointer
; // index into input_contents
89 unsigned cursor_suspend_count
;
91 unsigned cursor_column
;
92 systemtap_session
& session
;
93 stapfile
* current_file
;
108 struct expr_statement
;
109 struct return_statement
;
110 struct delete_statement
;
111 struct break_statement
;
112 struct next_statement
;
113 struct continue_statement
;
121 parser (systemtap_session
& s
, std::istream
& i
, bool p
);
122 parser (systemtap_session
& s
, const std::string
& n
, bool p
);
127 static stapfile
* parse (systemtap_session
& s
, std::istream
& i
, bool privileged
);
128 static stapfile
* parse (systemtap_session
& s
, const std::string
& n
, bool privileged
);
131 systemtap_session
& session
;
132 std::string input_name
;
133 std::istream
* free_input
;
136 parse_context context
;
138 // preprocessing subordinate
139 std::vector
<const token
*> enqueued_pp
;
140 const token
* scan_pp (bool wildcard
=false);
143 const token
* last ();
144 const token
* next (bool wildcard
=false);
145 const token
* peek (bool wildcard
=false);
147 const token
* last_t
; // the last value returned by peek() or next()
148 const token
* next_t
; // lookahead token
151 const token
* expect_known (token_type tt
, std::string
const & expected
);
152 const token
* expect_unknown (token_type tt
, std::string
& target
);
153 const token
* expect_unknown2 (token_type tt1
, token_type tt2
,
154 std::string
& target
);
157 const token
* expect_op (std::string
const & expected
);
158 const token
* expect_kw (std::string
const & expected
);
159 const token
* expect_number (int64_t & expected
);
160 const token
* expect_ident (std::string
& target
);
161 const token
* expect_ident_or_keyword (std::string
& target
);
162 bool peek_op (std::string
const & op
);
163 bool peek_kw (std::string
const & kw
);
165 void print_error (const parse_error
& pe
);
168 private: // nonterminals
169 void parse_probe (std::vector
<probe
*>&, std::vector
<probe_alias
*>&);
170 void parse_global (std::vector
<vardecl
*>&, std::vector
<probe
*>&);
171 void parse_functiondecl (std::vector
<functiondecl
*>&);
172 embeddedcode
* parse_embeddedcode ();
173 probe_point
* parse_probe_point ();
174 literal
* parse_literal ();
175 block
* parse_stmt_block ();
176 statement
* parse_statement ();
177 if_statement
* parse_if_statement ();
178 for_loop
* parse_for_loop ();
179 for_loop
* parse_while_loop ();
180 foreach_loop
* parse_foreach_loop ();
181 expr_statement
* parse_expr_statement ();
182 return_statement
* parse_return_statement ();
183 delete_statement
* parse_delete_statement ();
184 next_statement
* parse_next_statement ();
185 break_statement
* parse_break_statement ();
186 continue_statement
* parse_continue_statement ();
187 indexable
* parse_indexable ();
188 const token
*parse_hist_op_or_bare_name (hist_op
*&hop
, std::string
&name
);
189 expression
* parse_expression ();
190 expression
* parse_assignment ();
191 expression
* parse_ternary ();
192 expression
* parse_logical_or ();
193 expression
* parse_logical_and ();
194 expression
* parse_boolean_or ();
195 expression
* parse_boolean_xor ();
196 expression
* parse_boolean_and ();
197 expression
* parse_array_in ();
198 expression
* parse_comparison ();
199 expression
* parse_shift ();
200 expression
* parse_concatenation ();
201 expression
* parse_additive ();
202 expression
* parse_multiplicative ();
203 expression
* parse_unary ();
204 expression
* parse_crement ();
205 expression
* parse_value ();
206 expression
* parse_symbol ();
213 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.044091 seconds and 5 git commands to generate.