1
/* Copyright (C) 1995 Bjoern Beutel. */
3
/* Description. =============================================================*/
5
/* This is the header file for "libmalaga". */
7
/*===========================================================================*/
13
/* Constants. ===============================================================*/
15
/* Current version of libmalaga interface. */
16
#define LIBMALAGA_VERSION 6
18
/* Minimum version of libmalaga interface that is still fully supported. */
19
#define MIN_LIBMALAGA_VERSION 6
22
#define NULL 0 /* Null pointer. */
24
/* Some standard symbols. */
25
enum {NIL_SYMBOL, YES_SYMBOL, NO_SYMBOL,
26
SYMBOL_SYMBOL, STRING_SYMBOL, NUMBER_SYMBOL, LIST_SYMBOL, RECORD_SYMBOL};
28
/* Basic types. =============================================================*/
31
typedef signed char byte_t; /* Signed 8 bits. */
32
typedef unsigned char u_byte_t; /* Unsigned 8 bits. */
33
typedef signed short int short_t; /* Signed 16 bits. */
34
typedef unsigned short int u_short_t; /* Unsigned 16 bits. */
35
typedef signed int int_t; /* Signed 32 bits. */
36
typedef unsigned int u_int_t; /* Unsigned 32 bits. */
38
/* Character types. */
39
typedef char char_t; /* A single char. */
40
typedef char_t *string_t; /* An EOS-terminated C-style string. */
41
enum {EOS= '\0'}; /* End-Of-String control character. */
42
#define ORD(c) ((u_byte_t) (c)) /* The ordinal number of character C. */
45
#undef bool_t /* <rpc/rpc.h> conflicts with "bool_t" definition */
48
typedef enum {FALSE, TRUE} bool_t;
50
typedef u_short_t cell_t;
51
/* A value is stored in one or more cells.
52
* Use this type if you want to allocate memory (pools etc.) for values. */
54
typedef cell_t *value_t; /* Reference to a Malaga values by this type. */
55
typedef cell_t symbol_t;
57
typedef enum {MORPHOLOGY, SYNTAX} grammar_t; /* Grammatical analysis types. */
59
/* Variables. ===============================================================*/
61
extern char_t malaga_version[]; /* Read only! */
62
extern bool_t hangul; /* Read only! */
64
extern string_t malaga_error;
65
/* If one of the functions below has created an error, this variable
66
* contains an error message. If a function did its job, it is NULL. */
68
extern enum {INTERNAL_ORDER, ALPHABETIC_ORDER,
69
DEFINITION_ORDER} attribute_order;
70
/* The order in which attributes in a record are printed.
71
* INTERNAL_ORDER is the order in which attributes are stored internally.
72
* ALPHABETIC_ORDER means the alphabetic order of the attribute names.
73
* DEFINITION_ORDER is the order in which the attributes are defined in the
75
* Used by "value_readable". */
77
/* Value functions. =========================================================*/
79
extern value_t new_value( value_t value );
80
/* Allocate space for VALUE and copy it.
81
* Free the space occupied by this value with "free" after use. */
83
extern int_t length_of_value( value_t value );
84
/* Return the length of VALUE in cells. */
86
extern symbol_t get_value_type( value_t value );
87
/* Return the type of VALUE. Depending of the type, the result value may be
88
* SYMBOL_SYMBOL, STRING_SYMBOL, NUMBER_SYMBOL, LIST_SYMBOL, RECORD_SYMBOL. */
90
extern symbol_t value_to_symbol( value_t value );
91
/* Return VALUE as a symbol. It is an error if VALUE is no symbol. */
93
extern string_t get_symbol_name( symbol_t symbol );
94
/* Return the name of SYMBOL. */
96
extern value_t get_atoms( symbol_t symbol );
97
/* Return the list of atoms of SYMBOL. */
99
extern string_t get_value_string( value_t string );
100
/* Return the value of STRING as a C-style string in external encoding.
101
* The string must be freed after use. */
103
extern value_t get_attribute( value_t record, symbol_t attribute );
104
/* Return the value of ATTRIBUTE in RECORD or NULL if it doesn't exist. */
106
extern int_t get_list_length( value_t list );
107
/* Return the number of elements in the list LIST. */
109
extern value_t get_element( value_t list, int_t n );
110
/* Return the N-th element of the list LIST, or NULL if it doesn't exist.
111
* If N is positive, elements will be counted from the left border.
112
* If N is negative, elements will be counted from the right border. */
114
extern double value_to_double( value_t value );
115
/* Return the value of VALUE which must be a number value. */
117
extern int_t value_to_int( value_t value );
118
/* Return the value of VALUE which must be an integral number value. */
120
extern value_t get_value_part( value_t value, value_t path );
121
/* Return the value part of VALUE that is specified by the path PATH.
122
* If that value part does not exist, return NULL. */
124
extern value_t get_first_item( value_t value );
125
/* If VALUE is a list, then return its first element (or NULL).
126
* If VALUE is a record, then return its first attribute (or NULL). */
128
extern value_t get_next_item( value_t value, value_t item );
129
/* If VALUE is a list, and ELEMENT one of its elements,
130
* then NEW_ELEMENT is the successor of ELEMENT (or NULL).
131
* If VALUE is a record, and ELEMENT one of its attributes,
132
* then NEW_ELEMENT is the next attribute in VALUE (or NULL). */
134
extern bool_t values_equal( value_t value1, value_t value2 );
135
/* Return a truth value indicating whether VALUE1 and VALUE2 are equal.
136
* VALUE1 an VALUE2 must be of same type or one of them must be nil.
137
* Refer to documentation to see what "equal" in Malaga really means. */
139
extern bool_t values_congruent( value_t value1, value_t value2 );
140
/* Return a truth value indicating whether VALUE1 and VALUE2 have
141
* at least one element in common.
142
* VALUE1 and VALUE2 must both be symbols or lists. */
144
extern bool_t value_in_value( value_t value1, value_t value2 );
145
/* Return bool value saying if VALUE1 is element or attribute of VALUE2.
146
* VALUE2 must be a list or a record.
147
* If VALUE2 is a record, then VALUE1 must be a symbol. */
149
extern string_t value_to_readable( value_t value,
152
/* Return VALUE in a format readable for humans.
153
* If FULL_VALUE == TRUE, show all attributes, even those that are hidden.
154
* If INDENT >= 0, format value, i.e. print each element of a list or record
155
* on a line of its own. Assume the value is indented by INDENT columns.
156
* Use "free" to free the space after use. */
158
extern value_t parse_malaga_value( string_t string );
159
/* Convert the STRING to a Malaga value and return it.
160
* The value must be freed after use.
161
* This function sets "malaga_error". */
163
/* Functions. ===============================================================*/
165
extern void set_option( string_t option );
166
/* Set a libmalaga option.
167
* This function sets "malaga_error". */
169
extern string_t get_info( void );
170
/* Get info about the current grammar. */
172
extern void analyse_item( string_t item, grammar_t grammar );
173
/* Analyse ITEM according to GRAMMAR.
174
* GRAMMAR must be MORPHOLOGY or SYNTAX.
175
* This function sets "malaga_error". */
177
extern value_t first_analysis_result( void );
178
/* Get the first result of the last call of "analyse_item".
179
* Return NULL if there is no result. */
181
extern value_t next_analysis_result( void );
182
/* Get the next result of the last call of "analyse_item".
183
* Return NULL if there is no more result. */
185
extern void init_libmalaga( string_t project_file );
186
/* Initialise this module.
187
* This function sets "malaga_error". */
189
extern void terminate_libmalaga( void );
190
/* Terminate this module. */
192
/*===========================================================================*/
198
/* End of file. =============================================================*/