recutils
rec-sex-ast.h
Go to the documentation of this file.
1 /* -*- mode: C -*-
2  *
3  * File: rec-sex-ast.h
4  * Date: Tue Jan 12 17:07:59 2010
5  *
6  * GNU recutils - SEX Abstract Syntax Trees
7  *
8  */
9 
10 /* Copyright (C) 2010-2019 Jose E. Marchesi */
11 
12 /* This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef REC_SEX_AST_H
27 #define REC_SEX_AST_H
28 
29 #include <config.h>
30 
31 #include <stdbool.h>
32 
34 {
36 
37  /* Operations. */
61 
62  /* Values. */
67 };
68 
70 typedef struct rec_sex_ast_s *rec_sex_ast_t;
71 
72 /*
73  * Public functions.
74  */
75 
76 
77 /* Creation and destruction of ASTs. */
80 
81 /* Running the AST. */
82 /* Not here but in rec-sex.c int rec_sex_ast_run (rec_sex_ast_t ast, rec_record_t record); */
83 
86 
87 /* Nodes management. */
90 
93  enum rec_sex_ast_node_type_e type);
94 
96 void rec_sex_ast_node_set_int (rec_sex_ast_node_t node, int num);
98 void rec_sex_ast_node_set_real (rec_sex_ast_node_t node, double num);
100 void rec_sex_ast_node_set_str (rec_sex_ast_node_t node, char *str);
101 const char *rec_sex_ast_node_name (rec_sex_ast_node_t node);
103 void rec_sex_ast_node_set_name (rec_sex_ast_node_t node, const char *name, const char *subname);
104 
106 
108  int n);
109 
111  rec_sex_ast_node_t child);
112 
116  int index);
117 
119 
120 void rec_sex_ast_node_fix (rec_sex_ast_node_t node, char *val);
124 
125 /* This function returns 'true' if there is a node on AST of type
126  REC_SEX_NAME where NAME.name == NAME and NAME.idx <= IDX. */
127 bool rec_sex_ast_name_p (rec_sex_ast_t ast, const char *name, size_t idx);
128 
129 /* This function returns 'true' if there is a node on AST of type
130  REC_SEX_NAME where NAME.name == NAME and the parent of the node is
131  of type REC_SEX_OP_SHA, i.e. it recognizes #NAME in the source. */
132 bool rec_sex_ast_hash_name_p (rec_sex_ast_t ast, const char *name);
133 
134 #endif /* rec-sex-ast.h */
135 
136 
137 /* End of rec-sex-ast.h */
void rec_sex_ast_node_link(rec_sex_ast_node_t parent, rec_sex_ast_node_t child)
Definition: rec-sex-ast.c:228
const char * rec_sex_ast_node_subname(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:202
void rec_sex_ast_node_fix(rec_sex_ast_node_t node, char *val)
Definition: rec-sex-ast.c:313
void rec_sex_ast_node_set_name(rec_sex_ast_node_t node, const char *name, const char *subname)
Definition: rec-sex-ast.c:208
int rec_sex_ast_node_num_children(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:279
enum rec_sex_ast_node_type_e rec_sex_ast_node_type(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:136
int rec_sex_ast_node_index(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:347
struct rec_sex_ast_s * rec_sex_ast_t
Definition: rec-sex-ast.h:70
const char * rec_sex_ast_node_name(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:196
void rec_sex_ast_set_top(rec_sex_ast_t ast, rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:244
bool rec_sex_ast_hash_name_p(rec_sex_ast_t ast, const char *name)
Definition: rec-sex-ast.c:429
void rec_sex_ast_node_set_index(rec_sex_ast_node_t node, int index)
Definition: rec-sex-ast.c:353
void rec_sex_ast_node_set_int(rec_sex_ast_node_t node, int num)
Definition: rec-sex-ast.c:155
void rec_sex_ast_node_set_type(rec_sex_ast_node_t node, enum rec_sex_ast_node_type_e type)
Definition: rec-sex-ast.c:142
struct rec_sex_ast_node_s * rec_sex_ast_node_t
Definition: rec-sex-ast.h:69
bool rec_sex_ast_name_p(rec_sex_ast_t ast, const char *name, size_t idx)
Definition: rec-sex-ast.c:394
void rec_sex_ast_node_destroy(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:110
void rec_sex_ast_node_set_str(rec_sex_ast_node_t node, char *str)
Definition: rec-sex-ast.c:183
rec_sex_ast_node_type_e
Definition: rec-sex-ast.h:34
@ REC_SEX_OP_MAT
Definition: rec-sex-ast.h:46
@ REC_SEX_NAME
Definition: rec-sex-ast.h:66
@ REC_SEX_OP_MUL
Definition: rec-sex-ast.h:41
@ REC_SEX_OP_SUB
Definition: rec-sex-ast.h:40
@ REC_SEX_STR
Definition: rec-sex-ast.h:65
@ REC_SEX_OP_LTE
Definition: rec-sex-ast.h:49
@ REC_SEX_NOVAL
Definition: rec-sex-ast.h:35
@ REC_SEX_OP_OR
Definition: rec-sex-ast.h:52
@ REC_SEX_OP_MOD
Definition: rec-sex-ast.h:43
@ REC_SEX_OP_CONCAT
Definition: rec-sex-ast.h:60
@ REC_SEX_OP_GTE
Definition: rec-sex-ast.h:50
@ REC_SEX_OP_SAMETIME
Definition: rec-sex-ast.h:55
@ REC_SEX_OP_ADD
Definition: rec-sex-ast.h:39
@ REC_SEX_REAL
Definition: rec-sex-ast.h:64
@ REC_SEX_OP_NEG
Definition: rec-sex-ast.h:38
@ REC_SEX_OP_EQL
Definition: rec-sex-ast.h:44
@ REC_SEX_OP_NOT
Definition: rec-sex-ast.h:53
@ REC_SEX_OP_AFTER
Definition: rec-sex-ast.h:58
@ REC_SEX_OP_LT
Definition: rec-sex-ast.h:47
@ REC_SEX_OP_NEQ
Definition: rec-sex-ast.h:45
@ REC_SEX_OP_COND
Definition: rec-sex-ast.h:59
@ REC_SEX_INT
Definition: rec-sex-ast.h:63
@ REC_SEX_OP_BEFORE
Definition: rec-sex-ast.h:57
@ REC_SEX_OP_DIV
Definition: rec-sex-ast.h:42
@ REC_SEX_OP_GT
Definition: rec-sex-ast.h:48
@ REC_SEX_OP_IMPLIES
Definition: rec-sex-ast.h:56
@ REC_SEX_OP_AND
Definition: rec-sex-ast.h:51
@ REC_SEX_OP_SHA
Definition: rec-sex-ast.h:54
bool rec_sex_ast_node_fixed(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:335
rec_sex_ast_node_t rec_sex_ast_node_child(rec_sex_ast_node_t node, int n)
Definition: rec-sex-ast.c:285
double rec_sex_ast_node_real(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:163
void rec_sex_ast_node_unfix(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:322
void rec_sex_ast_print(rec_sex_ast_t ast)
Definition: rec-sex-ast.c:360
char * rec_sex_ast_node_str(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:177
rec_sex_ast_node_t rec_sex_ast_node_new(void)
Definition: rec-sex-ast.c:92
rec_sex_ast_node_t rec_sex_ast_top(rec_sex_ast_t ast)
Definition: rec-sex-ast.c:238
void rec_sex_ast_destroy(rec_sex_ast_t ast)
Definition: rec-sex-ast.c:81
char * rec_sex_ast_node_fixed_val(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:341
rec_sex_ast_t rec_sex_ast_new()
Definition: rec-sex-ast.c:67
int rec_sex_ast_node_int(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:149
void rec_sex_ast_node_set_real(rec_sex_ast_node_t node, double num)
Definition: rec-sex-ast.c:169
void rec_sex_ast_node_reset(rec_sex_ast_node_t node)
Definition: rec-sex-ast.c:300
Definition: rec-sex-ast.c:41
Definition: rec-sex-ast.c:58