1 
2 /******************************************************************************
3 * MODULE     : tree_analyze.hpp
4 * DESCRIPTION: routines for analyzing trees
5 * COPYRIGHT  : (C) 2010  Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11 
12 #ifndef TREE_ANALYZE_H
13 #define TREE_ANALYZE_H
14 #include "drd_std.hpp"
15 #include "language.hpp"
16 #include "analyze.hpp"
17 #include "vars.hpp"
18 
19 /******************************************************************************
20 * Concatenations and with-like structures
21 ******************************************************************************/
22 
23 array<tree> concat_tokenize (tree t);
24 array<tree> concat_decompose (tree t);
25 tree concat_recompose (array<tree> a);
26 
27 bool is_with_like (tree t);
28 tree& with_body (tree w);
29 bool with_same_type (tree w1, tree w2);
30 bool with_similar_type (tree w1, tree w2);
31 array<tree> with_decompose (tree w, tree t);
32 tree with_recompose (tree w, array<tree> a);
33 
34 /******************************************************************************
35 * Symbol types
36 ******************************************************************************/
37 
38 #define SYMBOL_DELETED           -1
39 #define SYMBOL_BASIC              0
40 #define SYMBOL_PREFIX             1
41 #define SYMBOL_POSTFIX            2
42 #define SYMBOL_INFIX              3
43 #define SYMBOL_SEPARATOR          4
44 #define SYMBOL_SKIP               5
45 #define SYMBOL_SCRIPT             6
46 #define SYMBOL_OPEN_BIG           7
47 #define SYMBOL_CLOSE_BIG          8
48 #define SYMBOL_OPEN               9
49 #define SYMBOL_MIDDLE            10
50 #define SYMBOL_CLOSE             11
51 #define SYMBOL_PROBABLE_OPEN     12
52 #define SYMBOL_PROBABLE_MIDDLE   13
53 #define SYMBOL_PROBABLE_CLOSE    14
54 #define SYMBOL_DUBIOUS_OPEN      15
55 #define SYMBOL_DUBIOUS_MIDDLE    16
56 #define SYMBOL_DUBIOUS_CLOSE     17
57 
58 int symbol_type (tree t);
59 array<int> symbol_types (array<tree> a);
60 
61 /******************************************************************************
62 * Symbol priorities
63 ******************************************************************************/
64 
65 #define PRIORITY_SEPARATOR          0
66 #define PRIORITY_ASSIGN             1
67 #define PRIORITY_FLUX               2
68 #define PRIORITY_MODELS             3
69 #define PRIORITY_IMPLY              4
70 #define PRIORITY_OR                 5
71 #define PRIORITY_AND                6
72 #define PRIORITY_RELATION           7
73 #define PRIORITY_ARROW              8
74 #define PRIORITY_UNION              9
75 #define PRIORITY_INTERSECTION      10
76 #define PRIORITY_PLUS              11
77 #define PRIORITY_TIMES             12
78 #define PRIORITY_POWER             13
79 #define PRIORITY_RADICAL           14
80 
81 int symbol_priority (tree t);
82 array<int> symbol_priorities (array<tree> a);
83 
84 /******************************************************************************
85 * DRD-based
86 ******************************************************************************/
87 
88 drd_info get_document_drd (tree doc);
89 bool is_correctable_child (tree t, int i, bool noaround= false);
90 
91 #endif // defined TREE_ANALYZE_H
92