record class names

This commit is contained in:
josh committed 2018-06-13 00:07:06 -04:00
1 parent 21e8c6c4ca
commit 022d636605
3 files changed
+15

No files matched your search

+11
View File
@@ -7,6 +7,7 @@
#include <stdbool.h>
std::unordered_set<std::string> type_names;
std::unordered_set<std::string> class_names;
extern FILE * yyin;
@@ -260,3 +261,13 @@ void set_translation_unit_node(Node * _translation_unit_node)
{
translation_unit_node = _translation_unit_node;
}
void observe_class_name(const std::string & name)
{
class_names.insert(name);
}
bool is_class_name(const std::string & name)
{
return class_names.count(name) != 0u;
}
+2
View File
@@ -15,5 +15,7 @@ void handle_parse_error(const char * str, const YYLTYPE * yylloc);
void observe_type_name(const Node * node);
bool is_type_name(const std::string & type_name);
void set_translation_unit_node(Node * _translation_unit_node);
void observe_class_name(const std::string & name);
bool is_class_name(const std::string & name);
#endif
+2
View File
@@ -749,9 +749,11 @@ enumerator
class_specifier
: CLASS IDENTIFIER LCURLY RCURLY {
$$ = new Node(NODE_TYPE_LIST);
observe_class_name(*$2->token.text);
}
| CLASS IDENTIFIER LCURLY external_declaration_list RCURLY {
$$ = new Node(NODE_TYPE_LIST);
observe_class_name(*$2->token.text);
}
;