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

[CHORE] move exceptions into isvalid #4838

Merged
merged 35 commits into from
Dec 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
64cf381
move exception into isvalid
Felienne Dec 1, 2023
372ceb4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2023
145ae6d
move more raises up and leave some notes to self
Felienne Dec 2, 2023
bd084d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2023
4a787b0
clarify for further work
Felienne Dec 2, 2023
80d4b58
Merge branch 'main' into clean-up-invalid
Felienne Dec 4, 2023
4d97bbc
can happen when you interrupt a test!
Felienne Dec 4, 2023
3b30591
more rewriting
Felienne Dec 4, 2023
a1e7f25
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2023
3827304
Merge branch 'main' into clean-up-invalid
Felienne Dec 5, 2023
ecaa994
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2023
9677022
fix tests
Felienne Dec 5, 2023
fa73d5f
Merge branch 'clean-up-invalid' of https://github.com/hedyorg/hedy in…
Felienne Dec 5, 2023
8bd9e43
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2023
310df05
update tree rewriting (not ready yet!)
Felienne Dec 5, 2023
c7669b3
Revert "update tree rewriting (not ready yet!)"
Felienne Dec 5, 2023
a82a77d
Revert "Merge branch 'clean-up-invalid' of https://github.com/hedyorg…
Felienne Dec 5, 2023
1597c94
merge
Felienne Dec 5, 2023
a494b46
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 5, 2023
0c37387
move all commands
Felienne Dec 5, 2023
4fbedfb
move all exceptions into isvalid
Felienne Dec 6, 2023
4edbb3b
revert grammar changes
Felienne Dec 6, 2023
947d78a
update
Felienne Dec 6, 2023
8ce8e93
one more grammar change
Felienne Dec 6, 2023
cf1b87f
finish tests
Felienne Dec 6, 2023
b4648b2
Merge branch 'clean-up-invalid' of https://github.com/hedyorg/hedy in…
Felienne Dec 6, 2023
663bc23
Merge branch 'main' into clean-up-invalid
Felienne Dec 6, 2023
fe0355e
manual merge
Felienne Dec 6, 2023
9bb6c94
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
1fc39fc
remove unused code
Felienne Dec 6, 2023
a37f825
Merge branch 'clean-up-invalid' of https://github.com/hedyorg/hedy in…
Felienne Dec 6, 2023
61231fe
refactor
Felienne Dec 6, 2023
3c3936c
ok ok precommit...!
Felienne Dec 6, 2023
e6d3202
remove broken programs
Felienne Dec 6, 2023
9de6ce5
Merge branch 'main' into clean-up-invalid
mergify[bot] Dec 7, 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
20 changes: 11 additions & 9 deletions hedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,14 @@ def error_invalid_space(self, meta, args):
def error_print_nq(self, meta, args):
words = [str(x[1]) for x in args] # second half of the list is the word
text = ' '.join(words)
return False, InvalidInfo("print without quotes", arguments=[
text], line=meta.line, column=meta.column), meta

raise exceptions.UnquotedTextException(
level=4,
Felienne marked this conversation as resolved.
Show resolved Hide resolved
unquotedtext=text,
line_number=meta.line
)



def error_list_access(self, meta, args):
error = InvalidInfo('misspelled "at" command', arguments=[str(args[1][1])], line=meta.line)
Expand Down Expand Up @@ -3301,10 +3307,6 @@ def is_program_valid(program_root, input_string, level, lang):
raise exceptions.IncompleteRepeatException(command='print', level=level, line_number=line)
elif invalid_info.error_type == 'repeat missing times':
raise exceptions.IncompleteRepeatException(command='times', level=level, line_number=line)
elif invalid_info.error_type == 'print without quotes':
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':
raise exceptions.MisspelledAtCommand(command='at', arg1=invalid_info.arguments[0], line_number=line)
elif invalid_info.error_type == 'unsupported number':
Expand Down Expand Up @@ -3395,10 +3397,10 @@ def transpile_inner(input_string, level, lang="en", populate_source_map=False, i
source_map.set_language(lang)
source_map.set_hedy_input(input_string)

# checks whether any error production nodes are present in the parse tree
is_program_valid(program_root, input_string, level, lang)

try:
# checks whether any error production nodes are present in the parse tree
is_program_valid(program_root, input_string, level, lang)

abstract_syntax_tree = ExtractAST().transform(program_root)

is_program_complete(abstract_syntax_tree, level)
Expand Down
Loading