Gidsss / UwUIDE

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

Feat/random stdlib #289

Closed am-cid closed 3 months ago

am-cid commented 3 months ago

closes #288

  1. randomInt-chan(bound1: number, bound2: number)
    • bound1 doesn't necessarily need to be lesser than bound2.
    • the fn will calculate which is the lower and upper bound anyway.
  2. randomFloat-kun(bound1: number, bound2: number)
    • bound1 doesn't necessarily need to be lesser than bound2.
    • the fn will calculate which is the lower and upper bound anyway.
  3. randomBool-sama()
  4. randomString-senpai(length: number)
    • length is floored to 0 so passing in negative numbers is fine

member checking logs

sample text file
--------------------------------------
1 |
2 |     fwunc mainuwu-san() [[
3 |         randomInt-chan = 1~
4 |         randomInt = 1~
5 |         randomInt = randomInt + 1~
6 |     ]]
7 |
--------------------------------------
end of file

Duplicate bulitin function: randomInt
        _______________________________
          |     tried to redefine as identifier
        3 |         randomInt-chan = 1~
          |         ^^^^^^^^^
        _______________________________

Tried to assign a value to a builtin function: randomInt()
        ___________________________
          |     'randomInt()' is a builtin function and cannot be assigned to
        4 |         randomInt = 1~
          |         ^^^^^^^^^
        ___________________________

Tried to assign a value to a builtin function: randomInt()
        _______________________________________
          |     'randomInt()' is a builtin function and cannot be assigned to
        5 |         randomInt = randomInt + 1~
          |         ^^^^^^^^^
        _______________________________________

Tried to use builtin function as value: randomInt()
        _______________________________________
          |     'randomInt()' is a builtin function and cannot be used as a value without calling it
        5 |         randomInt = randomInt + 1~
          |                     ^^^^^^^^^
        _______________________________________

type checking logs

sample text file
----------------------------------------------
 1 |
 2 |     fwunc mainuwu-san() [[
 3 |         a-chan = randomInt()~
 4 |         b-senpai = randomFloat()~
 5 |         b = randomBool()~
 6 |         a = randomString()~
 7 |
 8 |         a = -randomString()~
 9 |         a = randomString()++~
10 |         a = randomInt() + randomString()~
11 |     ]]
12 |
----------------------------------------------
end of file

Call arg type mismatch:
        __________________________________
          |
          |     'randomInt()' called here
        3 |         a-chan = randomInt()~
          |                  ^^^^^^^^^
          |
          |     'randomInt()' function expects 2 arguments but was called with 0
          |     EXPECTED               ACTUAL ARG
          |
          |     2 args missing
          |     ✗ chan, kun, or sama    ( MISSING )
          |     ✗ chan, kun, or sama    ( MISSING )
        __________________________________

Call arg type mismatch:
        ______________________________________
          |
          |     'randomFloat()' called here
        4 |         b-senpai = randomFloat()~
          |                    ^^^^^^^^^^^
          |
          |     'randomFloat()' function expects 2 arguments but was called with 0
          |     EXPECTED               ACTUAL ARG
          |
          |     2 args missing
          |     ✗ chan, kun, or sama    ( MISSING )
          |     ✗ chan, kun, or sama    ( MISSING )
        ______________________________________

Declaration Type Mismatch: expected 'senpai' but got 'kun'
        ______________________________________
             |    Expected type defined here
        4    |         b-senpai = randomFloat()~
             |           ^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'kun'
        4..n | |    b-senpai = randomFloat()
             | |               ^^^^^^^^^^^^^
             | |_______________|
        ______________________________________

Assignment Type Mismatch: expected 'senpai' but got 'sama'
        ______________________________________
             |    Expected type defined here
        4    |         b-senpai = randomFloat()~
             |           ^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'sama'
        5..n | |    b = randomBool()
             | |        ^^^^^^^^^^^^
             | |________|
        ______________________________________

Call arg type mismatch:
        ________________________________
          |
          |     'randomString()' called here
        6 |         a = randomString()~
          |             ^^^^^^^^^^^^
          |
          |     'randomString()' function expects 1 argument but was called with 0
          |     EXPECTED               ACTUAL ARG
          |
          |     1 arg missing
          |     ✗ chan, kun, or sama    ( MISSING )
        ________________________________

Assignment Type Mismatch: expected 'chan' but got 'senpai'
        __________________________________
             |    Expected type defined here
        3    |         a-chan = randomInt()~
             |           ^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'senpai'
        6..n | |    a = randomString()
             | |        ^^^^^^^^^^^^^^
             | |________|
        __________________________________

Call arg type mismatch:
        _________________________________
          |
          |     'randomString()' called here
        8 |         a = -randomString()~
          |              ^^^^^^^^^^^^
          |
          |     'randomString()' function expects 1 argument but was called with 0
          |     EXPECTED               ACTUAL ARG
          |
          |     1 arg missing
          |     ✗ chan, kun, or sama    ( MISSING )
        _________________________________

Non-Math Prefix Operator: 'randomString()'
        ______________________
          |     Value below evaluates to type: 'senpai'
        8 |   -randomString()
          |    ^^^^^^^^^^^^^^
        ______________________

Assignment Type Mismatch: expected 'chan' but got 'senpai'
        __________________________________
             |    Expected type defined here
        3    |         a-chan = randomInt()~
             |           ^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'senpai'
        8..n | |    a = -randomString()
             | |        ^^^^^^^^^^^^^^^
             | |________|
        __________________________________

Call arg type mismatch:
        __________________________________
          |
          |     'randomString()' called here
        9 |         a = randomString()++~
          |             ^^^^^^^^^^^^
          |
          |     'randomString()' function expects 1 argument but was called with 0
          |     EXPECTED               ACTUAL ARG
          |
          |     1 arg missing
          |     ✗ chan, kun, or sama    ( MISSING )
        __________________________________

Non-Math Postfix Operator: 'randomString()'
        ______________________
          |     Value below evaluates to type: 'senpai'
        9 |   randomString()++
          |   ^^^^^^^^^^^^^^
        ______________________

Assignment Type Mismatch: expected 'chan' but got 'senpai'
        __________________________________
             |    Expected type defined here
        3    |         a-chan = randomInt()~
             |           ^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'senpai'
        9..n | |    a = randomString()++
             | |        ^^^^^^^^^^^^^^^^
             | |________|
        __________________________________

Call arg type mismatch:
        _______________________________________________
           |
           |    'randomInt()' called here
        10 |         a = randomInt() + randomString()~
           |             ^^^^^^^^^
           |
           |    'randomInt()' function expects 2 arguments but was called with 0
           |    EXPECTED               ACTUAL ARG
           |
           |    2 args missing
           |    ✗ chan, kun, or sama    ( MISSING )
           |    ✗ chan, kun, or sama    ( MISSING )
        _______________________________________________

Call arg type mismatch:
        _______________________________________________
           |
           |    'randomString()' called here
        10 |         a = randomInt() + randomString()~
           |                           ^^^^^^^^^^^^
           |
           |    'randomString()' function expects 1 argument but was called with 0
           |    EXPECTED               ACTUAL ARG
           |
           |    1 arg missing
           |    ✗ chan, kun, or sama    ( MISSING )
        _______________________________________________

Non-Math Infix Operand:
        _________________________________
           |    Left value evaluates to type: 'chan'
        10 |   randomInt()+randomString()
           |   ^^^^^^^^^^^
           |
           |    Right value evaluates to type: 'senpai'
        10 |   randomInt()+randomString()
           |               ^^^^^^^^^^^^^^
        _________________________________