aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-05 16:42:37 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-05 16:52:58 +0300
commit806485a57fb37784e3e1789fce829a2bac390d99 (patch)
tree963e02852aa0203c912b9947eec0211e8661bc82 /include
parentf7b04cc09b26a7e1342170129dacf896f50f98b2 (diff)
downloadgrecs-806485a57fb37784e3e1789fce829a2bac390d99.tar.gz
grecs-806485a57fb37784e3e1789fce829a2bac390d99.tar.bz2
Fix syntax checking of compound vs. scalar statements. Add assertion functions.
Up to now the parser incorrectly accepted the use of compound statement keyword in scalar context, unless the keyword description had non NULL value in the callback field. This change fixes it. It also defines several assertion functions for use inm callbacks. * src/tree.c (grecs_value_type_string): New function. (find_keyword): Take into account node type. (nodeproc,reduceproc): Leave error reporting to find_keyword. * tests/set.at: Change expected error string. * include/grecs/tree.h (grecs_assert_value_type) (grecs_assert_scalar_stmt) (grecs_assert_node_value_type): New protos. * include/grecs/value.h (grecs_value_type_string): New proto. * src/Make.am: Add assert.c * src/assert.c: New file. * src/format.c (grecs_data_type_string): Add i18n markers to the returned strings.
Diffstat (limited to 'include')
-rw-r--r--include/grecs/node.h2
-rw-r--r--include/grecs/tree.h8
-rw-r--r--include/grecs/value.h1
3 files changed, 10 insertions, 1 deletions
diff --git a/include/grecs/node.h b/include/grecs/node.h
index 2d879ad..752b002 100644
--- a/include/grecs/node.h
+++ b/include/grecs/node.h
@@ -35,7 +35,7 @@ typedef struct grecs_node {
35 struct grecs_node *next; 35 struct grecs_node *next;
36 struct grecs_node *prev; 36 struct grecs_node *prev;
37 char *ident; 37 char *ident;
38 grecs_locus_t idloc; 38 grecs_locus_t idloc; /* Location of the identifier */
39 union { 39 union {
40 grecs_value_t *value; 40 grecs_value_t *value;
41 grecs_symtab_ptr_t texttab; 41 grecs_symtab_ptr_t texttab;
diff --git a/include/grecs/tree.h b/include/grecs/tree.h
index 2fb26dd..f13a74b 100644
--- a/include/grecs/tree.h
+++ b/include/grecs/tree.h
@@ -67,5 +67,13 @@ struct grecs_node *grecs_match_buf_get_node(grecs_match_buf_t buf);
67size_t grecs_match_buf_get_args(grecs_match_buf_t buf, char ***argv); 67size_t grecs_match_buf_get_args(grecs_match_buf_t buf, char ***argv);
68struct grecs_node *grecs_match_buf_get_root(grecs_match_buf_t buf); 68struct grecs_node *grecs_match_buf_get_root(grecs_match_buf_t buf);
69void grecs_match_buf_set_root(grecs_match_buf_t buf, struct grecs_node *root); 69void grecs_match_buf_set_root(grecs_match_buf_t buf, struct grecs_node *root);
70
71/* Assertions */
72int grecs_assert_value_type(const grecs_value_t *value, int type,
73 grecs_locus_t *refloc);
74int grecs_assert_scalar_stmt(grecs_locus_t *locus,
75 enum grecs_callback_command cmd);
76int grecs_assert_node_value_type(enum grecs_callback_command cmd,
77 grecs_node_t *node, int type);
70 78
71#endif 79#endif
diff --git a/include/grecs/value.h b/include/grecs/value.h
index 8cd2800..480db9d 100644
--- a/include/grecs/value.h
+++ b/include/grecs/value.h
@@ -44,6 +44,7 @@ typedef struct grecs_value {
44void grecs_value_free(struct grecs_value *val); 44void grecs_value_free(struct grecs_value *val);
45void grecs_value_free_content(struct grecs_value *val); 45void grecs_value_free_content(struct grecs_value *val);
46grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input); 46grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input);
47const char *grecs_value_type_string(int t);
47 48
48int grecs_value_eq(struct grecs_value *a, struct grecs_value *b); 49int grecs_value_eq(struct grecs_value *a, struct grecs_value *b);
49int grecs_value_match(struct grecs_value *pat, struct grecs_value *b, 50int grecs_value_match(struct grecs_value *pat, struct grecs_value *b,

Return to:

Send suggestions and report system problems to the System administrator.