path: root/include
authorSergey Poznyakoff <>2019-06-05 13:42:37 (GMT)
committer Sergey Poznyakoff <>2019-06-05 13:52:58 (GMT)
commit806485a57fb37784e3e1789fce829a2bac390d99 (patch) (side-by-side diff)
tree963e02852aa0203c912b9947eec0211e8661bc82 /include
parentf7b04cc09b26a7e1342170129dacf896f50f98b2 (diff)
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/ 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/ 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') (more/less context) (ignore whitespace changes)
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 {
struct grecs_node *next;
struct grecs_node *prev;
char *ident;
- grecs_locus_t idloc;
+ grecs_locus_t idloc; /* Location of the identifier */
union {
grecs_value_t *value;
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);
size_t grecs_match_buf_get_args(grecs_match_buf_t buf, char ***argv);
struct grecs_node *grecs_match_buf_get_root(grecs_match_buf_t buf);
void grecs_match_buf_set_root(grecs_match_buf_t buf, struct grecs_node *root);
+/* Assertions */
+int grecs_assert_value_type(const grecs_value_t *value, int type,
+ grecs_locus_t *refloc);
+int grecs_assert_scalar_stmt(grecs_locus_t *locus,
+ enum grecs_callback_command cmd);
+int grecs_assert_node_value_type(enum grecs_callback_command cmd,
+ grecs_node_t *node, int type);
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 {
void grecs_value_free(struct grecs_value *val);
void grecs_value_free_content(struct grecs_value *val);
grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input);
+const char *grecs_value_type_string(int t);
int grecs_value_eq(struct grecs_value *a, struct grecs_value *b);
int grecs_value_match(struct grecs_value *pat, struct grecs_value *b,

Return to:

Send suggestions and report system problems to the System administrator.