6 * Copyright (C) 2003 Linus Torvalds, all rights reserved
8 * Declarations and helper functions for expression parsing.
11 enum expression_type
{
32 struct expression
*unop
;
33 struct statement
*statement
;
34 struct symbol
*symbol
;
36 struct expression
*left
, *right
;
39 struct expression
*deref
;
43 struct symbol
*cast_type
;
44 struct expression
*cast_expression
;
46 struct conditional_expr
{
47 struct expression
*conditional
, *cond_true
, *cond_false
;
49 struct statement_struct
{
50 struct symbol_list
*syms
;
51 struct statement_list
*stmts
;
56 /* Constant expression values */
57 long long get_expression_value(struct expression
*);
59 /* Expression parsing */
60 struct token
*parse_expression(struct token
*token
, struct expression
**tree
);
61 struct token
*conditional_expression(struct token
*token
, struct expression
**tree
);
62 struct token
*primary_expression(struct token
*token
, struct expression
**tree
);
63 struct token
*parens_expression(struct token
*token
, struct expression
**expr
, const char *where
);
64 struct token
*assignment_expression(struct token
*token
, struct expression
**tree
);
66 extern int evaluate_expression(struct expression
*);
68 static inline struct expression
*alloc_expression(struct token
*token
, int type
)
70 struct expression
*expr
= __alloc_expression(0);
76 /* Type name parsing */
77 struct token
*typename(struct token
*, struct symbol
**);
79 static inline int lookup_type(struct token
*token
)
81 if (token
->type
== TOKEN_IDENT
)
82 return lookup_symbol(token
->ident
, NS_TYPEDEF
) != NULL
;
86 /* Statement parsing */
87 struct statement
*alloc_statement(struct token
* token
, int type
);
88 struct token
*initializer(struct token
*token
, struct ctype
*type
);
89 struct token
*compound_statement(struct token
*, struct statement
*);
91 /* The preprocessor calls this 'constant_expression()' */
92 #define constant_expression(token,tree) conditional_expression(token, tree)