diff --git a/ttcn3/syntax/nodes.go b/ttcn3/syntax/nodes.go index 6c46188d..c66aaf49 100644 --- a/ttcn3/syntax/nodes.go +++ b/ttcn3/syntax/nodes.go @@ -576,11 +576,12 @@ type ( // A BehaviourSpec represents a behaviour type specification. BehaviourSpec struct { - KindTok Token // TESTCASE, FUNCTION, ALTSTEP - Params *FormalPars // Parameter list or nil - RunsOn *RunsOnSpec // runs on spec or nil - System *SystemSpec // system spec or nil - Return *ReturnSpec // return value spec or nil + KindTok Token // TESTCASE, FUNCTION, ALTSTEP + Interleave Token // INTERLEAVE or nil + Params *FormalPars // Parameter list or nil + RunsOn *RunsOnSpec // runs on spec or nil + System *SystemSpec // system spec or nil + Return *ReturnSpec // return value spec or nil } ) @@ -636,18 +637,19 @@ type ( // A FuncDecl represents a behaviour definition. FuncDecl struct { - External Token // Position of "external" or nil - KindTok Token // TESTCASE, ALTSTEP, FUNCTION - Name *Ident - Modif Token // Position of "@deterministic" or nil - TypePars *FormalPars - Params *FormalPars // Formal parameter list or nil - RunsOn *RunsOnSpec // Optional runs-on-spec - Mtc *MtcSpec // Optional mtc-spec - System *SystemSpec // Optional system-spec - Return *ReturnSpec // Optional return-spec - Body *BlockStmt // Body or nil - With *WithSpec + External Token // Position of "external" or nil + KindTok Token // TESTCASE, ALTSTEP, FUNCTION + Interleave Token // INTERLEAVE or nil + Name *Ident + Modif Token // Position of "@deterministic" or nil + TypePars *FormalPars + Params *FormalPars // Formal parameter list or nil + RunsOn *RunsOnSpec // Optional runs-on-spec + Mtc *MtcSpec // Optional mtc-spec + System *SystemSpec // Optional system-spec + Return *ReturnSpec // Optional return-spec + Body *BlockStmt // Body or nil + With *WithSpec } // A ConstructorDecl represents a class constructor definition. @@ -728,15 +730,16 @@ type ( // A BehaviourTypeDecl represents a named behaviour type. BehaviourTypeDecl struct { - TypeTok Token // Position of "type" - KindTok Token // TESTCASE, ALTSTEP, FUNCTION - Name *Ident - TypePars *FormalPars - Params *FormalPars // Formal parameter list - RunsOn *RunsOnSpec // Optional runs-on spec - System *SystemSpec // Optional system spec - Return *ReturnSpec // Optional return spec - With *WithSpec + TypeTok Token // Position of "type" + KindTok Token // TESTCASE, ALTSTEP, FUNCTION + Interleave Token // INTERLEAVE or nil + Name *Ident + TypePars *FormalPars + Params *FormalPars // Formal parameter list + RunsOn *RunsOnSpec // Optional runs-on spec + System *SystemSpec // Optional system spec + Return *ReturnSpec // Optional return spec + With *WithSpec } PortTypeDecl struct { diff --git a/ttcn3/syntax/nodes_gen.go b/ttcn3/syntax/nodes_gen.go index 077b73fd..e01182af 100644 --- a/ttcn3/syntax/nodes_gen.go +++ b/ttcn3/syntax/nodes_gen.go @@ -93,6 +93,9 @@ func (n *BehaviourSpec) FirstTok() Token { case n.KindTok != nil: return n.KindTok + case n.Interleave != nil: + return n.Interleave + case n.Params != nil: return n.Params.FirstTok() @@ -125,6 +128,9 @@ func (n *BehaviourSpec) LastTok() Token { case n.Params != nil: return n.Params.LastTok() + case n.Interleave != nil: + return n.Interleave + case n.KindTok != nil: return n.KindTok @@ -134,12 +140,16 @@ func (n *BehaviourSpec) LastTok() Token { } func (n *BehaviourSpec) Children() []Node { - ret := make([]Node, 0, 5) + ret := make([]Node, 0, 6) if n.KindTok != nil { ret = append(ret, n.KindTok) } + if n.Interleave != nil { + ret = append(ret, n.Interleave) + } + if n.Params != nil { ret = append(ret, n.Params) } @@ -218,6 +228,9 @@ func (n *BehaviourTypeDecl) FirstTok() Token { case n.KindTok != nil: return n.KindTok + case n.Interleave != nil: + return n.Interleave + case n.Name != nil: return n.Name.FirstTok() @@ -268,6 +281,9 @@ func (n *BehaviourTypeDecl) LastTok() Token { case n.Name != nil: return n.Name.LastTok() + case n.Interleave != nil: + return n.Interleave + case n.KindTok != nil: return n.KindTok @@ -280,7 +296,7 @@ func (n *BehaviourTypeDecl) LastTok() Token { } func (n *BehaviourTypeDecl) Children() []Node { - ret := make([]Node, 0, 9) + ret := make([]Node, 0, 10) if n.TypeTok != nil { ret = append(ret, n.TypeTok) @@ -290,6 +306,10 @@ func (n *BehaviourTypeDecl) Children() []Node { ret = append(ret, n.KindTok) } + if n.Interleave != nil { + ret = append(ret, n.Interleave) + } + if n.Name != nil { ret = append(ret, n.Name) } @@ -3545,6 +3565,9 @@ func (n *FuncDecl) FirstTok() Token { case n.KindTok != nil: return n.KindTok + case n.Interleave != nil: + return n.Interleave + case n.Name != nil: return n.Name.FirstTok() @@ -3613,6 +3636,9 @@ func (n *FuncDecl) LastTok() Token { case n.Name != nil: return n.Name.LastTok() + case n.Interleave != nil: + return n.Interleave + case n.KindTok != nil: return n.KindTok @@ -3625,7 +3651,7 @@ func (n *FuncDecl) LastTok() Token { } func (n *FuncDecl) Children() []Node { - ret := make([]Node, 0, 12) + ret := make([]Node, 0, 13) if n.External != nil { ret = append(ret, n.External) @@ -3635,6 +3661,10 @@ func (n *FuncDecl) Children() []Node { ret = append(ret, n.KindTok) } + if n.Interleave != nil { + ret = append(ret, n.Interleave) + } + if n.Name != nil { ret = append(ret, n.Name) } diff --git a/ttcn3/syntax/parser.go b/ttcn3/syntax/parser.go index 73e02289..a1b68538 100644 --- a/ttcn3/syntax/parser.go +++ b/ttcn3/syntax/parser.go @@ -1833,6 +1833,11 @@ func (p *parser) parseBehaviourTypeDecl() *BehaviourTypeDecl { x := new(BehaviourTypeDecl) x.TypeTok = p.consume() x.KindTok = p.consume() + + if p.tok == INTERLEAVE { + x.Interleave = p.consume() + } + x.Name = p.parseName() if p.tok == LT { x.TypePars = p.parseTypeFormalPars() @@ -2001,6 +2006,11 @@ func (p *parser) parseBehaviourSpec() *BehaviourSpec { x := new(BehaviourSpec) x.KindTok = p.consume() + + if p.tok == INTERLEAVE { + x.Interleave = p.consume() + } + x.Params = p.parseFormalPars() if p.tok == RUNS { @@ -2177,6 +2187,10 @@ func (p *parser) parseFuncDecl() *FuncDecl { x := new(FuncDecl) x.KindTok = p.consume() + + if p.tok == INTERLEAVE { + x.Interleave = p.consume() + } if p.tok == MODIF { x.Modif = p.consume() } diff --git a/ttcn3/syntax/parser_test.go b/ttcn3/syntax/parser_test.go index 320652b9..238b74a7 100644 --- a/ttcn3/syntax/parser_test.go +++ b/ttcn3/syntax/parser_test.go @@ -105,6 +105,7 @@ func TestFuncDecls(t *testing.T) { {pass, `function f() mtc C {}`}, {pass, `function f() runs on C mtc C system C {}`}, {pass, `altstep as() { var roi[-] a[4][4]; [] receive; [else] {}}`}, + {pass, `altstep interleave interleaveStep() { [] p1.receive; [] p2.check{}}`}, {pass, `signature f();`}, {pass, `signature f() exception (integer);`}, {pass, `signature f() return int;`}, @@ -235,6 +236,8 @@ func TestTypes(t *testing.T) { {pass, `type set s {int a optional }`}, {pass, `type set s {set length(1) of set length(2) of int() f1[-][-] length(3) optional}`}, {pass, `type set s {function () runs on self return template int callback}`}, + {pass, `type set s {altstep (integer p_i) runs on self as_callback}`}, + {pass, `type set s {altstep interleave(integer p_i) runs on C is_callback}`}, {pass, `type union s {@default set of int f1 optional}`}, {pass, `type union s {enumerated { e(1) } foo}`}, {pass, `type enumerated a {e, e(1), e(1)}`}, @@ -260,6 +263,7 @@ func TestTypes(t *testing.T) { // Behaviour Types {pass, `type function fn() runs on self return template int`}, {pass, `type altstep as() runs on self return int`}, + {pass, `type altstep interleave iStep() runs on C`}, {pass, `type testcase tc() runs on C system TSI`}, // Class Types