Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LANGUAGE] improved error productions for at #4663

Merged
merged 31 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2bd64b4
made changes in isValid , is_program_valid in hedy.py | exceptions.py…
akseron Oct 24, 2023
471b594
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2023
9e02a95
comments added
akseron Oct 29, 2023
1c5859e
resolve conflicts
akseron Oct 29, 2023
c2e95da
Merge branch 'error-productions' of https://github.com/hedyorg/hedy i…
akseron Oct 29, 2023
a09c191
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2023
85cb6b9
Update hedy.py
akseron Oct 30, 2023
8c98530
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 30, 2023
44373dc
mainly debugging print statements, misspelled at works but implementa…
akseron Oct 31, 2023
9db8e49
Merge branch 'error-productions' of https://github.com/hedyorg/hedy i…
akseron Oct 31, 2023
8f1e460
Update level3-Additions.lark
akseron Oct 31, 2023
0c1f3cb
Update level3-Additions.lark
akseron Oct 31, 2023
cad1c3a
removed print statements
akseron Oct 31, 2023
2bdb0d0
debugging var_access _at var_access
akseron Nov 6, 2023
9fdf152
improved error message for invalid index command
akseron Nov 6, 2023
3e344b8
unnecessary as handled in previous commit
akseron Nov 6, 2023
909e74a
added simple error messages for dutch and english
akseron Nov 7, 2023
070bdaa
added testing + pybabel compiled
akseron Nov 20, 2023
3c8212f
Merge branch 'main' into error-productions
Felienne Nov 21, 2023
e0fb5ba
reextract babel strings
Felienne Nov 21, 2023
b2f0175
Update exceptions.py
akseron Nov 21, 2023
03a3ab8
Update tests/test_level/test_level_04.py
Felienne Nov 21, 2023
341fe1b
Update test_level_04.py
akseron Nov 21, 2023
aa3f4d9
Update tests/test_level/test_level_04.py
Felienne Nov 21, 2023
fbbb17b
Merge branch 'main' into error-productions
Felienne Nov 21, 2023
ad02016
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2023
8910590
removed error messages
akseron Nov 21, 2023
4e30aef
break the code to make the test pass :)
Felienne Nov 21, 2023
82c8108
reverted to original spacing (unimportant)
akseron Nov 21, 2023
184aec6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2023
48ecb6f
remove old todo comment
Felienne Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ def __init__(self, level, line_number, unquotedtext=None):
line_number=line_number)


class MisspelledAtCommand(HedyException):
# TODO adjust the parameters, will only put this in en/messages.po
akseron marked this conversation as resolved.
Show resolved Hide resolved
def __init__(self, level, line_number):
super().__init__('Misspelled At Command',
level=level,
line_number=line_number)


class UnquotedAssignTextException(HedyException):
def __init__(self, text, line_number):
super().__init__('Unquoted Assignment', text=text, line_number=line_number)
Expand Down
4 changes: 3 additions & 1 deletion grammars/level3-Additions.lark
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
command:+= assign_list | add | remove > error_invalid
command:+= error_list_access | assign_list | add | remove > error_invalid
_print_argument: (_SPACE | (list_access textwithoutspaces?) | textwithoutspaces)*
ask: var _IS _ASK ((_SPACE | text_ask)*)?

error_list_access: var_access textwithoutspaces? (INT | random)

assign: var _IS (list_access | text) -> assign
assign_list: var _IS text_list (_COMMA text_list)+

Expand Down
8 changes: 8 additions & 0 deletions hedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ def error_print_nq(self, meta, args):
return False, InvalidInfo("print without quotes", arguments=[
text], line=meta.line, column=meta.column), meta

def error_list_access(self, meta, args):
# for now copying another function, to test whether anything is being done at all
error = InvalidInfo('misspelled "at" command', arguments=[str(args[0])], line=meta.line, column=meta.column)
return False, error, meta

def error_invalid(self, meta, args):
# TODO: this will not work for misspelling 'at', needs to be improved!

Expand Down Expand Up @@ -3204,6 +3209,9 @@ def is_program_valid(program_root, input_string, level, lang):
unquotedtext = invalid_info.arguments[0]
raise exceptions.UnquotedTextException(
level=level, unquotedtext=unquotedtext, line_number=invalid_info.line)
elif invalid_info.error_type == 'misspelled "at" command':
# raising an exception here, for now default parameters, will put the wrongly spelled word later on
raise exceptions.MisspelledAtCommand(level=level, line_number=line)
elif invalid_info.error_type == 'unsupported number':
raise exceptions.UnsupportedFloatException(value=''.join(invalid_info.arguments))
elif invalid_info.error_type == 'lonely text':
Expand Down
4 changes: 4 additions & 0 deletions translations/en/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ msgstr ""
"finish with a quotation mark. You forgot that for the text "
"{unquotedtext}."

msgid "Misspelled At Command"
akseron marked this conversation as resolved.
Show resolved Hide resolved
msgstr " "
"You have probably misspelled the 'at' command. Don't forget to fix it."

msgid "Unsupported Float"
msgstr ""
"Non-integer numbers are not supported yet but they will be in a few "
Expand Down
Loading