@@ -48,7 +48,7 @@ pub enum GlobalStatement {
4848 DefType ( DefType ) ,
4949
5050 /// A function declaration, e.g. `DECLARE FUNCTION Add(A, B)`
51- FunctionDeclaration ( NamePos , Parameters ) ,
51+ FunctionDeclaration ( FunctionDeclaration ) ,
5252
5353 /// A function implementation
5454 FunctionImplementation ( FunctionImplementation ) ,
@@ -57,7 +57,7 @@ pub enum GlobalStatement {
5757 Statement ( Statement ) ,
5858
5959 /// A sub declaration, e.g. `DECLARE SUB Connect`
60- SubDeclaration ( BareNamePos , Parameters ) ,
60+ SubDeclaration ( SubDeclaration ) ,
6161
6262 /// A sub implementation
6363 SubImplementation ( SubImplementation ) ,
@@ -66,12 +66,38 @@ pub enum GlobalStatement {
6666 UserDefinedType ( UserDefinedType ) ,
6767}
6868
69+ impl GlobalStatement {
70+ pub fn function_declaration ( name : NamePos , parameters : Parameters ) -> Self {
71+ Self :: FunctionDeclaration ( FunctionDeclaration :: new ( name, parameters) )
72+ }
73+
74+ pub fn sub_declaration ( name : BareNamePos , parameters : Parameters ) -> Self {
75+ Self :: SubDeclaration ( SubDeclaration :: new ( name, parameters) )
76+ }
77+ }
78+
6979impl From < Statement > for GlobalStatement {
7080 fn from ( s : Statement ) -> Self {
7181 Self :: Statement ( s)
7282 }
7383}
7484
85+ #[ derive( Clone , Debug , PartialEq ) ]
86+ pub struct SubprogramDeclaration < T > {
87+ pub name : Positioned < T > ,
88+ pub parameters : Parameters ,
89+ }
90+
91+ impl < T > SubprogramDeclaration < T > {
92+ pub fn new ( name : Positioned < T > , parameters : Parameters ) -> Self {
93+ Self { name, parameters }
94+ }
95+ }
96+
97+ pub type SubDeclaration = SubprogramDeclaration < BareName > ;
98+
99+ pub type FunctionDeclaration = SubprogramDeclaration < Name > ;
100+
75101/// The implementation of a subprogram (FUNCTION or SUB).
76102#[ derive( Clone , Debug , PartialEq ) ]
77103pub struct SubprogramImplementation < T > {
@@ -80,7 +106,7 @@ pub struct SubprogramImplementation<T> {
80106 pub name : Positioned < T > ,
81107
82108 /// The parameters of the subprogram.
83- pub params : Vec < Positioned < Parameter > > ,
109+ pub params : Parameters ,
84110
85111 /// The body (statements) of the subprogram.
86112 pub body : Statements ,
0 commit comments