Gidsss / UwUIDE

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

Fix/fn calls as accessors and subscriptors, Feat/substring assignment error #282

Closed am-cid closed 4 months ago

am-cid commented 4 months ago

closes #279


fn calls are now allowed to be subscripted and be an accessor

b = z.concat("0"){0}~          >.< now ok, previously errored
a = b.concat("c").concat("d")~ >.< now ok, previously errored

cannot assign to string subscripts anymore

a-senpai = "hello"~
a{0} = "1"~ >.< now errored, previously ok

test log

sample text file
-------------------------------------------------------
 1 |
 2 |     cwass HoloFactory() [[
 3 |         factory-Hololive = Hololive()~
 4 |         fwunc fact-Hololive() [[
 5 |             wetuwn(Hololive())~
 6 |         ]]
 7 |     ]]
 8 |     cwass Hololive() [[
 9 |         strings-senpai[] = {""}~
10 |         string-senpai = ""~
11 |         fwunc str-senpai() [[
12 |             wetuwn(string)~
13 |         ]]
14 |     ]]
15 |     fwunc mainuwu-san() [[
16 |         z-senpai[2] = {{"hello"}}~
17 |         a-senpai[] = {"hello"}~
18 |         b-senpai = a{0}{0}{0}{0}{0}~
19 |         a{0}{0}{0}{0}{0}{0}{0} = "x"~
20 |         b{0}{0}{0}{0}{0}{0}{0} = "y"~
21 |         z{0}{0}{0}{0}{0}{0}{0} = "z"~
22 |
23 |         c-Hololive = Hololive()~
24 |         c.string = c.str()~
25 |         c.string{0} = c.str()~
26 |         c.strings{0} = c.str()~
27 |         c.strings{0}{0} = c.str()~
28 |
29 |         d-HoloFactory = HoloFactory()~
30 |
31 |         d.factory.string = d.factory.str()~
32 |         d.factory.string{0} = d.factory.str()~
33 |         d.factory.strings{0} = d.factory.str()~
34 |         d.factory.strings{0}{0} = d.factory.str()~
35 |
36 |         d.fact().string = d.factory.str()~
37 |         d.fact().string{0} = d.factory.str()~
38 |         d.fact().strings{0} = d.factory.str()~
39 |         d.fact().strings{0}{0} = d.factory.str()~
40 |     ]]
41 |
-------------------------------------------------------
end of file

Assignment to substring is not allowed: 'a{0}{0}{0}{0}{0}{0}{0}'
        ___________________________________________
           |    Defined here
        17 |         a-senpai[] = {"hello"}~
           |           ^^^^^^
           | __________|
           | |
           | |  Tried to assign here
        19 | |        a{0}{0}{0}{0}{0}{0}{0} = "x"~
           | |        ^
           | |________|
           |
           |    Hint: use .replace()
        .. |    a{0} = a{0}.replace(
        .. |        a{0}{0},
        .. |        "x"
        .. |    )~
        ___________________________________________

Assignment to substring is not allowed: 'b{0}{0}{0}{0}{0}{0}{0}'
        ___________________________________________
           |    Defined here
        18 |         b-senpai = a{0}{0}{0}{0}{0}~
           |           ^^^^^^
           | __________|
           | |
           | |  Tried to assign here
        20 | |        b{0}{0}{0}{0}{0}{0}{0} = "y"~
           | |        ^
           | |________|
           |
           |    Hint: use .replace()
        .. |    b = b.replace(
        .. |        b{0},
        .. |        "y"
        .. |    )~
        ___________________________________________

Assignment to substring is not allowed: 'z{0}{0}{0}{0}{0}{0}{0}'
        ___________________________________________
           |    Defined here
        16 |         z-senpai[2] = {{"hello"}}~
           |           ^^^^^^
           | __________|
           | |
           | |  Tried to assign here
        21 | |        z{0}{0}{0}{0}{0}{0}{0} = "z"~
           | |        ^
           | |________|
           |
           |    Hint: use .replace()
        .. |    z{0}{0} = z{0}{0}.replace(
        .. |        z{0}{0}{0},
        .. |        "z"
        .. |    )~
        ___________________________________________

Assignment to substring is not allowed: 'c.string{0}'
        ____________________________________
           |    Defined here
        10 |         string-senpai = ""~
           |                ^^^^^^
           | _______________|
           | |
           | |  Tried to assign here
        25 | |        c.string{0} = c.str()~
           | |          ^^^^^^
           | |__________|
           |
           |    Hint: use .replace()
        .. |    c.string = c.string.replace(
        .. |        c.string{0},
        .. |        c.str()
        .. |    )~
        ____________________________________

Assignment to substring is not allowed: 'c.strings{0}{0}'
        ________________________________________
           |    Defined here
        9  |         strings-senpai[] = {""}~
           |                 ^^^^^^
           | ________________|
           | |
           | |  Tried to assign here
        27 | |        c.strings{0}{0} = c.str()~
           | |          ^^^^^^^
           | |__________|
           |
           |    Hint: use .replace()
        .. |    c.strings{0} = c.strings{0}.replace(
        .. |        c.strings{0}{0},
        .. |        c.str()
        .. |    )~
        ________________________________________

Assignment to substring is not allowed: 'd.factory.string{0}'
        ____________________________________________________
           |    Defined here
        10 |         string-senpai = ""~
           |                ^^^^^^
           | _______________|
           | |
           | |  Tried to assign here
        32 | |        d.factory.string{0} = d.factory.str()~
           | |                  ^^^^^^
           | |__________________|
           |
           |    Hint: use .replace()
        .. |    d.factory.string = d.factory.string.replace(
        .. |        d.factory.string{0},
        .. |        d.factory.str()
        .. |    )~
        ____________________________________________________

Assignment to substring is not allowed: 'd.factory.strings{0}{0}'
        ________________________________________________________
           |    Defined here
        9  |         strings-senpai[] = {""}~
           |                 ^^^^^^
           | ________________|
           | |
           | |  Tried to assign here
        34 | |        d.factory.strings{0}{0} = d.factory.str()~
           | |                  ^^^^^^^
           | |__________________|
           |
           |    Hint: use .replace()
        .. |    d.factory.strings{0} = d.factory.strings{0}.replace(
        .. |        d.factory.strings{0}{0},
        .. |        d.factory.str()
        .. |    )~
        ________________________________________________________

Assignment to substring is not allowed: 'd.fact().string{0}'
        ___________________________________________________
           |    Defined here
        10 |         string-senpai = ""~
           |                ^^^^^^
           | _______________|
           | |
           | |  Tried to assign here
        37 | |        d.fact().string{0} = d.factory.str()~
           | |                 ^^^^^^
           | |_________________|
           |
           |    Hint: use .replace()
        .. |    d.fact().string = d.fact().string.replace(
        .. |        d.fact().string{0},
        .. |        d.factory.str()
        .. |    )~
        ___________________________________________________

Assignment to substring is not allowed: 'd.fact().strings{0}{0}'
        _______________________________________________________
           |    Defined here
        9  |         strings-senpai[] = {""}~
           |                 ^^^^^^
           | ________________|
           | |
           | |  Tried to assign here
        39 | |        d.fact().strings{0}{0} = d.factory.str()~
           | |                 ^^^^^^^
           | |_________________|
           |
           |    Hint: use .replace()
        .. |    d.fact().strings{0} = d.fact().strings{0}.replace(
        .. |        d.fact().strings{0}{0},
        .. |        d.factory.str()
        .. |    )~
        _______________________________________________________