Feat: Better identifier handling #16
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to improve identifier handling in the codebase. The most important changes include the addition of new functions for registering and checking identifiers, updates to existing functions to incorporate these new checks, and the addition of new test cases to validate the changes.
Improvements to identifier handling:
src/lang.c: Added calls toregister_identifier_*andcheck_identifier_*functions in various type-related functions to ensure proper registration and validation of identifiers. [1] [2] [3] [4] [5] [6] [7] [8] [9]src/lib.c: Introduced new functions for registering and checking identifiers, includingregister_identifier,register_identifier_variable,register_identifier_enumerator,register_identifier_struct,register_identifier_union,register_identifier_enum,register_identifier_typedef, and correspondingcheck_identifier_*functions.src/lib.h: Added new enums and structs to support the identifier registration and checking logic, includingenum IdentifierTypeandstruct IdentifierInfo. Also added function declarations for the new identifier handling functions.Test cases:
resource/test/test-identifier-predeclared/testcase1.jtl.h: Added test cases to validate the registration and checking of various identifier types, including structs, enums, unions, and typedefs.resource/test/test-indentifier-register/testcase-redefine-var.jtl.h: Added test cases to check for warnings when redefining identifiers as different types.Documentation and other changes:
readme.md: Updated the checklist to reflect the completion of tasks related to checking identifiers in global declarations and ensuring proper pre-definition.src/main.c: Initialized the identifier table in the main function to support the new identifier handling logic. [1] [2]src/lang.c: Includedlib.hto access the new identifier handling functions.