/[pspp]/pspp/src/expressions/parse.c
ViewVC logotype

Diff of /pspp/src/expressions/parse.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by blp, Fri Mar 4 07:18:56 2005 UTC revision 1.3 by blp, Sun Mar 6 19:06:30 2005 UTC
# Line 56  static struct expression *finish_express Line 56  static struct expression *finish_express
56                                               struct expression *);                                               struct expression *);
57  static bool type_check (struct expression *, union any_node **,  static bool type_check (struct expression *, union any_node **,
58                          enum expr_type expected_type);                          enum expr_type expected_type);
59    static union any_node *allocate_unary_variable (struct expression *,
60                                                    struct variable *);
61    
62  /* Public functions. */  /* Public functions. */
63    
# Line 402  type_coercion (struct expression *e, Line 404  type_coercion (struct expression *e,
404                 atom_type required_type, union any_node **node,                 atom_type required_type, union any_node **node,
405                 const char *operator_name)                 const char *operator_name)
406  {  {
407    return type_coercion_core (e, required_type, node, operator_name, 1);    return type_coercion_core (e, required_type, node, operator_name, true);
408  }  }
409    
410  /* Coerces *NODE to type REQUIRED_TYPE.  /* Coerces *NODE to type REQUIRED_TYPE.
# Line 411  static void Line 413  static void
413  type_coercion_assert (struct expression *e,  type_coercion_assert (struct expression *e,
414                        atom_type required_type, union any_node **node)                        atom_type required_type, union any_node **node)
415  {  {
416    int success = type_coercion_core (e, required_type, node, NULL, 1);    int success = type_coercion_core (e, required_type, node, NULL, true);
417    assert (success);    assert (success);
418  }  }
419    
# Line 421  static bool Line 423  static bool
423  is_coercible (atom_type required_type, union any_node *const *node)  is_coercible (atom_type required_type, union any_node *const *node)
424  {  {
425    return type_coercion_core (NULL, required_type,    return type_coercion_core (NULL, required_type,
426                               (union any_node **) node, NULL, 0);                               (union any_node **) node, NULL, false);
427  }  }
428    
429  /* How to parse an operator. */  /* How to parse an operator. */
# Line 783  parse_primary (struct expression *e) Line 785  parse_primary (struct expression *e)
785            /* It looks like a user variable.            /* It looks like a user variable.
786               (It could be a format specifier, but we'll assume               (It could be a format specifier, but we'll assume
787               it's a variable unless proven otherwise. */               it's a variable unless proven otherwise. */
788            struct variable *v = parse_dict_variable (e->dict);            return allocate_unary_variable (e, parse_dict_variable (e->dict));
           assert (v != NULL);  
           return expr_allocate_unary (e,  
                                       (v->type == NUMERIC  
                                        ? OP_NUM_VAR : OP_STR_VAR),  
                                       expr_allocate_variable (e, v));  
789          }          }
790        else        else
791          {          {
# Line 1159  parse_function (struct expression *e) Line 1156  parse_function (struct expression *e)
1156                goto fail;                goto fail;
1157              for (i = 0; i < var_cnt; i++)              for (i = 0; i < var_cnt; i++)
1158                add_arg (&args, &arg_cnt, &arg_cap,                add_arg (&args, &arg_cnt, &arg_cap,
1159                         expr_allocate_variable (e, vars[i]));                         allocate_unary_variable (e, vars[i]));
1160              free (vars);              free (vars);
1161            }            }
1162          else          else
# Line 1422  expr_allocate_format (struct expression Line 1419  expr_allocate_format (struct expression
1419    n->format.f = *format;    n->format.f = *format;
1420    return n;    return n;
1421  }  }
1422    
1423    /* Allocates a unary composite node that represents the value of
1424       variable V in expression E. */
1425    static union any_node *
1426    allocate_unary_variable (struct expression *e, struct variable *v)
1427    {
1428      assert (v != NULL);
1429      return expr_allocate_unary (e, v->type == NUMERIC ? OP_NUM_VAR : OP_STR_VAR,
1430                                  expr_allocate_variable (e, v));
1431    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26