Skip to content

Commit

Permalink
added fuction return feature to parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
NaveenDanj committed Dec 27, 2022
1 parent dfd3971 commit 6626234
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Binary file modified lib/RuntimUtil/__pycache__/function_util.cpython-37.pyc
Binary file not shown.
15 changes: 14 additions & 1 deletion lib/RuntimUtil/function_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ def handle_function_call(statement , parse_tree):
for item in st.parameters.items():
obj = item[1]
obj['func_name'] = function_name
obj['value'] = eval( param_list[counter] )
# obj['value'] = eval( param_list[counter] )
if 'get' in param_list[counter]:
val = param_list[counter]
function_name_ = val.split(' ' , 1)[1]
function_name_ = function_name_[:function_name_.index('>')-1]
function_name_ = function_name_.strip()
if function_name_ not in ret:
raise Exception('Function name ' + function_name_ + ' undefined!')
else:
obj['value'] = ret[function_name_]['value']
else:
obj['value'] = eval( param_list[counter] )


param[ obj['var_name'] ] = obj
counter += 1
else:
Expand Down
9 changes: 8 additions & 1 deletion test/t1.pr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@start

function print_statement (string s) ->
print var('s')
endfunction

function factorial (int n) ->

var int total = 1
Expand All @@ -16,9 +20,12 @@
function InputNumber () ->
var int x1 = int( input('Enter number : ') )
call factorial ->( var('x1') )


var int ret_val = 1
set var('ret_val') = get factorial ->( var('x1') )
print 'value is : ' + str( var('ret_val') )
~ print
call print_statement ->( get factorial ->( var('x1') ) )
endfunction

var int itterator = 3
Expand Down

0 comments on commit 6626234

Please sign in to comment.