Closed angelcaru closed 5 months ago
What do you think about this issue here?
$ python3.11 radon.py -s stdlib/Argparser.rn
Traceback (most recent call last):
File <stdin>, line 1, in <program>
File <stdin>, line 1, in require
Runtime Error: Failed to finish executing script "***/radon/stdlib/Argparser.rn"
Invalid Syntax: Expected '}'
File ***/radon/stdlib/Argparser.rn, line 10
this.options[option] = {"description": description, "is_flag": is_flag}
^
require("stdlib/Argparser.rn")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Still exist.
>>> some 234
Invalid Syntax: Token cannot appear after previous tokens
File <stdin>, line 1
some 234
^^^
And finally, we also need this huge list to be meaningful.
>>> to
Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not'
File <stdin>, line 1
to
^^
>>> step
Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not'
File <stdin>, line 1
step
^^^^
>>> [
Invalid Syntax: Expected ']', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '(', '[', '{' or 'not'
File <stdin>, line 1
[
^
>>> ]
Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not'
File <stdin>, line 1
]
^
Still exist.
>>> some 234 Invalid Syntax: Token cannot appear after previous tokens File <stdin>, line 1 some 234 ^^^
Yeah, but the error message actually makes sense in this context
And finally, we also need this huge list to be meaningful.
>>> to Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 to ^^ >>> step Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 step ^^^^ >>> [ Invalid Syntax: Expected ']', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '(', '[', '{' or 'not' File <stdin>, line 1 [ ^ >>> ] Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 ] ^
But it is meaningful! It's all of the possible tokens that start an expression. Admittedly, it could probably be rephrased as "expected expression" (that way it also never gets out of date). Will look into doing that
And finally, we also need this huge list to be meaningful.
>>> to Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 to ^^ >>> step Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 step ^^^^ >>> [ Invalid Syntax: Expected ']', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '(', '[', '{' or 'not' File <stdin>, line 1 [ ^ >>> ] Invalid Syntax: Expected 'return', 'continue', 'break', 'if', 'for', 'while', 'fun', int, float, identifier, '+', '-', '%', '(', '[', '{', or 'not' File <stdin>, line 1 ] ^
But it is meaningful! It's all of the possible tokens that start an expression. Admittedly, it could probably be rephrased as "expected expression" (that way it also never gets out of date). Will look into doing that
This looks total mess. As a user, I would expect 1 or 2 as suggestion. In some cases noting. Even Python doesn't shows like that. What is your opinion?
What is your opinion?
I'm currently in the process of rewriting all of those error messages to something like "expected expression"
There are more assert's exist.
But those I believe are actually unreachable. If you can reproduce them, I'll remove them
But those I believe are actually unreachable. If you can reproduce them, I'll remove them
Well lets see! 😃
I mean they're literally checking for a keyword at the start of a function that is only called when that keyword is found
Found a new one!
>>> 298345=
Invalid Syntax: Token cannot appear after previous tokens
File <stdin>, line 1
298345=
^
>>> dsjhfg=
Invalid Syntax: Token cannot appear after previous tokens
File <stdin>, line 1
dsjhfg=
^
>>> p=class
Invalid Syntax: Token cannot appear after previous tokens
File <stdin>, line 1
p=class
^
>>> some while
Invalid Syntax: Token cannot appear after previous tokens
File <stdin>, line 1
some while
^^^^^
Found a new one!
>>> 298345= Invalid Syntax: Token cannot appear after previous tokens File <stdin>, line 1 298345= ^ >>> dsjhfg= Invalid Syntax: Token cannot appear after previous tokens File <stdin>, line 1 dsjhfg= ^ >>> some while Invalid Syntax: Token cannot appear after previous tokens File <stdin>, line 1 some while ^^^^^
Still these exist.
Yeah but those are actually appropiate for the situation
I took some example from Python.
>>> 234545=
File "<stdin>", line 1
234545=
^^^^^^
SyntaxError: cannot assign to literal
>>> some while
File "<stdin>", line 1
some while
^^^^^
SyntaxError: invalid syntax
It looks fine now!
>>> some while File "<stdin>", line 1 some while ^^^^^ SyntaxError: invalid syntax
I'm pretty sure "Expected EOF" is more descriptive than "invalid syntax"
New complain in static
>>> static
Invalid Syntax: Expected 'fun'
File <stdin>, line 1
static
^
>>> static jdfg =2
2
>>> if {
... }
Invalid Syntax: Expected '{'
File <stdin>, line 2
}
^
>>> for i=3 to {
... }
Invalid Syntax: Expected '{'
File <stdin>, line 2
}
^
>>> if { ... } Invalid Syntax: Expected '{' File <stdin>, line 2 } ^ >>> for i=3 to { ... } Invalid Syntax: Expected '{' File <stdin>, line 2 } ^
That's actually "reasonable" (however funny it may be). It thinks you're using a HashMap as the if condition (or loop end point), so it parses that part correctly and fails when you don't provide a { for the body
I don't think there will be any major error related to "errors/exception" will be exist after this PR.
At least not syntax errors
I hope so.
Closes #112