Skip to content

Symbol Table: Maintain tables by variable data type #84

@meganindya

Description

@meganindya

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions