X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fexpressions%2Fprivate.h;h=e77ce4d941c852e7fe0e0cea7713a5af9cb513e4;hb=b38178991ef8cd3ab16a90f2a4703404945c7421;hp=3cf7a2c73213f581019f43beaa6ebe17b3bfe0a1;hpb=ea411b6c81ab5895051535a4730210a66d4be388;p=pspp diff --git a/src/language/expressions/private.h b/src/language/expressions/private.h index 3cf7a2c732..e77ce4d941 100644 --- a/src/language/expressions/private.h +++ b/src/language/expressions/private.h @@ -71,7 +71,7 @@ struct operation const char *name; const char *prototype; enum operation_flags flags; - atom_type returns; + atom_type returns; /* Usually OP_number, OP_string, or OP_boolean. */ int n_args; atom_type args[EXPR_ARG_MAX]; int array_min_elems; @@ -80,65 +80,40 @@ struct operation extern const struct operation operations[]; -/* Tree structured expressions. */ - -/* Atoms. */ -struct number_node +/* Expression parse tree. */ +struct expr_node { - operation_type type; /* OP_number. */ - double n; - }; + operation_type type; + struct msg_location *location; -struct string_node - { - operation_type type; /* OP_string. */ - struct substring s; - }; + union + { + /* OP_number. */ + double number; -struct variable_node - { - operation_type type; /* OP_variable. */ - const struct variable *v; - }; + /* OP_string. */ + struct substring string; -struct integer_node - { - operation_type type; /* OP_integer. */ - int i; - }; + /* OP_variable. */ + const struct variable *variable; -struct vector_node - { - operation_type type; /* OP_vector. */ - const struct vector *v; - }; + /* OP_integer. */ + int integer; -struct format_node - { - operation_type type; /* OP_format. */ - struct fmt_spec f; - }; + /* OP_vector. */ + const struct vector *vector; -/* Any composite node. */ -struct composite_node - { - operation_type type; /* One of OP_*. */ - size_t n_args; /* Number of arguments. */ - union any_node **args; /* Arguments. */ - size_t min_valid; /* Min valid array args to get valid result. */ - }; + /* OP_format. */ + struct fmt_spec format; -/* Any node. */ -union any_node - { - operation_type type; - struct number_node number; - struct string_node string; - struct variable_node variable; - struct integer_node integer; - struct vector_node vector; - struct format_node format; - struct composite_node composite; + /* All the other node types. */ + struct + { + size_t n_args; /* Number of arguments. */ + struct expr_node **args; /* Arguments. */ + size_t min_valid; /* Min valid array args to get valid result. */ + }; + }; }; union operation_data @@ -171,28 +146,28 @@ struct expression struct expression *expr_parse_any (struct lexer *lexer, struct dataset *, bool optimize); void expr_debug_print_postfix (const struct expression *); -union any_node *expr_optimize (union any_node *, struct expression *); -void expr_flatten (union any_node *, struct expression *); - -atom_type expr_node_returns (const union any_node *); - -union any_node *expr_allocate_nullary (struct expression *e, operation_type); -union any_node *expr_allocate_unary (struct expression *e, - operation_type, union any_node *); -union any_node *expr_allocate_binary (struct expression *e, operation_type, - union any_node *, union any_node *); -union any_node *expr_allocate_composite (struct expression *e, operation_type, - union any_node **, size_t); -union any_node *expr_allocate_number (struct expression *e, double); -union any_node *expr_allocate_boolean (struct expression *e, double); -union any_node *expr_allocate_integer (struct expression *e, int); -union any_node *expr_allocate_pos_int (struct expression *e, int); -union any_node *expr_allocate_string (struct expression *e, struct substring); -union any_node *expr_allocate_variable (struct expression *e, +struct expr_node *expr_optimize (struct expr_node *, struct expression *); +void expr_flatten (struct expr_node *, struct expression *); + +atom_type expr_node_returns (const struct expr_node *); + +struct expr_node *expr_allocate_nullary (struct expression *e, operation_type); +struct expr_node *expr_allocate_unary (struct expression *e, + operation_type, struct expr_node *); +struct expr_node *expr_allocate_binary (struct expression *e, operation_type, + struct expr_node *, struct expr_node *); +struct expr_node *expr_allocate_composite (struct expression *e, operation_type, + struct expr_node **, size_t); +struct expr_node *expr_allocate_number (struct expression *e, double); +struct expr_node *expr_allocate_boolean (struct expression *e, double); +struct expr_node *expr_allocate_integer (struct expression *e, int); +struct expr_node *expr_allocate_pos_int (struct expression *e, int); +struct expr_node *expr_allocate_string (struct expression *e, struct substring); +struct expr_node *expr_allocate_variable (struct expression *e, const struct variable *); -union any_node *expr_allocate_format (struct expression *e, +struct expr_node *expr_allocate_format (struct expression *e, const struct fmt_spec *); -union any_node *expr_allocate_vector (struct expression *e, +struct expr_node *expr_allocate_vector (struct expression *e, const struct vector *); #endif /* expressions/private.h */