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

Add unittests for visitor #6

Merged
merged 6 commits into from
Feb 7, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Do not set length of array if it is invalid
Due to the grammar description it is possible that the visitor returns
a string as array length.
An error is already printed, but the length was still set
  • Loading branch information
maxhoerstr committed Jan 19, 2023
commit f10fb2b02168c5902e75a794c63b549c4df7f1a2
7 changes: 5 additions & 2 deletions pfdl_scheduler/parser/pfdl_tree_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,14 @@ def visitVariable_definition(
array = Array()
array.type_of_elements = variable_type
array.context = ctx.array()
array.length = self.visitArray(ctx.array())
if not isinstance(array.length, int):
length = self.visitArray(ctx.array())
if not isinstance(length, int):
self.error_handler.print_error(
"Array length has to be specified by an integer", syntax_error=True
)
else:
array.length = length

variable_type = array

return (identifier, variable_type)
Expand Down