int bool real string sequence They are denoted by the following #defined constants from [primtype] module: INT_VALUE BOOL_VALUE REAL_VALUE STRING_VALUE SEQUENCE_VALUE
[primtype] must be one of the ???_VALUE constants described above. valptr points to something of that type (cast to char * by the caller). E.G. If you wanted to make an int value from the variable i, you'd do the following:{ int i; ..... ; value *val = mk_value((char *) (&i),"int"); }ALLOCATES a new value. Note that mk_value makes a COPY of its argument.
char *mk_print_string_from_value(value *va);
Note. A print_string is an ascii string that unambiguously describes the type and value of a value. See below for the syntax definition.
value *mk_value_from_print_string(char *print_string);
If the print string is not legally interpretable as a value, returns NULL.
int value_type(value *val);
Returns an integer: one of the ???_VALUE constants #defined above.
bool valtypes_are_same(value *v1,value *v2);
True if and only if the [primtype]s are the same. If v1 and v2 are both sequences, recursively checks that they are the same size, and the i'th element of each sequence have same [primtype]s.
int int_from_value([value] *v); bool bool_from_value([value] *v); double real_from_value([value] *v); char *mk_string_from_value([value] *v); [sequence] *mk_sequence_from_value([value] *v);
Returns an object of the desired type. PRECONDITION: The [primtype] must be the same as the C return type requested. Notice that mk_string_from_value and mk_sequence_from_value ALLOCATE memory and return a COPY of the data denoted by v.
bool less_or_equal(value *v1,value *v2);
Defines a partial (or total) order on values. Make it the strongest natural order (e.g. <= on numbers, lexicographic on strings). Vector dominance on vectors. Assume the PO is reflexive, i.e. for two identical values less_or_equal(v1,v1) must be true.
bool values_are_equal(value *v1,value *v2); value *mk_copy_value(value *val); void fprintf_value(FILE *s,char *m1,value *val,char *m2); void free_value(value *val); sequence *mk_empty_sequence(); void add_to_sequence(sequence *seq,value *val);
Assume sequence is previously of size n. After this it is of size n+1, and the n+1'th element is a COPY of val.
int sequence_size(sequence *seq); value *sequence_ref(sequence *seq,int index);
Returns a pointer (not a copy) to the index'th element stored in the [sequence]. Error if index < 0 or index >= size
void fprintf_sequence(FILE *s,char *m1,[sequence] *seq,char *m2); void free_sequence([sequence] *seq); sequence *mk_copy_sequence([sequence] *seq);
No white space is permitted in the print-string format for the time being. Fairly easily changed if that is desired in future.
If [primtype] is int then print_string="XXX" where XXX is the ascii printed int representation of an int. There must be no decimal point.
If [primtype] is bool then print_string="XXX" where XXX is the ascii printed bool representation. The strings "t" and "true" denote true. The strings "f" and "false" denote false. Boolean strings are recognized in a case insensitive manner, so TrUe also denotes true. No other string is legal.
If [primtype] is real then print_string="XXX" where XXX is the ascii printed double real representation and has a decimal point or a letter 'e' in it somewhere.
If [primtype] is a string then print_string=""XXX"" where XXX is the precise sequence of ASCII characters that appear in the string. Notice that at the current time, NO DOUBLE-QUOTES (" char) are allowed in strings. Easily modified if later this becomes needed.
If [primtype] is sequence then print_string="s(X0,X1,...Xn)" where X0..Xn are all print_string representations of values.