Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions ttcn3/syntax/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
36 changes: 33 additions & 3 deletions ttcn3/syntax/nodes_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ttcn3/syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
Expand Down
4 changes: 4 additions & 0 deletions ttcn3/syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;`},
Expand Down Expand Up @@ -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)}`},
Expand All @@ -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
Expand Down
Loading