SCompiler/opcode
2025-04-22 16:54:33 +08:00

70 lines
1.7 KiB
Plaintext

module: CommonTasks
function: add_numbers
parameter:
declare num1: int
declare num2: int
return_type: int
body:
return num1 + num2
end body
end function
end module
module: MathUtils
function: square_number
parameter:
declare number: int
return_type: int
body:
return number * number
end body
end function
end module
module: StringUtils
function: concatenate
parameter:
declare first_str: string
declare second_str: string
return_type: string
body:
return first_str + second_str
end body
end function
end module
module: MainModule
import: CommonTasks, MathUtils, StringUtils, BuiltinUtils
function: main
parameter:
args: string
return_type: void
body:
loop:
initializer:
declare counter: int = 5
condition:
counter > 0
update:
counter = counter - 1
body:
BuiltinUtils.print(counter)
end body
end loop
declare input_number: int = BuiltinUtils.to_int(args)
if input_number == 0 then
input_number = 999
end if
declare sum_result: int = CommonTasks.add_numbers(input_number, 20)
declare squared_result: int = MathUtils.square_number(sum_result)
declare final_message: string = StringUtils.concatenate("Result:",BuiltinUtils.to_string(squared_result))
BuiltinUtils.print(final_message)
end body
end function
end module