-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ttcn: add "template" ["(omit)" | "(value)" | "(present)"]
Modern TTCN3 has TemplateRestriction keywords, which improve detection of invalid template use at compile time. They simply add one of "(omit)", "(value)", "(present)" after the "template" keyword. Example: template (value) ts_FOO_Request(integer bar := 0) := { member := bar }; template (present) tr_FOO_Request(template integer bar := *) := { member := bar }; Before this patch, u-ctags would not tag these two definitons above, making my work on the Osmocom test suite hard. (See https://gitea.osmocom.org/ttcn3/osmo-ttcn3-hacks) At first I tried to exactly match the three keywords within the braces, but the token parsing does not support unrolling more than one token. So if an unmatching token follows after the opening brace, I cannot un-get the opening brace. The easiest solution, and one that also is tolerant to keyword typos, is to just accept any braces after "template". Related: ETSI ES 201 873-1 V4.14.1 § A.1.6.1.3
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
5 changes: 5 additions & 0 deletions
5
Units/parser-ttcn.r/ttcn-template-restriction.d/expected.tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CoffeeTemplates input.ttcn /^module CoffeeTemplates$/;" M | ||
AnyCoffee input.ttcn /^template (present) Coffee AnyCoffee$/;" d | ||
SomeCoffee input.ttcn /^template (value) Coffee SomeCoffee(integer id, charstring description := "")$/;" d | ||
Espresso input.ttcn /^template (omit) Coffee Espresso()$/;" d | ||
Latte input.ttcn /^template (TYPO IN RESTRICTION) Coffee Latte()$/;" d |
32 changes: 32 additions & 0 deletions
32
Units/parser-ttcn.r/ttcn-template-restriction.d/input.ttcn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import from CoffeeTypes all | ||
import from CoffeeConstants all | ||
|
||
module CoffeeTemplates | ||
{ | ||
|
||
template (present) Coffee AnyCoffee | ||
{ | ||
id := ?, | ||
description := ? | ||
} | ||
|
||
template (value) Coffee SomeCoffee(integer id, charstring description := "") | ||
{ | ||
id := id, | ||
description := description | ||
} | ||
|
||
template (omit) Coffee Espresso() | ||
{ | ||
id := c_espressoId, | ||
description := c_espresso | ||
} | ||
|
||
template (TYPO IN RESTRICTION) Coffee Latte() | ||
{ | ||
id := c_latteId, | ||
description := c_latte | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters