Skip to content

Commit

Permalink
Updated spi.py for checking the parameters in procedure call
Browse files Browse the repository at this point in the history
  • Loading branch information
aniruddha2000 committed Aug 26, 2019
1 parent ff3c79c commit c920020
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions part16/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ErrorCode(Enum):
UNEXPECTED_TOKEN = 'Unexpected token'
ID_NOT_FOUND = 'Identifier not found'
DUPLICATE_ID = 'Duplicate id found'
WRONG_PARAMS_NUM = 'Wrong number of arguments'


class Error(Exception):
Expand Down Expand Up @@ -1004,6 +1005,19 @@ def visit_ProcedureCall(self, node):
for param_node in node.actual_params:
self.visit(param_node)

def visit_ProcedureCall(self, node):
proc_symbol = self.current_scope.lookup(node.proc_name)
formal_params = proc_symbol.params
actual_params = node.actual_params

if len(actual_params) != len(formal_params):
self.error(
error_code=ErrorCode.WRONG_PARAMS_NUM,
token=node.token
)

for param_node in node.actual_params:
self.visit(param_node)

###############################################################################
# #
Expand Down

0 comments on commit c920020

Please sign in to comment.