Gidsss / UwUIDE

A compiler made to be cute uwu >~<
6 stars 0 forks source link

Feat/int float builtin types #242

Closed am-cid closed 4 months ago

am-cid commented 4 months ago

closes #241


builtin Int and Float types

todo: implement other builtin methods (only abs() for now)


test log for Int operations while capping value

src

image

transpiled

image

output

image

test log for Int Float assignment and val capping

src

image

transpiled

def main():
    _num: Float = Float(input(String("Enter number to be squared: ")))
    _times: Int = Int(Float(input(String("Enter number of times to square: "))))
    if (_num > 0):
        _i: Int = Int(Float(0))
        while (_i < _times):
            print(_num)
            _num = Float(_square(_num))
            _i = (_i + 1)

    else:
        print(String(f"Enter a positive number. '{_num}' is not a positive number."))

def _square(_num: Float):
    _num: Float = Float(_num)
    return (_num * _num)

if __name__ == '__main__':
    # clear screen before executing
    import platform
    import os
    os.system('cls' if platform.system() == 'Windows' else 'clear')

    # declare globals
    main()

output

image