Gidsss / UwUIDE

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

int and float literals auto converted to builtin type, more array builtin methods, `.pow()` fix #280

Closed am-cid closed 4 months ago

am-cid commented 4 months ago

closes #277 closes #276 closes #271


changes

  1. More Array builtin methods
    • specified at #277
  2. int and float literals are auto converted to Int and Float respectively at a literal level
    • just like Bool, String, and Arrays
  3. all builtin number types have __pow__() and __rpow__() methods now

    test log

    source

    image

    transpiled

    image

    output

    image

am-cid commented 4 months ago

type checking test log

sample text file
---------------------------------------------
 1 |
 2 |     fwunc mainuwu-san() [[
 3 |         a-chan[2] = {{2}, {1}}~
 4 |         b-chan[1] = a.pop()~
 5 |         b = a{0}.pop()~
 6 |         c-chan[2] = a.pop()~
 7 |         c = a{0}.pop()~
 8 |         d-chan[3] = a.pop()~
 9 |         d = a{0}.pop()~
10 |
11 |         e-chan[1] = a.shift()~
12 |         e = a{0}.shift()~
13 |         f-chan[2] = a.shift()~
14 |         f = a{0}.shift()~
15 |         g-chan[3] = a.shift()~
16 |         g = a{0}.shift()~
17 |
18 |         h-chan[1] = a.first(1)~
19 |         h = a{0}.first(1)~
20 |         i-chan[2] = a.first(2)~
21 |         i = a{0}.first(2)~
22 |         j-chan[3] = a.first(3)~
23 |         j = a{0}.first(3)~
24 |
25 |         k-chan[1] = a.last(1)~
26 |         k = a{0}.last(1)~
27 |         l-chan[2] = a.last(2)~
28 |         l = a{0}.last(2)~
29 |         m-chan[3] = a.last(3)~
30 |         m = a{0}.last(3)~
31 |
32 |         n-chan[1] = a.replace(1, 2)~
33 |         n = a{0}.replace(1, 2)~
34 |         o-chan[2] = a.replace({3}, 4)~
35 |         o = a{0}.replace({3}, 4)~
36 |         p-chan[3] = a.replace({5}, {6})~
37 |         p = a{0}.replace({5}, {6})~
38 |
39 |         q-chan[1] = a.dimension()
40 |                 + b.dimension()
41 |                 - c.dimension()
42 |                 * d.dimension()
43 |                 / e.dimension()
44 |                 % f.dimension()
45 |                 + g.dimension()
46 |                 - h.dimension()
47 |                 * i.dimension()
48 |                 / j.dimension()
49 |                 % k.dimension()
50 |                 + l.dimension()
51 |                 - m.dimension()
52 |                 * n.dimension()
53 |                 / o.dimension()
54 |                 % p.dimension()~
55 |     ]]
56 |
---------------------------------------------
end of file

Assignment Type Mismatch: expected 'chan[1]' but got 'chan'
        _________________________________
             |    Expected type defined here
        4    |         b-chan[1] = a.pop()~
             |           ^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan'
        5..n | |    b = a{0}.pop()
             | |        ^^^^^^^^^^
             | |________|
        _________________________________

Declaration Type Mismatch: expected 'chan[2]' but got 'chan[1]'
        _________________________________
             |    Expected type defined here
        6    |         c-chan[2] = a.pop()~
             |           ^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan[1]'
        6..n | |    c-chan[2] = a.pop()
             | |                ^^^^^^^
             | |________________|
        _________________________________

Assignment Type Mismatch: expected 'chan[2]' but got 'chan'
        _________________________________
             |    Expected type defined here
        6    |         c-chan[2] = a.pop()~
             |           ^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan'
        7..n | |    c = a{0}.pop()
             | |        ^^^^^^^^^^
             | |________|
        _________________________________

Declaration Type Mismatch: expected 'chan[3]' but got 'chan[1]'
        _________________________________
             |    Expected type defined here
        8    |         d-chan[3] = a.pop()~
             |           ^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan[1]'
        8..n | |    d-chan[3] = a.pop()
             | |                ^^^^^^^
             | |________________|
        _________________________________

Assignment Type Mismatch: expected 'chan[3]' but got 'chan'
        _________________________________
             |    Expected type defined here
        8    |         d-chan[3] = a.pop()~
             |           ^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan'
        9..n | |    d = a{0}.pop()
             | |        ^^^^^^^^^^
             | |________|
        _________________________________

Assignment Type Mismatch: expected 'chan[1]' but got 'chan'
        _____________________________________
              |    Expected type defined here
        11    |         e-chan[1] = a.shift()~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan'
        12..n | |    e = a{0}.shift()
              | |        ^^^^^^^^^^^^
              | |________|
        _____________________________________

Declaration Type Mismatch: expected 'chan[2]' but got 'chan[1]'
        _____________________________________
              |    Expected type defined here
        13    |         f-chan[2] = a.shift()~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        13..n | |    f-chan[2] = a.shift()
              | |                ^^^^^^^^^
              | |________________|
        _____________________________________

Assignment Type Mismatch: expected 'chan[2]' but got 'chan'
        _____________________________________
              |    Expected type defined here
        13    |         f-chan[2] = a.shift()~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan'
        14..n | |    f = a{0}.shift()
              | |        ^^^^^^^^^^^^
              | |________|
        _____________________________________

