st.test.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. 'use strict';
  6. import { testTokenization } from '../test/testRunner';
  7. testTokenization('st', [
  8. [{
  9. line: "xVar : BOOL;",
  10. tokens: [
  11. { startIndex: 0, type: 'identifier.st' },
  12. { startIndex: 4, type: 'white.st' },
  13. { startIndex: 5, type: '' },
  14. { startIndex: 6, type: 'white.st' },
  15. { startIndex: 7, type: 'type.st' },
  16. { startIndex: 11, type: 'delimiter.st' },
  17. ]
  18. }],
  19. [{
  20. line: "xStart AT %IX0.0.1: BOOL := TRUE;",
  21. tokens: [
  22. { startIndex: 0, type: 'identifier.st' },
  23. { startIndex: 6, type: 'white.st' },
  24. { startIndex: 7, type: 'keyword.st' },
  25. { startIndex: 9, type: 'white.st' },
  26. { startIndex: 10, type: 'tag.st' },
  27. { startIndex: 18, type: '' },
  28. { startIndex: 19, type: 'white.st' },
  29. { startIndex: 20, type: 'type.st' },
  30. { startIndex: 24, type: 'white.st' },
  31. { startIndex: 25, type: '' },
  32. { startIndex: 27, type: 'white.st' },
  33. { startIndex: 28, type: 'constant.st' },
  34. { startIndex: 32, type: 'delimiter.st' },
  35. ]
  36. }],
  37. [{
  38. line: "IF a > 2#0000_0110 THEN (* Something ' happens *)",
  39. tokens: [
  40. { startIndex: 0, type: 'keyword.st' },
  41. { startIndex: 2, type: 'white.st' },
  42. { startIndex: 3, type: 'identifier.st' },
  43. { startIndex: 4, type: 'white.st' },
  44. { startIndex: 5, type: '' },
  45. { startIndex: 6, type: 'white.st' },
  46. { startIndex: 7, type: 'number.binary.st' },
  47. { startIndex: 18, type: 'white.st' },
  48. { startIndex: 19, type: 'keyword.st' },
  49. { startIndex: 23, type: 'white.st' },
  50. { startIndex: 24, type: 'comment.st' },
  51. ]
  52. }],
  53. [{
  54. line: "TON1(IN := TRUE, PT := T#20ms, Q => xStart); // Run timer",
  55. tokens: [
  56. { startIndex: 0, type: 'identifier.st' },
  57. { startIndex: 4, type: 'delimiter.parenthesis.st' },
  58. { startIndex: 5, type: 'identifier.st' },
  59. { startIndex: 7, type: 'white.st' },
  60. { startIndex: 8, type: '' },
  61. { startIndex: 10, type: 'white.st' },
  62. { startIndex: 11, type: 'constant.st' },
  63. { startIndex: 15, type: '' },
  64. { startIndex: 16, type: 'white.st' },
  65. { startIndex: 17, type: 'identifier.st' },
  66. { startIndex: 19, type: 'white.st' },
  67. { startIndex: 20, type: '' },
  68. { startIndex: 22, type: 'white.st' },
  69. { startIndex: 23, type: 'tag.st' },
  70. { startIndex: 29, type: '' },
  71. { startIndex: 30, type: 'white.st' },
  72. { startIndex: 31, type: 'identifier.st' },
  73. { startIndex: 32, type: 'white.st' },
  74. { startIndex: 33, type: '' },
  75. { startIndex: 35, type: 'white.st' },
  76. { startIndex: 36, type: 'identifier.st' },
  77. { startIndex: 42, type: 'delimiter.parenthesis.st' },
  78. { startIndex: 43, type: 'delimiter.st' },
  79. { startIndex: 44, type: 'white.st' },
  80. { startIndex: 45, type: 'comment.st' },
  81. ]
  82. }],
  83. // Numbers
  84. [{
  85. line: '0',
  86. tokens: [
  87. { startIndex: 0, type: 'number.st' }
  88. ]
  89. }],
  90. [{
  91. line: '0.0',
  92. tokens: [
  93. { startIndex: 0, type: 'number.float.st' }
  94. ]
  95. }],
  96. [{
  97. line: '2#000_0101',
  98. tokens: [
  99. { startIndex: 0, type: 'number.binary.st' }
  100. ]
  101. }],
  102. [{
  103. line: '16#0f',
  104. tokens: [
  105. { startIndex: 0, type: 'number.hex.st' }
  106. ]
  107. }],
  108. [{
  109. line: '23.5',
  110. tokens: [
  111. { startIndex: 0, type: 'number.float.st' }
  112. ]
  113. }],
  114. [{
  115. line: '23.5e3',
  116. tokens: [
  117. { startIndex: 0, type: 'number.float.st' }
  118. ]
  119. }],
  120. [{
  121. line: '23.5E3',
  122. tokens: [
  123. { startIndex: 0, type: 'number.float.st' }
  124. ]
  125. }],
  126. ]);