1
/* Copyright (C) 1995 Bjoern Beutel. */
3
/* Description. =============================================================*/
5
/* This file contains data structures and functions used for grammatical
8
/* Types. ===================================================================*/
10
typedef enum {MORPHOLOGY, SYNTAX} grammar_t; /* Types of grammatic analysis. */
12
typedef enum {BREAK_NODE, FINAL_NODE, UNFINAL_NODE, INTER_NODE,
13
PRUNED_NODE} tree_node_type_t;
15
typedef enum {ANALYSE_WORD, ANALYSE_ALL} analysis_mode_t;
16
typedef enum {NO_TREE, BUILD_TREE} tree_mode_t;
18
typedef struct /* A node of the analysis tree. */
20
int_t index; /* Index of this analysis tree node. */
21
tree_node_type_t type;
22
int_t parent_index; /* Index of parent analysis tree node or -1. */
23
string_t rule_name; /* Name of the rule that created result or NULL. */
24
string_t link_surf; /* Link's surface or NULL. */
25
value_t link_fs; /* Link's feature structure or NULL. */
26
string_t result_surf; /* Surface of resulting state or NULL. */
27
value_t result_fs; /* Feature structure of resulting state or NULL. */
28
string_t rule_set; /* Successor rules of resulting state or NULL. */
32
{ROBUST_RULE_OPTION, PRUNING_RULE_OPTION, CACHE_OPTION,
33
MOR_OUT_FILTER_OPTION, SYN_IN_FILTER_OPTION, SYN_OUT_FILTER_OPTION,
34
MOR_INCOMPLETE_OPTION, SYN_INCOMPLETE_OPTION,
35
ANALYSIS_OPTION_COUNT} analysis_option_t;
37
typedef enum {STATE_SURFACE, LINK_SURFACE, RESULT_SURFACE} surface_t;
38
/* Kinds of surfaces that can be obtained by "get_rule_info" in "rules.h" */
40
/* Variables. ===============================================================*/
42
extern rule_sys_t *rule_system[2];
43
/* rule_system[ MORPHOLOGY ] and rule_system[ SYNTAX ]. Read only! */
45
extern grammar_t top_grammar; /* Grammar of last analysis. Read only! */
47
extern int_t state_count; /* Counts number of generated states. Read only! */
49
extern int_t current_state; /* Index of current state. Read only! */
51
extern bool_t recognised_by_combi_rules;
52
/* TRUE if last analysis was recognised by combi rules. Read only! */
54
extern bool_t recognised_by_robust_rule;
55
/* TRUE if last analysis was recognised by robust rule. Read only! */
57
extern string_t last_analysis_input;
58
/* Start of top level input string. Read only! */
60
extern void (*debug_state)( int_t index, bool_t enter );
61
/* Callback function for "analyse".
62
* This is called with ENTER == TRUE when successor rules for
63
* state with analysis node INDEX will be executed.
64
* It is called with ENTER == FALSE when successor rules for state with
65
* analysis node INDEX have been executed. */
67
extern string_t (*get_surface)( surface_t surface_type );
68
/* Return surface SURFACE_TYPE for currently executed rule.
69
* The result must be freed after use. */
71
/* Functions. ===============================================================*/
73
extern void init_analysis( string_t morphology_file, string_t syntax_file );
74
/* Initialise the analysis module.
75
* MORPHOLOGY_FILE and SYNTAX_FILE are the rule files to load.
76
* SYNTAX_FILE may be NULL. */
78
extern void terminate_analysis( void );
79
/* Free analysis module. */
81
extern void preprocess_input( string_t input, bool_t expect_quotes);
82
/* Delete heading and trailing spaces in INPUT
83
* and compress all whitespace sequences to a single space.
84
* If EXPECT_QUOTES == TRUE, expect quoted input and remove the quotes. */
86
extern void set_analysis_option( analysis_option_t selected, bool_t setting );
87
/* Set analysis option SELECTED to SETTING. */
89
extern bool_t get_analysis_option( analysis_option_t selected );
90
/* Return the current setting of analysis option SELECTED. */
92
extern void analyse( grammar_t grammar,
94
tree_mode_t tree_mode,
95
analysis_mode_t mode );
96
/* Perform a LAG analysis of INPUT using GRAMMAR (MORPHOLOGY or SYNTAX).
97
* An analysis tree will be built if TREE_MODE == BUILD_TREE.
98
* The whole input will be analysed if MODE == ANALYSE_ALL. */
100
extern bool_t analysis_has_results( void );
101
/* Return TRUE iff the last analysis has created results. */
103
extern value_t first_analysis_result( void );
104
/* Return the feature structure of the first analysis result.
105
* Return NULL if there are no results. */
107
extern value_t next_analysis_result( void );
108
/* Return the feature structure of the next analysis result.
109
* Return NULL if there are no more results. */
111
extern bool_t analysis_has_nodes( void );
112
/* Return TRUE iff the last analysis has created tree nodes. */
114
extern analysis_node_t *get_first_analysis_node( void );
115
/* Return the first analysis tree node of the last analysis.
116
* Return NULL if there is no node.
117
* The node must be freed with "free_analysis_node" after use. */
119
extern analysis_node_t *get_next_analysis_node( void );
120
/* Return the next analysis tree node of the last analysis.
121
* Return NULL if there is no more node.
122
* The node must be freed with "free_analysis_node" after use. */
124
extern void free_analysis_node( analysis_node_t **node );
125
/* Free the memory occupied by NODE. */
127
/* End of file. =============================================================*/