erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.63k stars 54 forks source link

Classify parser errors and use them #320

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Currently, many of the errors in the parser use simple_syntax_error( or skip_and_throw_syntax_err). This causes almost all errors to generate invalid syntax error, making them difficult to understand. This lets you know how invalid syntax is.

In addition, add doc comment.

Changes proposed in this PR:

Define specify error

Use following errors

Internal error(parser bug)

It is a high possibility of the parser bug if it coccus

Invalid/unintended syntax error

Some sentences are written in Parser They are not listed here

syntax error of parsing

Minor adjustment

@mtshiba

GreasySlug commented 1 year ago

Could you please check the translation again when this PR is ready from the draft? @C-BJ

It's fine about 2 failing checks I'll fix them

C-BJ commented 1 year ago

OK

GreasySlug commented 1 year ago

对不起,这个PR仍在进行中 我建议你先不要翻译它,因为我正在做破坏性的修改 能否请你在这份PR从草稿中准备好后再检查一下翻译 如果你想知道,到目前为止,你的翻译并没有引起任何冲突,所以这不是一个问题 @C-BJ

C-BJ commented 1 year ago

oh, sorry. I read it wrong.

GreasySlug commented 1 year ago

70% of the work has been done

mtshiba commented 1 year ago

The parser seems to erase class attributes.

C = Class {x = Int;}
C.
    x = 1 # no-linebreak
$ cargo r -- --mode parse test.er
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target\debug\erg.exe --mode parse test.er`
C =
    ::Class:
        {::x =
    ::Int; }

$
C-BJ commented 1 year ago

Please ask me to review the translation again when it is finished @GreasySlug

GreasySlug commented 1 year ago

Please ask me to review the translation again when it is finished @GreasySlug

I have finished writing the error messages, so if there are any translation errors or good translations in the Chinese ones please correct them, @C-BJ

mtshiba commented 1 year ago

Congrats & thank you so much!