@@ -312,10 +312,9 @@ def from_init(
312312 )
313313 spec_type = cls .from_spec (init .spec )
314314 if isinstance (init , TypeInitialization ):
315- full_type_name = join_if (init .indirection , " " , spec_type .full_type_name )
316315 return cls (
317316 base_type_name = spec_type .base_type_name ,
318- full_type_name = full_type_name ,
317+ full_type_name = spec_type . full_type_name ,
319318 context = init ,
320319 )
321320 return spec_type
@@ -1174,8 +1173,7 @@ class TypeInitialization(TypeInitializationBase):
11741173 TypeName := Value1
11751174 STRING[100] := "value"
11761175 """
1177- indirection : Optional [IndirectionType ]
1178- spec : SimpleSpecification
1176+ spec : Union [SimpleSpecification , IndirectSimpleSpecification ]
11791177 value : Optional [Expression ]
11801178 meta : Optional [Meta ] = meta_field ()
11811179
@@ -1581,13 +1579,47 @@ class IndirectSimpleSpecification(TypeSpecificationBase):
15811579 POINTER TO TypeName
15821580 REFERENCE TO TypeName
15831581 REFERENCE TO POINTER TO TypeName
1582+
1583+ Initialization parameters such as these are parsed but otherwise ignored
1584+ by TwinCAT::
1585+
1586+ POINTER TO TypeName(1, 2)
1587+ POINTER TO TypeName(1, 2, C := 4)
15841588 """
15851589 indirection : Optional [IndirectionType ]
15861590 type : SimpleSpecification
1591+ init_parameters : Optional [List [InputParameterAssignment ]]
15871592 meta : Optional [Meta ] = meta_field ()
15881593
1594+ @staticmethod
1595+ def from_lark (
1596+ indirection : Optional [IndirectionType ],
1597+ type_ : SimpleSpecification ,
1598+ init_parameters_tree : Optional [lark .Tree ],
1599+ ) -> IndirectSimpleSpecification :
1600+ if init_parameters_tree is None :
1601+ init_parameters = None
1602+ else :
1603+ init_parameters = typing .cast (
1604+ List [InputParameterAssignment ],
1605+ list (init_parameters_tree .children )
1606+ )
1607+ return IndirectSimpleSpecification (
1608+ indirection ,
1609+ type_ ,
1610+ init_parameters ,
1611+ )
1612+
15891613 def __str__ (self ) -> str :
1590- return join_if (self .indirection , " " , self .type )
1614+ full_type = join_if (self .indirection , " " , self .type )
1615+ if not self .init_parameters :
1616+ return full_type
1617+
1618+ initializers = ", " .join (
1619+ str (init )
1620+ for init in self .init_parameters
1621+ )
1622+ return f"{ full_type } ({ initializers } )"
15911623
15921624
15931625# _array_spec_type
@@ -2673,7 +2705,7 @@ class ParameterAssignment:
26732705
26742706
26752707@dataclass
2676- @_rule_handler ("param_assignment" )
2708+ @_rule_handler ("param_assignment" , "input_param_assignment" )
26772709class InputParameterAssignment (ParameterAssignment ):
26782710 """
26792711 An input parameter in a function call.
0 commit comments