index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!doctype html>
  2. <title>CodeMirror: TTCN mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/matchbrackets.js"></script>
  8. <script src="ttcn.js"></script>
  9. <style type="text/css">
  10. .CodeMirror {
  11. border-top: 1px solid black;
  12. border-bottom: 1px solid black;
  13. }
  14. </style>
  15. <div id=nav>
  16. <a href="https://codemirror.net"><h1>CodeMirror</h1>
  17. <img id=logo src="../../doc/logo.png">
  18. </a>
  19. <ul>
  20. <li><a href="../../index.html">Home</a>
  21. <li><a href="../../doc/manual.html">Manual</a>
  22. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  23. </ul>
  24. <ul>
  25. <li><a href="../index.html">Language modes</a>
  26. <li><a class=active href="http://en.wikipedia.org/wiki/TTCN">TTCN</a>
  27. </ul>
  28. </div>
  29. <article>
  30. <h2>TTCN example</h2>
  31. <div>
  32. <textarea id="ttcn-code">
  33. module Templates {
  34. /* import types from ASN.1 */
  35. import from Types language "ASN.1:1997" all;
  36. /* During the conversion phase from ASN.1 to TTCN-3 */
  37. /* - the minus sign (Message-Type) within the identifiers will be replaced by underscore (Message_Type)*/
  38. /* - the ASN.1 identifiers matching a TTCN-3 keyword (objid) will be postfixed with an underscore (objid_)*/
  39. // simple types
  40. template SenderID localObjid := objid {itu_t(0) identified_organization(4) etsi(0)};
  41. // complex types
  42. /* ASN.1 Message-Type mapped to TTCN-3 Message_Type */
  43. template Message receiveMsg(template (present) Message_Type p_messageType) := {
  44. header := p_messageType,
  45. body := ?
  46. }
  47. /* ASN.1 objid mapped to TTCN-3 objid_ */
  48. template Message sendInviteMsg := {
  49. header := inviteType,
  50. body := {
  51. /* optional fields may be assigned by omit or may be ignored/skipped */
  52. description := "Invite Message",
  53. data := 'FF'O,
  54. objid_ := localObjid
  55. }
  56. }
  57. template Message sendAcceptMsg modifies sendInviteMsg := {
  58. header := acceptType,
  59. body := {
  60. description := "Accept Message"
  61. }
  62. };
  63. template Message sendErrorMsg modifies sendInviteMsg := {
  64. header := errorType,
  65. body := {
  66. description := "Error Message"
  67. }
  68. };
  69. template Message expectedErrorMsg := {
  70. header := errorType,
  71. body := ?
  72. };
  73. template Message expectedInviteMsg modifies expectedErrorMsg := {
  74. header := inviteType
  75. };
  76. template Message expectedAcceptMsg modifies expectedErrorMsg := {
  77. header := acceptType
  78. };
  79. } with { encode "BER:1997" }
  80. </textarea>
  81. </div>
  82. <script>
  83. var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-code"), {
  84. lineNumbers: true,
  85. matchBrackets: true,
  86. mode: "text/x-ttcn"
  87. });
  88. ttcnEditor.setSize(600, 860);
  89. var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
  90. CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
  91. </script>
  92. <br/>
  93. <p><strong>Language:</strong> Testing and Test Control Notation
  94. (<a href="http://en.wikipedia.org/wiki/TTCN">TTCN</a>)
  95. </p>
  96. <p><strong>MIME types defined:</strong> <code>text/x-ttcn,
  97. text/x-ttcn3, text/x-ttcnpp</code>.</p>
  98. <br/>
  99. <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson
  100. </a>.</p>
  101. <p>Coded by Asmelash Tsegay Gebretsadkan </p>
  102. </article>