@@ -1924,7 +1924,7 @@ def __str__(self) -> str:
19241924 body = "\n " .join (
19251925 (
19261926 "STRUCT" ,
1927- indent ("\n " .join (str ( decl ) for decl in self .declarations )),
1927+ indent ("\n " .join (f" { decl } ;" for decl in self .declarations )),
19281928 "END_STRUCT" ,
19291929 )
19301930 )
@@ -1940,24 +1940,25 @@ def __str__(self) -> str:
19401940@_rule_handler ("structure_element_declaration" , comments = True )
19411941class StructureElementDeclaration :
19421942 """
1943- Declaration of a single element of a structure.
1943+ Declaration line of a structure, typically with a single variable name.
1944+
1945+ Excludes the trailing semicolon.
19441946
19451947 Examples::
19461948
1947- iValue : INT := 3 + 4;
1948- stTest : ST_Testing := (1, 2);
1949- eValue : E_Test := E_Test.ABC;
1950- arrValue : ARRAY [1..2] OF INT := [1, 2];
1951- arrValue1 : INT (1..2);
1952- arrValue1 : (Value1 := 1) INT;
1953- sValue : STRING := 'abc';
1954- iValue1 AT %I* : INT := 5;
1955- sValue1 : STRING[10] := 'test';
1949+ iValue : INT := 3 + 4
1950+ stTest : ST_Testing := (1, 2)
1951+ eValue : E_Test := E_Test.ABC
1952+ arrValue : ARRAY [1..2] OF INT := [1, 2]
1953+ arrValue1 : INT (1..2)
1954+ arrValue1 : (Value1 := 1) INT
1955+ sValue : STRING := 'abc'
1956+ iValue1 AT %I* : INT := 5
1957+ sValue1 : STRING[10] := 'test'
1958+ Timer1, Timer2, Timer3 : library.TPUDO
19561959 """
1957- name : lark .Token
1958- location : Optional [IncompleteLocation ]
1960+ variables : List [DeclaredVariable ]
19591961 init : Union [
1960- StructureInitialization ,
19611962 ArrayTypeInitialization ,
19621963 StringTypeInitialization ,
19631964 TypeInitialization ,
@@ -1968,35 +1969,24 @@ class StructureElementDeclaration:
19681969 ]
19691970 meta : Optional [Meta ] = meta_field ()
19701971
1971- @property
1972- def variables (self ) -> List [str ]:
1973- """API compat: list of variable names."""
1974- return [self .name ]
1975-
19761972 @property
19771973 def value (self ) -> str :
19781974 """The initialization value, if applicable."""
1979- if isinstance (self .init , StructureInitialization ):
1980- return str (self .init )
19811975 return str (self .init .value )
19821976
19831977 @property
19841978 def base_type_name (self ) -> Union [lark .Token , str ]:
19851979 """The base type name."""
1986- if isinstance (self .init , StructureInitialization ):
1987- return self .name
19881980 return self .init .base_type_name
19891981
19901982 @property
1991- def full_type_name (self ) -> lark .Token :
1983+ def full_type_name (self ) -> Union [ lark .Token , str ] :
19921984 """The full type name."""
1993- if isinstance (self .init , StructureInitialization ):
1994- return self .name
19951985 return self .init .full_type_name
19961986
19971987 def __str__ (self ) -> str :
1998- name_and_location = join_if ( self . name , " " , self .location )
1999- return f"{ name_and_location } : { self .init } ; "
1988+ variables = " , ". join ( str ( var ) for var in self .variables )
1989+ return f"{ variables } : { self .init } "
20001990
20011991
20021992UnionElementSpecification = Union [
@@ -4585,6 +4575,10 @@ def full_subrange(self):
45854575 def var1_list (self , * items : DeclaredVariable ) -> List [DeclaredVariable ]:
45864576 return list (items )
45874577
4578+ @_annotator_method_wrapper
4579+ def struct_var1_list (self , * items : DeclaredVariable ) -> List [DeclaredVariable ]:
4580+ return list (items )
4581+
45884582 @_annotator_method_wrapper
45894583 def fb_decl_name_list (self , * items : lark .Token ) -> List [lark .Token ]:
45904584 return list (items )
0 commit comments