Linearize iterators, at least a first try at it.
[smatch.git] / parse.h
blob8387d8ac780a3312b9555410afd618c048802cb8
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_EXPRESSION,
17 STMT_COMPOUND,
18 STMT_IF,
19 STMT_RETURN,
20 STMT_CASE,
21 STMT_SWITCH,
22 STMT_ITERATOR,
23 STMT_LABEL,
24 STMT_GOTO,
25 STMT_ASM,
27 /* These only show up after linearization */
28 STMT_GOTO_BB,
31 struct statement {
32 enum statement_type type;
33 struct position pos;
34 union {
35 struct /* label_arg */ {
36 struct symbol *label;
37 struct statement *label_statement;
39 struct expression *expression;
40 struct /* return_statement */ {
41 struct expression *ret_value;
42 struct symbol *ret_target;
44 struct /* if_statement */ {
45 struct expression *if_conditional;
46 struct statement *if_true;
47 struct statement *if_false;
49 struct /* compound_struct */ {
50 struct symbol_list *syms;
51 struct statement_list *stmts;
52 struct symbol *ret;
54 struct /* labeled_struct */ {
55 struct symbol *label_identifier;
56 struct statement *label_statement;
58 struct /* case_struct */ {
59 struct expression *case_expression;
60 struct expression *case_to;
61 struct statement *case_statement;
62 struct symbol *case_label;
64 struct /* switch_struct */ {
65 struct expression *switch_expression;
66 struct statement *switch_statement;
67 struct symbol *switch_break, *switch_case;
69 struct /* iterator_struct */ {
70 struct symbol *iterator_break;
71 struct symbol *iterator_continue;
72 struct symbol_list *iterator_syms;
73 struct statement *iterator_pre_statement;
74 struct expression *iterator_pre_condition;
76 struct statement *iterator_statement;
78 struct statement *iterator_post_statement;
79 struct expression *iterator_post_condition;
81 struct /* goto_struct */ {
82 struct symbol *goto_label;
83 struct expression *goto_expression;
85 struct /* goto_bb */ {
86 struct expression *bb_conditional;
87 struct symbol *bb_target;
92 extern struct token *parse_expression(struct token *, struct expression **);
93 extern struct token *statement_list(struct token *, struct statement_list **);
94 extern struct symbol *label_symbol(struct token *token);
96 extern int show_statement(struct statement *);
97 extern void show_statement_list(struct statement_list *, const char *);
98 extern int show_expression(struct expression *);
99 extern void translation_unit(struct token *, struct symbol_list **);
101 extern struct symbol *ctype_integer(unsigned int spec);
102 extern struct symbol *ctype_fp(unsigned int spec);
104 extern int match_string_ident(struct ident *, const char *);
105 extern void copy_statement(struct statement *src, struct statement *dst);
106 extern int inline_function(struct expression *expr, struct symbol *sym);
108 #endif /* PARSE_H */