record class names
This commit is contained in:
parent
21e8c6c4ca
commit
022d636605
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user