constraints: replace get_common_relationship() with get_shared_relations()
[smatch.git] / parse.h
blobb26bd03f26de99bc330d510687f02336b52cf31d
1 #ifndef PARSE_H
2 #define PARSE_H
3 /*
4 * Basic parsing data structures. Statements and symbols.
6 * Copyright (C) 2003 Transmeta Corp.
7 * 2003 Linus Torvalds
9 * Licensed under the Open Software License version 1.1
12 #include "symbol.h"
14 enum statement_type {
15 STMT_NONE,
16 STMT_DECLARATION,
17 STMT_EXPRESSION,
18 STMT_COMPOUND,
19 STMT_IF,
20 STMT_RETURN,
21 STMT_CASE,
22 STMT_SWITCH,
23 STMT_ITERATOR,
24 STMT_LABEL,
25 STMT_GOTO,
26 STMT_ASM,
27 STMT_CONTEXT,
28 STMT_RANGE,
31 struct statement {
32 enum statement_type type;
33 struct position pos;
34 union {
35 struct /* declaration */ {
36 struct symbol_list *declaration;
38 struct {
39 struct expression *expression;
40 struct expression *context;
42 struct /* return_statement */ {
43 struct expression *ret_value;
44 struct symbol *ret_target;
46 struct /* if_statement */ {
47 struct expression *if_conditional;
48 struct statement *if_true;
49 struct statement *if_false;
51 struct /* compound_struct */ {
52 struct statement_list *stmts;
53 struct symbol *ret;
54 struct symbol *inline_fn;
55 struct statement *args;
57 struct /* labeled_struct */ {
58 struct symbol *label_identifier;
59 struct statement *label_statement;
61 struct /* case_struct */ {
62 struct expression *case_expression;
63 struct expression *case_to;
64 struct statement *case_statement;
65 struct symbol *case_label;
67 struct /* switch_struct */ {
68 struct expression *switch_expression;
69 struct statement *switch_statement;
70 struct symbol *switch_break, *switch_case;
72 struct /* iterator_struct */ {
73 struct symbol *iterator_break;
74 struct symbol *iterator_continue;
75 struct symbol_list *iterator_syms;
76 struct statement *iterator_pre_statement;
77 struct expression *iterator_pre_condition;
79 struct statement *iterator_statement;
81 struct statement *iterator_post_statement;
82 struct expression *iterator_post_condition;
84 struct /* goto_struct */ {
85 struct symbol *goto_label;
87 /* computed gotos have these: */
88 struct expression *goto_expression;
89 struct symbol_list *target_list;
91 struct /* goto_bb */ {
92 struct expression *bb_conditional;
93 struct symbol *bb_target;
95 struct /* multijmp */ {
96 struct expression *multi_from;
97 struct expression *multi_to;
98 struct symbol *multi_target;
100 struct /* asm */ {
101 struct expression *asm_string;
102 struct expression_list *asm_outputs;
103 struct expression_list *asm_inputs;
104 struct expression_list *asm_clobbers;
105 struct symbol_list *asm_labels;
107 struct /* range */ {
108 struct expression *range_expression;
109 struct expression *range_low;
110 struct expression *range_high;
115 extern struct symbol_list *function_computed_target_list;
116 extern struct statement_list *function_computed_goto_list;
118 extern struct token *parse_expression(struct token *, struct expression **);
119 extern struct symbol *label_symbol(struct token *token);
121 extern int show_statement(struct statement *);
122 extern void show_statement_list(struct statement_list *, const char *);
123 extern int show_expression(struct expression *);
125 extern struct token *external_declaration(struct token *token, struct symbol_list **list);
127 extern struct symbol *ctype_integer(int size, int want_unsigned);
129 extern void copy_statement(struct statement *src, struct statement *dst);
130 extern int inline_function(struct expression *expr, struct symbol *sym);
131 extern void uninline(struct symbol *sym);
132 extern void init_parser(int);
134 #endif /* PARSE_H */