Handle '#' properly (well, _more_ properly) in macro expansion.
[smatch.git] / expression.h
blobd378184321f446fa3abb14d368075fcf963b7cc6
1 #ifndef EXPRESSION_H
2 #define EXPRESSION_H
3 /*
4 * sparse/expression.h
6 * Copyright (C) 2003 Linus Torvalds, all rights reserved
8 * Declarations and helper functions for expression parsing.
9 */
11 /* Constant expression values */
12 long long get_expression_value(struct expression *);
14 /* Expression parsing */
15 struct token *parse_expression(struct token *token, struct expression **tree);
16 struct token *conditional_expression(struct token *token, struct expression **tree);
17 struct token *primary_expression(struct token *token, struct expression **tree);
18 struct token *parens_expression(struct token *token, struct expression **expr, const char *where);
19 struct token *assignment_expression(struct token *token, struct expression **tree);
21 static inline struct expression *alloc_expression(struct token *token, int type)
23 struct expression *expr = __alloc_expression(0);
24 expr->type = type;
25 expr->token = token;
26 return expr;
29 /* Type name parsing */
30 struct token *typename(struct token *, struct symbol **);
32 static inline int lookup_type(struct token *token)
34 if (token->type == TOKEN_IDENT)
35 return lookup_symbol(token->ident, NS_TYPEDEF) != NULL;
36 return 0;
39 /* Statement parsing */
40 struct statement *alloc_statement(struct token * token, int type);
41 struct token *initializer(struct token *token, struct ctype *type);
42 struct token *compound_statement(struct token *, struct statement *);
44 /* The preprocessor calls this 'constant_expression()' */
45 #define constant_expression(token,tree) conditional_expression(token, tree)
47 #endif