Declaration Type Mismatch: expected 'chan[3]' but got 'chan[1]'
        _____________________________________
              |    Expected type defined here
        15    |         g-chan[3] = a.shift()~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        15..n | |    g-chan[3] = a.shift()
              | |                ^^^^^^^^^
              | |________________|
        _____________________________________

Assignment Type Mismatch: expected 'chan[3]' but got 'chan'
        _____________________________________
              |    Expected type defined here
        15    |         g-chan[3] = a.shift()~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan'
        16..n | |    g = a{0}.shift()
              | |        ^^^^^^^^^^^^
              | |________|
        _____________________________________

Declaration Type Mismatch: expected 'chan[1]' but got 'chan[2]'
        ______________________________________
              |    Expected type defined here
        18    |         h-chan[1] = a.first(1)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[2]'
        18..n | |    h-chan[1] = a.first(1)
              | |                ^^^^^^^^^^
              | |________________|
        ______________________________________

Assignment Type Mismatch: expected 'chan[2]' but got 'chan[1]'
        ______________________________________
              |    Expected type defined here
        20    |         i-chan[2] = a.first(2)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        21..n | |    i = a{0}.first(2)
              | |        ^^^^^^^^^^^^^
              | |________|
        ______________________________________

Declaration Type Mismatch: expected 'chan[3]' but got 'chan[2]'
        ______________________________________
              |    Expected type defined here
        22    |         j-chan[3] = a.first(3)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[2]'
        22..n | |    j-chan[3] = a.first(3)
              | |                ^^^^^^^^^^
              | |________________|
        ______________________________________

Assignment Type Mismatch: expected 'chan[3]' but got 'chan[1]'
        ______________________________________
              |    Expected type defined here
        22    |         j-chan[3] = a.first(3)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        23..n | |    j = a{0}.first(3)
              | |        ^^^^^^^^^^^^^
              | |________|
        ______________________________________

Declaration Type Mismatch: expected 'chan[1]' but got 'chan[2]'
        _____________________________________
              |    Expected type defined here
        25    |         k-chan[1] = a.last(1)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[2]'
        25..n | |    k-chan[1] = a.last(1)
              | |                ^^^^^^^^^
              | |________________|
        _____________________________________

Assignment Type Mismatch: expected 'chan[2]' but got 'chan[1]'
        _____________________________________
              |    Expected type defined here
        27    |         l-chan[2] = a.last(2)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        28..n | |    l = a{0}.last(2)
              | |        ^^^^^^^^^^^^
              | |________|
        _____________________________________

Declaration Type Mismatch: expected 'chan[3]' but got 'chan[2]'
        _____________________________________
              |    Expected type defined here
        29    |         m-chan[3] = a.last(3)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[2]'
        29..n | |    m-chan[3] = a.last(3)
              | |                ^^^^^^^^^
              | |________________|
        _____________________________________

Assignment Type Mismatch: expected 'chan[3]' but got 'chan[1]'
        _____________________________________
              |    Expected type defined here
        29    |         m-chan[3] = a.last(3)~
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[1]'
        30..n | |    m = a{0}.last(3)
              | |        ^^^^^^^^^^^^
              | |________|
        _____________________________________

Call arg type mismatch:
        __________________________________________
           |
           |    'chan[2].replace()' called here
        32 |         n-chan[1] = a.replace(1, 2)~
           |                       ^^^^^^^
           |
           |    'chan[2].replace()' class method expects 2 arguments
           |    EXPECTED     ACTUAL     ARG
           |    ✗ chan[1]    chan       1
           |    ✗ chan[1]    chan       2
        __________________________________________

Call arg type mismatch:
        ____________________________________________
           |
           |    'chan[2].replace()' called here
        34 |         o-chan[2] = a.replace({3}, 4)~
           |                       ^^^^^^^
           |
           |    'chan[2].replace()' class method expects 2 arguments
           |    EXPECTED     ACTUAL      ARG
           |    ✓ chan[1]    chan[1]     {3}
           |    ✗ chan[1]    chan        4
        ____________________________________________

Call arg type mismatch:
        _______________________________________
           |
           |    'chan[1].replace()' called here
        35 |         o = a{0}.replace({3}, 4)~
           |                  ^^^^^^^
           |
           |    'chan[1].replace()' class method expects 2 arguments
           |    EXPECTED     ACTUAL      ARG
           |    ✗ chan       chan[1]     {3}
           |    ✓ chan       chan        4
        _______________________________________

Call arg type mismatch:
        _________________________________________
           |
           |    'chan[1].replace()' called here
        37 |         p = a{0}.replace({5}, {6})~
           |                  ^^^^^^^
           |
           |    'chan[1].replace()' class method expects 2 arguments
           |    EXPECTED     ACTUAL      ARG
           |    ✗ chan       chan[1]     {5}
           |    ✗ chan       chan[1]     {6}
        _________________________________________

Declaration Type Mismatch: expected 'chan[1]' but got 'chan'
        ________________________________________
              |    Expected type defined here
        39    |         q-chan[1] = a.dimension()
              |           ^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan'
        39..n | |    q-chan[1] = ((((((a.dimension() + b.dimension()) - (((c.dimension() * d.dimension()) / e.dimension()) % f.dimension())) + g.dimension()) - (((h.dimension() * i.dimension()) / j.dimension()) % k.dimension())) + l.dimension()) - (((m.dimension() * n.dimension()) / o.dimension()) % p.dimension()))
              | |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              | |________________|
        ________________________________________