Skip to content

Commit

Permalink
Split method
Browse files Browse the repository at this point in the history
- Enable reusing parts of the method when multiple types per variable
 are allowed
  • Loading branch information
OliverStolzBO committed Apr 10, 2024
1 parent 61c72ef commit 5bd0be9
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions pfdl_scheduler/parser/pfdl_tree_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,28 @@ def visitVariable_definition(
variable_type = self.visitPrimitive(ctx.primitive())

if ctx.array():
array = Array()
array.type_of_elements = variable_type
array.context = ctx.array()
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

array = self.initializeArray(ctx.array(), variable_type)
variable_type = array

return (identifier, variable_type)

def visitPrimitive(self, ctx: PFDLParser.PrimitiveContext):
return ctx.getText()

def initializeArray(self, array_ctx: PFDLParser.ArrayContext, variable_type: str) -> Array:
array = Array()
array.type_of_elements = variable_type
array.context = array_ctx
length = self.visitArray(array_ctx)
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

return array

def visitAttribute_access(self, ctx: PFDLParser.Attribute_accessContext) -> List[str]:
access_list = []

Expand Down

0 comments on commit 5bd0be9

Please sign in to comment.