mani-language / Mani

Máni ... an awesome, super simple programming language!
https://mani-language.github.io/
Mozilla Public License 2.0
28 stars 7 forks source link

Wrong with Class Parsing #18

Closed haifenghuang closed 5 years ago

haifenghuang commented 5 years ago

I have got an error when executing a person.mn file, it's contents are as beow:

Class Person {
    Person(first, last) {
        this.first = first;
        this.last = last;
    }

    normal() {
        say this.first + ", " + this.last;
    }

    internal reverse() {
        say this.last + " " + this.first;
    }

    both() {
        this.reverse();
        this.normal();
    }
}

let p = Person("John", "Doe");

p.normal();     // John, Doe
p.reverse();    // Sorry, this is a private function!
p.both();       // Doe John ... John Doe

But it always report below error:

[line 9] Error at '}'  : Expect expression.
[line 13] Error at '}'  : Expect expression.
[line 18] Error at '}'  : Expect expression.
crazywolf132 commented 5 years ago

Hi there!

Thank you for getting in touch, I would have replied sooner but I have just gotten back from holidays. I see the error, and I have edited the documents to reflect the changes.

The problem is the capital "C" in "Class" the reason everything is freaking out, is because it doesn't realise it is in a class.

Once you fix that... It will arise a problem at line 24, which is the p.reverse(); line. The reason is is raising an error is because the reverse function is private.

Once you remove that, the program will continue to run.

Regards.