diff --git a/include/tree.h b/include/tree.h index 7c51432..774191a 100644 --- a/include/tree.h +++ b/include/tree.h @@ -98,6 +98,13 @@ int libab_tree_has_string(libab_tree_variant var); * @return true if the tree node variant contains a type. */ int libab_tree_has_type(libab_tree_variant var); +/** + * Determines if the given tree node + * variant contains a scope. + * @param var the variant of the tree node. + * @return true if the node variant contains a scope. + */ +int libab_tree_has_scope(libab_tree_variant var); /** * Determines if the given tree node variant * should contain a vector. diff --git a/src/tree.c b/src/tree.c index b790bcf..4016249 100644 --- a/src/tree.c +++ b/src/tree.c @@ -16,6 +16,12 @@ int libab_tree_has_string(libab_tree_variant variant) { variant == TREE_RESERVED_OP; } +int libab_tree_has_scope(libab_tree_variant variant) { + return variant == TREE_BASE || variant == TREE_BLOCK || + variant == TREE_IF || variant == TREE_WHILE || + variant == TREE_DOWHILE || variant == TREE_FUN; +} + int libab_tree_has_type(libab_tree_variant variant) { return variant == TREE_FUN_PARAM || variant == TREE_FUN; }