Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement import from in symbol table #195

Merged
merged 4 commits into from
Oct 27, 2023

Conversation

Glyphack
Copy link
Owner

@Glyphack Glyphack commented Oct 23, 2023

  • Add import from statements to symbol table
  • Update tests to pretty print import results

This is what we want to do for imports:

  • import a: Adds an entry to the symbol table for the module a. The entry includes the module name and a flag indicating it is a module.
  • from a import b: Adds an entry for b that points to the symbol b within the module a. The entry includes the symbol name, a flag indicating it is imported, and a reference to the module symbol a.
  • from a import *: Adds an entry to symbol table with name *. This symbol table node will be used in another pass to actually copy the symbols from imported module in this table.

@Glyphack Glyphack marked this pull request as draft October 23, 2023 21:22
@@ -18,7 +18,7 @@ use crate::{
pub struct SemanticAnalyzer {
pub globals: SymbolTable,
file: Box<EnderpyFile>,
pub imports: HashMap<String, Box<ImportResult>>,
pub imports: HashMap<String, ImportResult>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you do that?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it was unnecessary. Box should be used either for performance or for recursive structs and none are this case.

@Glyphack Glyphack force-pushed the import-resolver-semantic-analyzer branch from 351b464 to 5b248ae Compare October 24, 2023 20:04
@Glyphack Glyphack requested a review from ghodsizadeh October 24, 2023 21:25
@Glyphack Glyphack linked an issue Oct 24, 2023 that may be closed by this pull request
2 tasks
@Glyphack Glyphack marked this pull request as ready for review October 25, 2023 18:25
@Glyphack Glyphack force-pushed the import-resolver-semantic-analyzer branch from 0c82162 to 466af13 Compare October 25, 2023 19:42
@Glyphack Glyphack force-pushed the import-resolver-semantic-analyzer branch from 466af13 to d436757 Compare October 25, 2023 19:48
@Glyphack Glyphack merged commit f745827 into main Oct 27, 2023
1 check passed
@Glyphack Glyphack deleted the import-resolver-semantic-analyzer branch October 27, 2023 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add alias declaration to symbol table
2 participants