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

Symbol Table: Maintain tables by variable data type #84

Open
6 tasks
meganindya opened this issue Nov 10, 2021 · 3 comments
Open
6 tasks

Symbol Table: Maintain tables by variable data type #84

meganindya opened this issue Nov 10, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers unit-scope Related to the scope module
Milestone

Comments

@meganindya
Copy link
Member

meganindya commented Nov 10, 2021

Description

The Symbol Table component in src/syntax/symbol-table/symbolTable.ts maintains global, program-specific, and routine-specific variables only by variable name. You can only fetch variables by variable name. Add methods for each table to fetch variables by variable name and variable data type.

For example, say there is a global variable foo of data type number. Currently you can fetch it by getGlobalVariable('foo'). The objective is to optionally supply the type as well like getGlobalVariable('foo', 'number'), which returns the same. But, calling getGlobalVariable('foo', 'string') returns null.

Objectives

Refactor function signatures (make change in symbolTable.ts file and the symbolTable.spec.ts file):

  • getGlobalVariable(variable: string, dataType?: TDataName): IVariable | null
  • getProcessVariable(variable: string, program: string, dataType?: TDataName): IVariable | null
  • getRoutineVariable(variable: string, routine: string, dataType?: TDataName): IVariable | null

Add unit tests for:

  • getGlobalVariable with dataType field
  • getProcessVariable with dataType field
  • getRoutineVariable with dataType field
@meganindya meganindya added enhancement New feature or request good first issue Good for newcomers unit-syntax-elements Related to syntax elements labels Nov 10, 2021
@meganindya meganindya changed the title Syntax: [Symbol Table] Maintain tables by variable data type Symbol Table: Maintain tables by variable data type Nov 13, 2021
@meganindya meganindya added unit-scope Related to the scope module and removed unit-syntax-elements Related to syntax elements labels Nov 13, 2021
@S-kus
Copy link

S-kus commented Jan 31, 2022

Hello @meganindya, I would like to work on this issue.
After going through the code, the file symbolTable.spec.ts (not symbolTable.d.ts) and symbolTable.ts are currently in src/execution/, Ig it's needed to update in the description of the issue.
Could you please confirm once again that we needed to change the getGlobalVariable() function similar to addGlobalVariable() and what is getProgramVariable I am not able to find it in any files, Is it getProcessVariable? but it's already updated according to the issue.

@meganindya
Copy link
Member Author

Yes, I updated the identifiers. The output variable format needs to be what the IVariable type describes. However, all three private variable tables _globalTable, _processTable, and _routineTable store variables by variable name. They need to store those variables by data types at the top level and then by variable names inside the data types namespace. This way two identically named variables with different data types can be stored.

The objective is to:

  • make changes in the private variable tables to store variables by data type and then by variable names within them
  • make changes to the public query functions as specified above

@S-kus
Copy link

S-kus commented Feb 1, 2022

Thanks @meganindya, I am working on it.

impAkshat added a commit to impAkshat/musicblocks-v4-lib that referenced this issue Feb 7, 2022
* Changed `IVariableTable` type
* Changed `_globalTable` accordingly
@meganindya meganindya added this to the Release v0.3.0 milestone Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers unit-scope Related to the scope module
Projects
None yet
Development

No branches or pull requests

2 participants