1
/* Copyright (C) 1995 Bjoern Beutel. */
3
/* Description. =============================================================*/
5
/* This module defines the structure of compiled Malaga files. */
7
/* Constants. ===============================================================*/
9
enum {MALAGA_LEN = 6}; /* Length of magic code at beginning of Malaga file. */
11
/* Values for FILE_TYPE. */
12
enum {SYMBOL_FILE, RULE_FILE, LEXICON_FILE, PRELEX_FILE};
14
/* Versions of compiled Malaga file types. */
15
enum {SYMBOL_CODE_VERSION = 7};
16
enum {RULE_CODE_VERSION = 46};
17
enum {LEXICON_CODE_VERSION = 13};
18
enum {PRELEX_CODE_VERSION = 0};
20
/* Versions of Malaga file types that are still understood. */
21
enum {MIN_SYMBOL_CODE_VERSION = 7};
22
enum {MIN_RULE_CODE_VERSION = 46};
23
enum {MIN_LEXICON_CODE_VERSION = 13};
24
enum {MIN_PRELEX_CODE_VERSION = 0};
26
/* Types. ===================================================================*/
28
typedef struct /* The common header of every Malaga file. */
30
char_t malaga[ MALAGA_LEN ]; /* "MALAGA" to recognise Malaga files. */
31
u_byte_t hangul; /* TRUE iff Hangul char set is used. */
32
byte_t file_type; /* SYMBOL_FILE, RULE_FILE or LEXICON_FILE. */
33
int_t code_version; /* Only load code of the current version. */
34
int_t sym_stamp; /* Stamp for ".sym" file. */
35
int_t esym_stamp; /* Stamp for ".esym" file or 0. */
38
/*---------------------------------------------------------------------------*/
40
typedef struct /* The format of a Malaga rule file. */
42
common_header_t common_header;
43
int_t initial_rule_set; /* Index of the initial rule set in RULE_SETS. */
44
int_t initial_fs; /* Index of the initial feature structure in VALUES. */
45
int_t robust_rule; /* Rule number of robust_rule. */
46
int_t pruning_rule; /* Rule number of pruning_rule. */
47
int_t allo_rule; /* Rule number of allo_rule. */
48
int_t input_filter; /* Rule number of input_filter. */
49
int_t output_filter; /* Rule number of output_filter. */
50
int_t rule_count; /* Number of rules in this file. */
51
int_t rule_sets_size; /* Size of rule set table. */
52
int_t instr_count; /* Number of instructions in this file. */
53
int_t values_size; /* Size of Malaga value table. */
54
int_t src_line_count; /* Number of correspondences
55
* between source lines and rule code. */
56
int_t var_count; /* Number of variable names. */
57
int_t var_scope_count; /* Number of variable scopes. */
58
int_t constant_count; /* Number of named constants. */
59
int_t strings_size; /* Size of string table. */
61
/* The following blocks have dynamic size: */
62
/* rule_t rules[ rule_count ]; */
63
/* int_t rule_sets[ rule_sets_size ]; */
64
/* instr_t instrs[ instr_count ]; */
65
/* cell_t values[ values_size ]; */
66
/* src_line_t src_lines[ src_line_count ]; */
67
/* var_t vars[ var_count ]; */
68
/* var_scope_t var_scopes[ var_scope_count ]; */
69
/* constant_t constants[ constant_count ]; */
70
/* char_t strings[ strings_size ]; */
73
/*---------------------------------------------------------------------------*/
75
typedef struct /* An entry in the symbol table. */
77
int_t name; /* STRINGS index to symbol name. */
78
int_t atoms; /* VALUES index to list of the atomic symbols
79
* of a multi-symbol (or -1). */
82
typedef struct /* The format of a Malaga symbol file. */
84
common_header_t common_header;
85
int_t symbol_count; /* Number of symbols in this file. */
86
int_t values_size; /* Size of Malaga value table (for multi-symbols). */
87
int_t strings_size; /* Size of string table (for symbol names). */
89
/* The following blocks have dynamic size:
90
* symbol_entry_t symbols[ symbol_count ];
91
* cell_t values[ values_size ];
92
* char_t strings[ strings_size ]; */
95
/*---------------------------------------------------------------------------*/
97
typedef struct /* An entry in the prelex file. */
99
int_t surface; /* STRINGS index to surface. */
100
int_t fs; /* VALUES index to feature structure. */
103
typedef struct /* The format of a Malaga prelex file. */
105
common_header_t common_header;
106
int_t entry_count; /* Number of entries in this file. */
107
int_t values_size; /* Size of value table. */
108
int_t strings_size; /* Size of string table. */
110
/* The following blocks have dynamic size:
111
* prelex_entry_t entries[ entry_count ];
112
* cell_t values[ values_size ];
113
* char_t strings[ strings_size ]; */
116
/*---------------------------------------------------------------------------*/
118
typedef struct /* The format of a Malaga lexicon file. */
120
common_header_t common_header;
121
int_t trie_size; /* Size of trie table. */
122
int_t trie_root; /* Index of root node in TRIE. */
123
int_t fs_lists_size; /* Size of feature structure lists table. */
124
int_t values_size; /* Size of value table. */
126
/* The following blocks have dynamic size:
127
* int_t trie[ trie_size ];
128
* int_t fs_lists[ fs_lists_size ];
129
* cell_t values[ values_size ]; */
132
/* Functions. ===============================================================*/
134
extern void set_sym_stamp( void );
135
/* Create a stamp for the ".sym" file */
137
extern void set_esym_stamp( void );
138
/* Create a stamp for the ".esym" file */
140
extern void check_header( common_header_t *header,
143
int_t min_code_version,
144
int_t max_code_version );
145
/* Check if HEADER is of FILE_TYPE and
146
* between MIN_CODE_VERSION and MAX_CODE_VERSION.
147
* FILE_NAME is needed for error messages. */
149
extern void set_header( common_header_t *header,
151
int_t code_version );
152
/* Set header to be of FILE_TYPE and CODE_VERSION. */
154
/* End of file. =============================================================*/