@mpeggroup/mpeg-sdl-parser 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +337 -0
  3. package/bun.lock +65 -0
  4. package/dist/index.js +11829 -0
  5. package/grammar/sdl.ebnf.grammar +399 -0
  6. package/grammar/sdl.lezer.grammar +629 -0
  7. package/index.ts +83 -0
  8. package/package.json +61 -0
  9. package/src/analyser/checks/check-array-definition.ts +90 -0
  10. package/src/analyser/checks/check-array-element-access.ts +31 -0
  11. package/src/analyser/checks/check-class-declaration.ts +417 -0
  12. package/src/analyser/checks/check-computed-array-definition.ts +44 -0
  13. package/src/analyser/checks/check-computed-elementary-type-definition.ts +45 -0
  14. package/src/analyser/checks/check-elementary-type-definition.ts +167 -0
  15. package/src/analyser/checks/check-expression-binary.ts +242 -0
  16. package/src/analyser/checks/check-expression-lengthof.ts +34 -0
  17. package/src/analyser/checks/check-expression-unary.ts +166 -0
  18. package/src/analyser/checks/check-identifier.ts +71 -0
  19. package/src/analyser/checks/check-if-statement.ts +164 -0
  20. package/src/analyser/checks/check-map-declaration.ts +180 -0
  21. package/src/analyser/checks/check-map-definition.ts +118 -0
  22. package/src/analyser/checks/check-number-literal-float.ts +28 -0
  23. package/src/analyser/checks/check-parameter-list.ts +42 -0
  24. package/src/analyser/checks/check-specification.ts +53 -0
  25. package/src/analyser/checks/check-switch-statement.ts +206 -0
  26. package/src/analyser/checks/check.ts +20 -0
  27. package/src/analyser/create-sdl-analyser.ts +85 -0
  28. package/src/analyser/node-handler/abstract-analysis-node-handler.ts +626 -0
  29. package/src/analyser/node-handler/build-symbol-table-node-handler.ts +649 -0
  30. package/src/analyser/node-handler/specific-check-node-handler.ts +46 -0
  31. package/src/analyser/node-handler/validate-scope-node-handler.ts +290 -0
  32. package/src/analyser/node-handler/validate-type-node-handler.ts +497 -0
  33. package/src/analyser/sdl-analyser.ts +119 -0
  34. package/src/analyser/symbol-table.ts +388 -0
  35. package/src/analyser/util/symbol-table-utils.ts +458 -0
  36. package/src/analyser/util/type-utils.ts +238 -0
  37. package/src/ast/build/consume/consume-abstract-node.ts +199 -0
  38. package/src/ast/build/consume/consume-ast-node.ts +400 -0
  39. package/src/ast/build/consume/consume-primitive.ts +59 -0
  40. package/src/ast/build/consume/consume-trivia.ts +96 -0
  41. package/src/ast/build/consume/consume-white-space-and-missing-errors.ts +27 -0
  42. package/src/ast/build/node/build-aggregate-output-value.ts +57 -0
  43. package/src/ast/build/node/build-aligned-modifier.ts +99 -0
  44. package/src/ast/build/node/build-array-definition.ts +131 -0
  45. package/src/ast/build/node/build-array-element-access.ts +45 -0
  46. package/src/ast/build/node/build-base64-string-literal.ts +41 -0
  47. package/src/ast/build/node/build-binary-expression.ts +113 -0
  48. package/src/ast/build/node/build-binary-literal.ts +37 -0
  49. package/src/ast/build/node/build-bit-modifier.ts +86 -0
  50. package/src/ast/build/node/build-case-clause.ts +101 -0
  51. package/src/ast/build/node/build-class-declaration.ts +124 -0
  52. package/src/ast/build/node/build-class-definition.ts +56 -0
  53. package/src/ast/build/node/build-class-id-range.ts +32 -0
  54. package/src/ast/build/node/build-class-id.ts +19 -0
  55. package/src/ast/build/node/build-class-member-access.ts +27 -0
  56. package/src/ast/build/node/build-compound-statement.ts +33 -0
  57. package/src/ast/build/node/build-computed-array-definition.ts +53 -0
  58. package/src/ast/build/node/build-computed-elementary-type-definition.ts +100 -0
  59. package/src/ast/build/node/build-decimal-literal.ts +15 -0
  60. package/src/ast/build/node/build-default-clause.ts +76 -0
  61. package/src/ast/build/node/build-do-statement.ts +71 -0
  62. package/src/ast/build/node/build-elementary-type-definition.ts +164 -0
  63. package/src/ast/build/node/build-elementary-type-output-value.ts +25 -0
  64. package/src/ast/build/node/build-elementary-type.ts +36 -0
  65. package/src/ast/build/node/build-expandable-modifier.ts +68 -0
  66. package/src/ast/build/node/build-explicit-array-dimension.ts +37 -0
  67. package/src/ast/build/node/build-expression-statement.ts +31 -0
  68. package/src/ast/build/node/build-extended-class-id-range.ts +27 -0
  69. package/src/ast/build/node/build-extends-modifier.ts +41 -0
  70. package/src/ast/build/node/build-floating-point-literal.ts +15 -0
  71. package/src/ast/build/node/build-for-statement.ts +117 -0
  72. package/src/ast/build/node/build-hexadecimal-literal.ts +38 -0
  73. package/src/ast/build/node/build-identifier.ts +8 -0
  74. package/src/ast/build/node/build-if-statement.ts +82 -0
  75. package/src/ast/build/node/build-implicit-array-dimension.ts +78 -0
  76. package/src/ast/build/node/build-integer-literal.ts +15 -0
  77. package/src/ast/build/node/build-length-attribute.ts +48 -0
  78. package/src/ast/build/node/build-lengthof-expression.ts +45 -0
  79. package/src/ast/build/node/build-map-declaration.ts +110 -0
  80. package/src/ast/build/node/build-map-definition.ts +103 -0
  81. package/src/ast/build/node/build-map-entry.ts +33 -0
  82. package/src/ast/build/node/build-missing-error.ts +10 -0
  83. package/src/ast/build/node/build-multiple-character-literal.ts +65 -0
  84. package/src/ast/build/node/build-parameter-list.ts +50 -0
  85. package/src/ast/build/node/build-parameter-value-list.ts +54 -0
  86. package/src/ast/build/node/build-parameter.ts +47 -0
  87. package/src/ast/build/node/build-partial-array-dimension.ts +55 -0
  88. package/src/ast/build/node/build-specification.ts +24 -0
  89. package/src/ast/build/node/build-string-definition.ts +106 -0
  90. package/src/ast/build/node/build-switch-statement.ts +84 -0
  91. package/src/ast/build/node/build-token.ts +26 -0
  92. package/src/ast/build/node/build-unary-expression.ts +109 -0
  93. package/src/ast/build/node/build-unexpected-error.ts +14 -0
  94. package/src/ast/build/node/build-utf-string-literal.ts +110 -0
  95. package/src/ast/build/node/build-while-statement.ts +55 -0
  96. package/src/ast/build/util/array-dimension-kind-by-token-type-id-map.ts +167 -0
  97. package/src/ast/build/util/binary-operator-kind-by-token-type-id-map.ts +152 -0
  98. package/src/ast/build/util/build-context.ts +36 -0
  99. package/src/ast/build/util/class-id-kind-by-token-type-id-map.ts +160 -0
  100. package/src/ast/build/util/expression-kind-by-token-type-id-map.ts +168 -0
  101. package/src/ast/build/util/fetch-node.ts +433 -0
  102. package/src/ast/build/util/node-kind-by-token-type-id-map.ts +202 -0
  103. package/src/ast/build/util/statement-kind-by-token-type-id-map.ts +210 -0
  104. package/src/ast/build/util/string-literal-kind-by-token-type-id-map.ts +162 -0
  105. package/src/ast/build/util/token-kind-by-token-type-id-map.ts +337 -0
  106. package/src/ast/build-ast.ts +114 -0
  107. package/src/ast/node/abstract-array-definition.ts +17 -0
  108. package/src/ast/node/abstract-array-dimension.ts +20 -0
  109. package/src/ast/node/abstract-class-id.ts +13 -0
  110. package/src/ast/node/abstract-composite-node.ts +58 -0
  111. package/src/ast/node/abstract-elementary-type-definition.ts +29 -0
  112. package/src/ast/node/abstract-expression.ts +13 -0
  113. package/src/ast/node/abstract-leaf-node.ts +10 -0
  114. package/src/ast/node/abstract-node.ts +16 -0
  115. package/src/ast/node/abstract-statement.ts +13 -0
  116. package/src/ast/node/aggregate-output-value.ts +28 -0
  117. package/src/ast/node/aligned-modifier.ts +21 -0
  118. package/src/ast/node/array-definition.ts +44 -0
  119. package/src/ast/node/array-element-access.ts +24 -0
  120. package/src/ast/node/binary-expression.ts +28 -0
  121. package/src/ast/node/bit-modifier.ts +24 -0
  122. package/src/ast/node/case-clause.ts +30 -0
  123. package/src/ast/node/class-declaration.ts +39 -0
  124. package/src/ast/node/class-definition.ts +23 -0
  125. package/src/ast/node/class-id-range.ts +17 -0
  126. package/src/ast/node/class-id.ts +14 -0
  127. package/src/ast/node/class-member-access.ts +19 -0
  128. package/src/ast/node/compound-statement.ts +19 -0
  129. package/src/ast/node/computed-array-definition.ts +26 -0
  130. package/src/ast/node/computed-elementary-type-definition.ts +34 -0
  131. package/src/ast/node/default-clause.ts +26 -0
  132. package/src/ast/node/do-statement.ts +28 -0
  133. package/src/ast/node/elementary-type-definition.ts +49 -0
  134. package/src/ast/node/elementary-type-output-value.ts +19 -0
  135. package/src/ast/node/elementary-type.ts +18 -0
  136. package/src/ast/node/enum/array-dimension-kind.ts +11 -0
  137. package/src/ast/node/enum/binary-operator-kind.ts +41 -0
  138. package/src/ast/node/enum/class-id-kind.ts +12 -0
  139. package/src/ast/node/enum/elementary-type-kind.ts +13 -0
  140. package/src/ast/node/enum/expression-kind.ts +11 -0
  141. package/src/ast/node/enum/node-kind.ts +57 -0
  142. package/src/ast/node/enum/number-literal-kind.ts +17 -0
  143. package/src/ast/node/enum/statement-kind.ts +37 -0
  144. package/src/ast/node/enum/string-literal-kind.ts +13 -0
  145. package/src/ast/node/enum/string-variable-kind.ts +25 -0
  146. package/src/ast/node/enum/token-kind.ts +87 -0
  147. package/src/ast/node/expandable-modifier.ts +21 -0
  148. package/src/ast/node/explicit-array-dimension.ts +26 -0
  149. package/src/ast/node/expression-statement.ts +23 -0
  150. package/src/ast/node/extended-class-id-range.ts +20 -0
  151. package/src/ast/node/extends-modifier.ts +21 -0
  152. package/src/ast/node/for-statement.ts +29 -0
  153. package/src/ast/node/identifier.ts +12 -0
  154. package/src/ast/node/if-statement.ts +28 -0
  155. package/src/ast/node/implicit-array-dimension.ts +34 -0
  156. package/src/ast/node/length-attribute.ts +24 -0
  157. package/src/ast/node/length-of-expression.ts +21 -0
  158. package/src/ast/node/map-declaration.ts +34 -0
  159. package/src/ast/node/map-definition.ts +27 -0
  160. package/src/ast/node/map-entry.ts +18 -0
  161. package/src/ast/node/missing-error.ts +9 -0
  162. package/src/ast/node/number-literal.ts +18 -0
  163. package/src/ast/node/parameter-list.ts +25 -0
  164. package/src/ast/node/parameter-value-list.ts +29 -0
  165. package/src/ast/node/parameter.ts +20 -0
  166. package/src/ast/node/partial-array-dimension.ts +28 -0
  167. package/src/ast/node/specification.ts +21 -0
  168. package/src/ast/node/string-definition.ts +28 -0
  169. package/src/ast/node/string-literal.ts +21 -0
  170. package/src/ast/node/switch-statement.ts +32 -0
  171. package/src/ast/node/token.ts +20 -0
  172. package/src/ast/node/trivia.ts +13 -0
  173. package/src/ast/node/unary-expression.ts +31 -0
  174. package/src/ast/node/unexpected-error.ts +12 -0
  175. package/src/ast/node/while-statement.ts +26 -0
  176. package/src/ast/util/types.ts +138 -0
  177. package/src/ast/visitor/node-handler.ts +15 -0
  178. package/src/ast/visitor/node-visitor.ts +13 -0
  179. package/src/ast/visitor/traversing-visitor.ts +69 -0
  180. package/src/completion/completion-rules.ts +447 -0
  181. package/src/completion/get-potential-syntactic-tokens.ts +54 -0
  182. package/src/completion/get-potential-token-type-ids.ts +116 -0
  183. package/src/completion/hierarchical-map.ts +43 -0
  184. package/src/completion/rules/abstract-types.ts +174 -0
  185. package/src/completion/rules/aggregate-output-value-rules.ts +48 -0
  186. package/src/completion/rules/aligned-modifier-rules.ts +45 -0
  187. package/src/completion/rules/array-definition-rules.ts +87 -0
  188. package/src/completion/rules/array-element-access-rules.ts +22 -0
  189. package/src/completion/rules/assignment-expression-rules.ts +19 -0
  190. package/src/completion/rules/binary-expression-rules.ts +23 -0
  191. package/src/completion/rules/bit-modifier-rules.ts +25 -0
  192. package/src/completion/rules/case-clause-rules.ts +39 -0
  193. package/src/completion/rules/class-declaration-rules.ts +81 -0
  194. package/src/completion/rules/class-definition-rules.ts +28 -0
  195. package/src/completion/rules/class-id-range-rules.ts +17 -0
  196. package/src/completion/rules/class-id-rules.ts +9 -0
  197. package/src/completion/rules/class-member-access-rules.ts +7 -0
  198. package/src/completion/rules/compound-statement-rules.ts +25 -0
  199. package/src/completion/rules/computed-array-definition-rules.ts +25 -0
  200. package/src/completion/rules/computed-elementary-type-rules.ts +44 -0
  201. package/src/completion/rules/default-clause-rules.ts +23 -0
  202. package/src/completion/rules/do-statement-rules.ts +38 -0
  203. package/src/completion/rules/elementary-type-definition-rules.ts +62 -0
  204. package/src/completion/rules/elementary-type-output-value-rules.ts +13 -0
  205. package/src/completion/rules/elementary-type-rules.ts +18 -0
  206. package/src/completion/rules/expandable-modifier-rules.ts +21 -0
  207. package/src/completion/rules/explicit-array-dimension-rules.ts +22 -0
  208. package/src/completion/rules/expression-statement-rules.ts +22 -0
  209. package/src/completion/rules/extended-class-id-range-rules.ts +17 -0
  210. package/src/completion/rules/extends-modifier-rules.ts +17 -0
  211. package/src/completion/rules/for-statement-rules.ts +51 -0
  212. package/src/completion/rules/if-statement-rules.ts +42 -0
  213. package/src/completion/rules/implicit-array-dimension-rules.ts +21 -0
  214. package/src/completion/rules/length-attribute-rules.ts +19 -0
  215. package/src/completion/rules/lengthof-expression-rules.ts +23 -0
  216. package/src/completion/rules/map-declaration-rules.ts +45 -0
  217. package/src/completion/rules/map-definition-rules.ts +46 -0
  218. package/src/completion/rules/map-entry-rules.ts +17 -0
  219. package/src/completion/rules/parameter-list-rules.ts +21 -0
  220. package/src/completion/rules/parameter-rules.ts +17 -0
  221. package/src/completion/rules/parameter-value-list-rules.ts +27 -0
  222. package/src/completion/rules/partial-array-dimension-rules.ts +33 -0
  223. package/src/completion/rules/specification-rules.ts +37 -0
  224. package/src/completion/rules/string-definition-rules.ts +103 -0
  225. package/src/completion/rules/switch-statement-rules.ts +50 -0
  226. package/src/completion/rules/unary-expression-rules.ts +41 -0
  227. package/src/completion/rules/utf-string-literal-rules.ts +17 -0
  228. package/src/completion/rules/while-statement-rules.ts +38 -0
  229. package/src/lezer/context-tracker.ts +45 -0
  230. package/src/lezer/create-sdl-parser.ts +88 -0
  231. package/src/lezer/create-syntax-error-from-text-and-cursor.ts +110 -0
  232. package/src/lezer/create-syntax-error-from-text-and-position.ts +36 -0
  233. package/src/lezer/parser.terms.ts +129 -0
  234. package/src/lezer/parser.ts +63 -0
  235. package/src/lezer/props/fold-node-prop-source.ts +27 -0
  236. package/src/lezer/props/primitive-node-prop-source.ts +19 -0
  237. package/src/lezer/props/style-tags-node-prop-source.ts +188 -0
  238. package/src/lezer/props/syntactic-token-node-prop-source.ts +298 -0
  239. package/src/lezer/sdl-string-input.ts +46 -0
  240. package/src/location.ts +13 -0
  241. package/src/parse-helper.ts +93 -0
  242. package/src/prettier/prettier-plugin-sdl.ts +89 -0
  243. package/src/prettier/print-abstract-array-dimension.ts +84 -0
  244. package/src/prettier/print-abstract-class-id.ts +53 -0
  245. package/src/prettier/print-abstract-expression.ts +168 -0
  246. package/src/prettier/print-abstract-node.ts +224 -0
  247. package/src/prettier/print-abstract-statement.ts +124 -0
  248. package/src/prettier/print-aggregate-output-value.ts +35 -0
  249. package/src/prettier/print-aligned-modifier.ts +50 -0
  250. package/src/prettier/print-array-definition.ts +95 -0
  251. package/src/prettier/print-array-element-access.ts +14 -0
  252. package/src/prettier/print-bit-modifier.ts +48 -0
  253. package/src/prettier/print-case-clause.ts +58 -0
  254. package/src/prettier/print-class-declaration.ts +99 -0
  255. package/src/prettier/print-class-definition.ts +44 -0
  256. package/src/prettier/print-class-member-access.ts +13 -0
  257. package/src/prettier/print-computed-array-definition.ts +33 -0
  258. package/src/prettier/print-computed-elementary-type-definition.ts +60 -0
  259. package/src/prettier/print-default-clause.ts +39 -0
  260. package/src/prettier/print-do-statement.ts +31 -0
  261. package/src/prettier/print-elementary-type-definition.ts +108 -0
  262. package/src/prettier/print-elementary-type-output-value.ts +13 -0
  263. package/src/prettier/print-elementary-type.ts +28 -0
  264. package/src/prettier/print-expandable-modifier.ts +41 -0
  265. package/src/prettier/print-extends-modifier.ts +29 -0
  266. package/src/prettier/print-for-statement.ts +64 -0
  267. package/src/prettier/print-identifier.ts +10 -0
  268. package/src/prettier/print-if-statement.ts +76 -0
  269. package/src/prettier/print-length-attribute.ts +14 -0
  270. package/src/prettier/print-map-declaration.ts +75 -0
  271. package/src/prettier/print-map-definition.ts +67 -0
  272. package/src/prettier/print-map-entry.ts +22 -0
  273. package/src/prettier/print-number-literal.ts +84 -0
  274. package/src/prettier/print-parameter-list.ts +20 -0
  275. package/src/prettier/print-parameter-value-list.ts +20 -0
  276. package/src/prettier/print-parameter.ts +34 -0
  277. package/src/prettier/print-specification.ts +51 -0
  278. package/src/prettier/print-string-definition.ts +114 -0
  279. package/src/prettier/print-string-literal.ts +57 -0
  280. package/src/prettier/print-switch-statement.ts +46 -0
  281. package/src/prettier/print-token.ts +7 -0
  282. package/src/prettier/print-unexpected-error.ts +10 -0
  283. package/src/prettier/print-while-statement.ts +26 -0
  284. package/src/prettier/util/print-utils.ts +607 -0
  285. package/src/prettier/util/types.ts +40 -0
  286. package/src/scanner-error.ts +65 -0
  287. package/src/util/location-utils.ts +16 -0
  288. package/src/util/logger.ts +165 -0
  289. package/tests/analyser/create-sdl-analyser.test.ts +54 -0
  290. package/tests/analyser/get-sdl-analyser-test-scenarios.ts +80 -0
  291. package/tests/analyser/sdl-analyser-scenarios.test.ts +67 -0
  292. package/tests/analyser/semantic-error-scenarios.test.ts +40 -0
  293. package/tests/analyser/symbol-table.test.ts +188 -0
  294. package/tests/analyser/test-cases/array_definition.txt +50 -0
  295. package/tests/analyser/test-cases/class_declaration.txt +112 -0
  296. package/tests/analyser/test-cases/class_definition.txt +60 -0
  297. package/tests/analyser/test-cases/compound_statement.txt +63 -0
  298. package/tests/analyser/test-cases/computed_array_definition.txt +12 -0
  299. package/tests/analyser/test-cases/computed_elementary_type_definition.txt +39 -0
  300. package/tests/analyser/test-cases/do_statement.txt +16 -0
  301. package/tests/analyser/test-cases/elementary_type_definition.txt +58 -0
  302. package/tests/analyser/test-cases/expression.txt +159 -0
  303. package/tests/analyser/test-cases/for_statement.txt +55 -0
  304. package/tests/analyser/test-cases/if_statement.txt +57 -0
  305. package/tests/analyser/test-cases/map_declaration.txt +89 -0
  306. package/tests/analyser/test-cases/map_definition.txt +35 -0
  307. package/tests/analyser/test-cases/number_literal.txt +31 -0
  308. package/tests/analyser/test-cases/parameter_list.txt +16 -0
  309. package/tests/analyser/test-cases/scopes.txt +239 -0
  310. package/tests/analyser/test-cases/specification.txt +28 -0
  311. package/tests/analyser/test-cases/string_definition.txt +40 -0
  312. package/tests/analyser/test-cases/switch_statement.txt +96 -0
  313. package/tests/analyser/test-cases/while_statement.txt +16 -0
  314. package/tests/analyser/util/symbol-table-utils.test.ts +65 -0
  315. package/tests/ast/__snapshots__/build-ast.test.ts.snap +38897 -0
  316. package/tests/ast/build-ast.test.ts +463 -0
  317. package/tests/ast/visitor/traversing-visitor.test.ts +36 -0
  318. package/tests/completion/get-potential-syntactic-tokens.test.ts +89 -0
  319. package/tests/completion/get-potential-token-type-ids.test.ts +76 -0
  320. package/tests/completion/test-potential-syntactic-tokens-scenario.ts +24 -0
  321. package/tests/completion/test-potential-token-type-ids-scenario.ts +33 -0
  322. package/tests/fixtures/history-recording-node-handler.ts +232 -0
  323. package/tests/lezer/create-parse-error-from-text-and-position.test.ts +129 -0
  324. package/tests/lezer/create-sdl-parser.test.ts +15 -0
  325. package/tests/lezer/sdl-parser-scenarios.test.ts +24 -0
  326. package/tests/lezer/sdl-string-input.test.ts +12 -0
  327. package/tests/lezer/syntax-error-scenarios.test.ts +114 -0
  328. package/tests/lezer/test-cases/array_definition.txt +109 -0
  329. package/tests/lezer/test-cases/class_declaration.txt +141 -0
  330. package/tests/lezer/test-cases/class_definition.txt +89 -0
  331. package/tests/lezer/test-cases/comment.txt +335 -0
  332. package/tests/lezer/test-cases/compound_statement.txt +109 -0
  333. package/tests/lezer/test-cases/computed_array_definition.txt +33 -0
  334. package/tests/lezer/test-cases/computed_elementary_type_definition.txt +59 -0
  335. package/tests/lezer/test-cases/do_statement.txt +48 -0
  336. package/tests/lezer/test-cases/elementary_type_definition.txt +158 -0
  337. package/tests/lezer/test-cases/expression.txt +1203 -0
  338. package/tests/lezer/test-cases/for_statement.txt +183 -0
  339. package/tests/lezer/test-cases/if_statement.txt +183 -0
  340. package/tests/lezer/test-cases/invalid.txt +97 -0
  341. package/tests/lezer/test-cases/map_declaration.txt +152 -0
  342. package/tests/lezer/test-cases/map_definition.txt +59 -0
  343. package/tests/lezer/test-cases/number_literal.txt +273 -0
  344. package/tests/lezer/test-cases/specification.txt +38 -0
  345. package/tests/lezer/test-cases/string_definition.txt +263 -0
  346. package/tests/lezer/test-cases/string_literal.txt +303 -0
  347. package/tests/lezer/test-cases/switch_statement.txt +407 -0
  348. package/tests/lezer/test-cases/while_statement.txt +45 -0
  349. package/tests/parse-helper.test.ts +361 -0
  350. package/tests/prettier/__snapshots__/prettier-plugin-sdl.test.ts.snap +127 -0
  351. package/tests/prettier/prettier-plugin-sdl.test.ts +58 -0
  352. package/tests/prettier/print-array.test.ts +29 -0
  353. package/tests/prettier/print-class.test.ts +15 -0
  354. package/tests/prettier/print-do.test.ts +25 -0
  355. package/tests/prettier/print-elementary-type.test.ts +62 -0
  356. package/tests/prettier/print-error.test.ts +40 -0
  357. package/tests/prettier/print-expression.test.ts +17 -0
  358. package/tests/prettier/print-for.test.ts +23 -0
  359. package/tests/prettier/print-if.test.ts +71 -0
  360. package/tests/prettier/print-number-literal.test.ts +28 -0
  361. package/tests/prettier/print-specification.test.ts +54 -0
  362. package/tests/prettier/print-string.test.ts +36 -0
  363. package/tests/prettier/print-switch.test.ts +69 -0
  364. package/tests/prettier/print-while.test.ts +23 -0
  365. package/tests/prettier/test-prettier-scenario.ts +41 -0
  366. package/tests/prettier/util/print-utils.test.ts +665 -0
  367. package/tests/prettier/util/types.test.ts +38 -0
  368. package/tests/sample-specifications/invalid.sdl +24 -0
  369. package/tests/sample-specifications/prettified-invalid.sdl +28 -0
  370. package/tests/sample-specifications/prettified-various-elements-narrow.sdl +97 -0
  371. package/tests/sample-specifications/prettified-various-elements.sdl +90 -0
  372. package/tests/sample-specifications/sample.sdl +24 -0
  373. package/tests/sample-specifications/various-elements.sdl +88 -0
  374. package/tests/util/logger.test.ts +36 -0
  375. package/tsconfig.json +29 -0
@@ -0,0 +1,1203 @@
1
+ # Number literal with unary plus operator
2
+
3
+ class A {+1;}
4
+
5
+ ==>
6
+
7
+ Specification(
8
+ ClassDeclaration(
9
+ class
10
+ Whitespace
11
+ Identifier
12
+ Whitespace
13
+ OpenBrace
14
+ ExpressionStatement(
15
+ UnaryExpression(
16
+ UnaryPlus
17
+ UnaryExpression(
18
+ IntegerLiteral
19
+ )
20
+ )
21
+ Semicolon
22
+ )
23
+ CloseBrace
24
+ )
25
+ )
26
+
27
+ # Identifier with unary negation operator
28
+
29
+ class A {-i;}
30
+
31
+ ==>
32
+
33
+ Specification(
34
+ ClassDeclaration(
35
+ class
36
+ Whitespace
37
+ Identifier
38
+ Whitespace
39
+ OpenBrace
40
+ ExpressionStatement(
41
+ UnaryExpression(
42
+ UnaryNegation
43
+ UnaryExpression(
44
+ Identifier
45
+ )
46
+ )
47
+ Semicolon
48
+ )
49
+ CloseBrace
50
+ )
51
+ )
52
+
53
+ # Lengthof operator with unary negation
54
+
55
+ class A {-lengthof(i);}
56
+
57
+ ==>
58
+
59
+ Specification(
60
+ ClassDeclaration(
61
+ class
62
+ Whitespace
63
+ Identifier
64
+ Whitespace
65
+ OpenBrace
66
+ ExpressionStatement(
67
+ UnaryExpression(
68
+ UnaryNegation
69
+ UnaryExpression(
70
+ LengthofExpression(
71
+ lengthof
72
+ OpenParenthesis
73
+ UnaryExpression(
74
+ Identifier
75
+ )
76
+ CloseParenthesis
77
+ )
78
+ )
79
+ )
80
+ Semicolon
81
+ )
82
+ CloseBrace
83
+ )
84
+ )
85
+
86
+ # Postfix operator
87
+
88
+ class A {i++;}
89
+
90
+ ==>
91
+
92
+ Specification(
93
+ ClassDeclaration(
94
+ class
95
+ Whitespace
96
+ Identifier
97
+ Whitespace
98
+ OpenBrace
99
+ ExpressionStatement(
100
+ UnaryExpression(
101
+ UnaryExpression(
102
+ Identifier
103
+ )
104
+ PostfixIncrement
105
+ )
106
+ Semicolon
107
+ )
108
+ CloseBrace
109
+ )
110
+ )
111
+
112
+ # Class member access expression
113
+
114
+ class A {a.b;}
115
+
116
+ ==>
117
+
118
+ Specification(
119
+ ClassDeclaration(
120
+ class
121
+ Whitespace
122
+ Identifier
123
+ Whitespace
124
+ OpenBrace
125
+ ExpressionStatement(
126
+ UnaryExpression(
127
+ UnaryExpression(
128
+ Identifier
129
+ )
130
+ ClassMemberAccess(
131
+ Period
132
+ Identifier
133
+ )
134
+ )
135
+ Semicolon
136
+ )
137
+ CloseBrace
138
+ )
139
+ )
140
+
141
+ # Class member access expression - multiple
142
+
143
+ class A {a.b.c;}
144
+
145
+ ==>
146
+
147
+ Specification(
148
+ ClassDeclaration(
149
+ class
150
+ Whitespace
151
+ Identifier
152
+ Whitespace
153
+ OpenBrace
154
+ ExpressionStatement(
155
+ UnaryExpression(
156
+ UnaryExpression(
157
+ UnaryExpression(
158
+ Identifier
159
+ )
160
+ ClassMemberAccess(
161
+ Period
162
+ Identifier
163
+ )
164
+ )
165
+ ClassMemberAccess(
166
+ Period
167
+ Identifier
168
+ )
169
+ )
170
+ Semicolon
171
+ )
172
+ CloseBrace
173
+ )
174
+ )
175
+
176
+ # Array element access expression
177
+
178
+ class A {a[1];}
179
+
180
+ ==>
181
+
182
+ Specification(
183
+ ClassDeclaration(
184
+ class
185
+ Whitespace
186
+ Identifier
187
+ Whitespace
188
+ OpenBrace
189
+ ExpressionStatement(
190
+ UnaryExpression(
191
+ UnaryExpression(
192
+ Identifier
193
+ )
194
+ ArrayElementAccess(
195
+ OpenBracket
196
+ UnaryExpression(
197
+ IntegerLiteral
198
+ )
199
+ CloseBracket
200
+ )
201
+ )
202
+ Semicolon
203
+ )
204
+ CloseBrace
205
+ )
206
+ )
207
+
208
+ # Array element access expression multiple
209
+
210
+ class A {a[1][2];}
211
+
212
+ ==>
213
+
214
+ Specification(
215
+ ClassDeclaration(
216
+ class
217
+ Whitespace
218
+ Identifier
219
+ Whitespace
220
+ OpenBrace
221
+ ExpressionStatement(
222
+ UnaryExpression(
223
+ UnaryExpression(
224
+ UnaryExpression(
225
+ Identifier
226
+ )
227
+ ArrayElementAccess(
228
+ OpenBracket
229
+ UnaryExpression(
230
+ IntegerLiteral
231
+ )
232
+ CloseBracket
233
+ )
234
+ )
235
+ ArrayElementAccess(
236
+ OpenBracket
237
+ UnaryExpression(
238
+ IntegerLiteral
239
+ )
240
+ CloseBracket
241
+ )
242
+ )
243
+ Semicolon
244
+ )
245
+ CloseBrace
246
+ )
247
+ )
248
+
249
+ # Class member access expression with postfix operator
250
+
251
+ class A {a.b++;}
252
+
253
+ ==>
254
+
255
+ Specification(
256
+ ClassDeclaration(
257
+ class
258
+ Whitespace
259
+ Identifier
260
+ Whitespace
261
+ OpenBrace
262
+ ExpressionStatement(
263
+ UnaryExpression(
264
+ UnaryExpression(
265
+ UnaryExpression(
266
+ Identifier
267
+ )
268
+ ClassMemberAccess(
269
+ Period
270
+ Identifier
271
+ )
272
+ )
273
+ PostfixIncrement
274
+ )
275
+ Semicolon
276
+ )
277
+ CloseBrace
278
+ )
279
+ )
280
+
281
+ # Array element access expression with postfix operator
282
+
283
+ class A {a[1]++;}
284
+
285
+ ==>
286
+
287
+ Specification(
288
+ ClassDeclaration(
289
+ class
290
+ Whitespace
291
+ Identifier
292
+ Whitespace
293
+ OpenBrace
294
+ ExpressionStatement(
295
+ UnaryExpression(
296
+ UnaryExpression(
297
+ UnaryExpression(
298
+ Identifier
299
+ )
300
+ ArrayElementAccess(
301
+ OpenBracket
302
+ UnaryExpression(
303
+ IntegerLiteral
304
+ )
305
+ CloseBracket
306
+ )
307
+ )
308
+ PostfixIncrement
309
+ )
310
+ Semicolon
311
+ )
312
+ CloseBrace
313
+ )
314
+ )
315
+
316
+ # Class member and array element access expression - multiple mixed
317
+
318
+ class A {a[1][2].b.c[3];}
319
+
320
+ ==>
321
+
322
+ Specification(
323
+ ClassDeclaration(
324
+ class
325
+ Whitespace
326
+ Identifier
327
+ Whitespace
328
+ OpenBrace
329
+ ExpressionStatement(
330
+ UnaryExpression(
331
+ UnaryExpression(
332
+ UnaryExpression(
333
+ UnaryExpression(
334
+ UnaryExpression(
335
+ UnaryExpression(
336
+ Identifier
337
+ )
338
+ ArrayElementAccess(
339
+ OpenBracket
340
+ UnaryExpression(
341
+ IntegerLiteral
342
+ )
343
+ CloseBracket
344
+ )
345
+ )
346
+ ArrayElementAccess(
347
+ OpenBracket
348
+ UnaryExpression(
349
+ IntegerLiteral
350
+ )
351
+ CloseBracket
352
+ )
353
+ )
354
+ ClassMemberAccess(
355
+ Period
356
+ Identifier
357
+ )
358
+ )
359
+ ClassMemberAccess(
360
+ Period
361
+ Identifier
362
+ )
363
+ )
364
+ ArrayElementAccess(
365
+ OpenBracket
366
+ UnaryExpression(
367
+ IntegerLiteral
368
+ )
369
+ CloseBracket
370
+ )
371
+ )
372
+ Semicolon
373
+ )
374
+ CloseBrace
375
+ )
376
+ )
377
+
378
+ # Expression in parenthesis with postfix operator and whitespace
379
+
380
+ class A {( i ) ++;}
381
+
382
+ ==>
383
+
384
+ Specification(
385
+ ClassDeclaration(
386
+ class
387
+ Whitespace
388
+ Identifier
389
+ Whitespace
390
+ OpenBrace
391
+ ExpressionStatement(
392
+ UnaryExpression(
393
+ UnaryExpression(
394
+ OpenParenthesis
395
+ Whitespace
396
+ UnaryExpression(
397
+ Identifier
398
+ )
399
+ Whitespace
400
+ CloseParenthesis
401
+ )
402
+ Whitespace
403
+ PostfixIncrement
404
+ )
405
+ Semicolon
406
+ )
407
+ CloseBrace
408
+ )
409
+ )
410
+
411
+ # Multiplication of two literals
412
+
413
+ class A {1*2;}
414
+
415
+ ==>
416
+
417
+ Specification(
418
+ ClassDeclaration(
419
+ class
420
+ Whitespace
421
+ Identifier
422
+ Whitespace
423
+ OpenBrace
424
+ ExpressionStatement(
425
+ BinaryExpression(
426
+ UnaryExpression(
427
+ IntegerLiteral
428
+ )
429
+ Multiplication
430
+ UnaryExpression(
431
+ IntegerLiteral
432
+ )
433
+ )
434
+ Semicolon
435
+ )
436
+ CloseBrace
437
+ )
438
+ )
439
+
440
+ # Multiplication of two literals with unary operators
441
+
442
+ class A {+1*-2;}
443
+
444
+ ==>
445
+
446
+ Specification(
447
+ ClassDeclaration(
448
+ class
449
+ Whitespace
450
+ Identifier
451
+ Whitespace
452
+ OpenBrace
453
+ ExpressionStatement(
454
+ BinaryExpression(
455
+ UnaryExpression(
456
+ UnaryPlus
457
+ UnaryExpression(
458
+ IntegerLiteral
459
+ )
460
+ )
461
+ Multiplication
462
+ UnaryExpression(
463
+ UnaryNegation
464
+ UnaryExpression(
465
+ IntegerLiteral
466
+ )
467
+ )
468
+ )
469
+ Semicolon
470
+ )
471
+ CloseBrace
472
+ )
473
+ )
474
+
475
+ # Multiplication of three literals
476
+
477
+ class A {1*2*3;}
478
+
479
+ ==>
480
+
481
+ Specification(
482
+ ClassDeclaration(
483
+ class
484
+ Whitespace
485
+ Identifier
486
+ Whitespace
487
+ OpenBrace
488
+ ExpressionStatement(
489
+ BinaryExpression(
490
+ BinaryExpression(
491
+ UnaryExpression(
492
+ IntegerLiteral
493
+ )
494
+ Multiplication
495
+ UnaryExpression(
496
+ IntegerLiteral
497
+ )
498
+ )
499
+ Multiplication
500
+ UnaryExpression(
501
+ IntegerLiteral
502
+ )
503
+ )
504
+ Semicolon
505
+ )
506
+ CloseBrace
507
+ )
508
+ )
509
+
510
+ # Binary expression in parenthesis
511
+
512
+ class A {(1*2);}
513
+
514
+ ==>
515
+
516
+ Specification(
517
+ ClassDeclaration(
518
+ class
519
+ Whitespace
520
+ Identifier
521
+ Whitespace
522
+ OpenBrace
523
+ ExpressionStatement(
524
+ UnaryExpression(
525
+ OpenParenthesis
526
+ BinaryExpression(
527
+ UnaryExpression(
528
+ IntegerLiteral
529
+ )
530
+ Multiplication
531
+ UnaryExpression(
532
+ IntegerLiteral
533
+ )
534
+ )
535
+ CloseParenthesis
536
+ )
537
+ Semicolon
538
+ )
539
+ CloseBrace
540
+ )
541
+ )
542
+
543
+ # Binary expression in parenthesis with postfix operator - invalid syntax!
544
+
545
+ class A {(1*2)++;}
546
+
547
+ ==>
548
+
549
+ Specification(
550
+ ClassDeclaration(
551
+ class
552
+ Whitespace
553
+ Identifier
554
+ Whitespace
555
+ OpenBrace
556
+ ExpressionStatement(
557
+ UnaryExpression(
558
+ UnaryExpression(
559
+ OpenParenthesis
560
+ BinaryExpression(
561
+ UnaryExpression(
562
+ IntegerLiteral
563
+ )
564
+ Multiplication
565
+ UnaryExpression(
566
+ IntegerLiteral
567
+ )
568
+ )
569
+ CloseParenthesis
570
+ )
571
+ PostfixIncrement
572
+ )
573
+ Semicolon
574
+ )
575
+ CloseBrace
576
+ )
577
+ )
578
+
579
+ # Multiplicative operators - left-to-right associativity
580
+
581
+ class A {1/2*3;}
582
+
583
+ ==>
584
+
585
+ Specification(
586
+ ClassDeclaration(
587
+ class
588
+ Whitespace
589
+ Identifier
590
+ Whitespace
591
+ OpenBrace
592
+ ExpressionStatement(
593
+ BinaryExpression(
594
+ BinaryExpression(
595
+ UnaryExpression(
596
+ IntegerLiteral
597
+ )
598
+ Division
599
+ UnaryExpression(
600
+ IntegerLiteral
601
+ )
602
+ )
603
+ Multiplication
604
+ UnaryExpression(
605
+ IntegerLiteral
606
+ )
607
+ )
608
+ Semicolon
609
+ )
610
+ CloseBrace
611
+ )
612
+ )
613
+
614
+ # Multiplicative and additive operators - precedence
615
+
616
+ class A {1+2*3;}
617
+
618
+ ==>
619
+
620
+ Specification(
621
+ ClassDeclaration(
622
+ class
623
+ Whitespace
624
+ Identifier
625
+ Whitespace
626
+ OpenBrace
627
+ ExpressionStatement(
628
+ BinaryExpression(
629
+ UnaryExpression(
630
+ IntegerLiteral
631
+ )
632
+ Addition
633
+ BinaryExpression(
634
+ UnaryExpression(
635
+ IntegerLiteral
636
+ )
637
+ Multiplication
638
+ UnaryExpression(
639
+ IntegerLiteral
640
+ )
641
+ )
642
+ )
643
+ Semicolon
644
+ )
645
+ CloseBrace
646
+ )
647
+ )
648
+
649
+ # Multiplicative and additive operators - precedence overridden by parenthesis
650
+
651
+ class A {(1+2)*3;}
652
+
653
+ ==>
654
+
655
+ Specification(
656
+ ClassDeclaration(
657
+ class
658
+ Whitespace
659
+ Identifier
660
+ Whitespace
661
+ OpenBrace
662
+ ExpressionStatement(
663
+ BinaryExpression(
664
+ UnaryExpression(
665
+ OpenParenthesis
666
+ BinaryExpression(
667
+ UnaryExpression(
668
+ IntegerLiteral
669
+ )
670
+ Addition
671
+ UnaryExpression(
672
+ IntegerLiteral
673
+ )
674
+ )
675
+ CloseParenthesis
676
+ )
677
+ Multiplication
678
+ UnaryExpression(
679
+ IntegerLiteral
680
+ )
681
+ )
682
+ Semicolon
683
+ )
684
+ CloseBrace
685
+ )
686
+ )
687
+
688
+ # Logical operators
689
+
690
+ class A {i||j && k;}
691
+
692
+ ==>
693
+
694
+ Specification(
695
+ ClassDeclaration(
696
+ class
697
+ Whitespace
698
+ Identifier
699
+ Whitespace
700
+ OpenBrace
701
+ ExpressionStatement(
702
+ BinaryExpression(
703
+ BinaryExpression(
704
+ UnaryExpression(
705
+ Identifier
706
+ )
707
+ LogicalOr
708
+ UnaryExpression(
709
+ Identifier
710
+ )
711
+ )
712
+ Whitespace
713
+ LogicalAnd
714
+ Whitespace
715
+ UnaryExpression(
716
+ Identifier
717
+ )
718
+ )
719
+ Semicolon
720
+ )
721
+ CloseBrace
722
+ )
723
+ )
724
+
725
+ # Additive operators
726
+
727
+ class A {i+j - k;}
728
+
729
+ ==>
730
+
731
+ Specification(
732
+ ClassDeclaration(
733
+ class
734
+ Whitespace
735
+ Identifier
736
+ Whitespace
737
+ OpenBrace
738
+ ExpressionStatement(
739
+ BinaryExpression(
740
+ BinaryExpression(
741
+ UnaryExpression(
742
+ Identifier
743
+ )
744
+ Addition
745
+ UnaryExpression(
746
+ Identifier
747
+ )
748
+ )
749
+ Whitespace
750
+ Subtraction
751
+ Whitespace
752
+ UnaryExpression(
753
+ Identifier
754
+ )
755
+ )
756
+ Semicolon
757
+ )
758
+ CloseBrace
759
+ )
760
+ )
761
+
762
+ # Shift operators
763
+
764
+ class A {i<<j >> k;}
765
+
766
+ ==>
767
+
768
+ Specification(
769
+ ClassDeclaration(
770
+ class
771
+ Whitespace
772
+ Identifier
773
+ Whitespace
774
+ OpenBrace
775
+ ExpressionStatement(
776
+ BinaryExpression(
777
+ BinaryExpression(
778
+ UnaryExpression(
779
+ Identifier
780
+ )
781
+ BitwiseShiftLeft
782
+ UnaryExpression(
783
+ Identifier
784
+ )
785
+ )
786
+ Whitespace
787
+ BitwiseShiftRight
788
+ Whitespace
789
+ UnaryExpression(
790
+ Identifier
791
+ )
792
+ )
793
+ Semicolon
794
+ )
795
+ CloseBrace
796
+ )
797
+ )
798
+
799
+ # Relational operators
800
+
801
+ class A {i<j<=k>l>=m;}
802
+
803
+ ==>
804
+
805
+ Specification(
806
+ ClassDeclaration(
807
+ class
808
+ Whitespace
809
+ Identifier
810
+ Whitespace
811
+ OpenBrace
812
+ ExpressionStatement(
813
+ BinaryExpression(
814
+ BinaryExpression(
815
+ BinaryExpression(
816
+ BinaryExpression(
817
+ UnaryExpression(
818
+ Identifier
819
+ )
820
+ RelationalLessThan
821
+ UnaryExpression(
822
+ Identifier
823
+ )
824
+ )
825
+ RelationalLessThanOrEqual
826
+ UnaryExpression(
827
+ Identifier
828
+ )
829
+ )
830
+ RelationalGreaterThan
831
+ UnaryExpression(
832
+ Identifier
833
+ )
834
+ )
835
+ RelationalGreaterThanOrEqual
836
+ UnaryExpression(
837
+ Identifier
838
+ )
839
+ )
840
+ Semicolon
841
+ )
842
+ CloseBrace
843
+ )
844
+ )
845
+
846
+ # Equality operators
847
+
848
+ class A {i==j != k;}
849
+
850
+ ==>
851
+
852
+ Specification(
853
+ ClassDeclaration(
854
+ class
855
+ Whitespace
856
+ Identifier
857
+ Whitespace
858
+ OpenBrace
859
+ ExpressionStatement(
860
+ BinaryExpression(
861
+ BinaryExpression(
862
+ UnaryExpression(
863
+ Identifier
864
+ )
865
+ RelationalEqual
866
+ UnaryExpression(
867
+ Identifier
868
+ )
869
+ )
870
+ Whitespace
871
+ RelationalNotEqual
872
+ Whitespace
873
+ UnaryExpression(
874
+ Identifier
875
+ )
876
+ )
877
+ Semicolon
878
+ )
879
+ CloseBrace
880
+ )
881
+ )
882
+
883
+ # Bitwise operators
884
+
885
+ class A {i&j | k;}
886
+
887
+ ==>
888
+
889
+ Specification(
890
+ ClassDeclaration(
891
+ class
892
+ Whitespace
893
+ Identifier
894
+ Whitespace
895
+ OpenBrace
896
+ ExpressionStatement(
897
+ BinaryExpression(
898
+ BinaryExpression(
899
+ UnaryExpression(
900
+ Identifier
901
+ )
902
+ BitwiseAnd
903
+ UnaryExpression(
904
+ Identifier
905
+ )
906
+ )
907
+ Whitespace
908
+ BitwiseOr
909
+ Whitespace
910
+ UnaryExpression(
911
+ Identifier
912
+ )
913
+ )
914
+ Semicolon
915
+ )
916
+ CloseBrace
917
+ )
918
+ )
919
+
920
+ # All precedence rules
921
+
922
+ class A {8&&7|6==5>4>>3+2*1;}
923
+
924
+ ==>
925
+
926
+ Specification(
927
+ ClassDeclaration(
928
+ class
929
+ Whitespace
930
+ Identifier
931
+ Whitespace
932
+ OpenBrace
933
+ ExpressionStatement(
934
+ BinaryExpression(
935
+ UnaryExpression(
936
+ IntegerLiteral
937
+ )
938
+ LogicalAnd
939
+ BinaryExpression(
940
+ UnaryExpression(
941
+ IntegerLiteral
942
+ )
943
+ BitwiseOr
944
+ BinaryExpression(
945
+ UnaryExpression(
946
+ IntegerLiteral
947
+ )
948
+ RelationalEqual
949
+ BinaryExpression(
950
+ UnaryExpression(
951
+ IntegerLiteral
952
+ )
953
+ RelationalGreaterThan
954
+ BinaryExpression(
955
+ UnaryExpression(
956
+ IntegerLiteral
957
+ )
958
+ BitwiseShiftRight
959
+ BinaryExpression(
960
+ UnaryExpression(
961
+ IntegerLiteral
962
+ )
963
+ Addition
964
+ BinaryExpression(
965
+ UnaryExpression(
966
+ IntegerLiteral
967
+ )
968
+ Multiplication
969
+ UnaryExpression(
970
+ IntegerLiteral
971
+ )
972
+ )
973
+ )
974
+ )
975
+ )
976
+ )
977
+ )
978
+ )
979
+ Semicolon
980
+ )
981
+ CloseBrace
982
+ )
983
+ )
984
+
985
+ # Mixed unary and binary expressions
986
+
987
+ class A {i++ * lengthof(j);}
988
+
989
+ ==>
990
+
991
+ Specification(
992
+ ClassDeclaration(
993
+ class
994
+ Whitespace
995
+ Identifier
996
+ Whitespace
997
+ OpenBrace
998
+ ExpressionStatement(
999
+ BinaryExpression(
1000
+ UnaryExpression(
1001
+ UnaryExpression(
1002
+ Identifier
1003
+ )
1004
+ PostfixIncrement
1005
+ )
1006
+ Whitespace
1007
+ Multiplication
1008
+ Whitespace
1009
+ UnaryExpression(
1010
+ LengthofExpression(
1011
+ lengthof
1012
+ OpenParenthesis
1013
+ UnaryExpression(
1014
+ Identifier
1015
+ )
1016
+ CloseParenthesis
1017
+ )
1018
+ )
1019
+ )
1020
+ Semicolon
1021
+ )
1022
+ CloseBrace
1023
+ )
1024
+ )
1025
+
1026
+ # Nested parenthesis
1027
+
1028
+ class A {((1*2)+3)/(2*3);}
1029
+
1030
+ ==>
1031
+
1032
+ Specification(
1033
+ ClassDeclaration(
1034
+ class
1035
+ Whitespace
1036
+ Identifier
1037
+ Whitespace
1038
+ OpenBrace
1039
+ ExpressionStatement(
1040
+ BinaryExpression(
1041
+ UnaryExpression(
1042
+ OpenParenthesis
1043
+ BinaryExpression(
1044
+ UnaryExpression(
1045
+ OpenParenthesis
1046
+ BinaryExpression(
1047
+ UnaryExpression(
1048
+ IntegerLiteral
1049
+ )
1050
+ Multiplication
1051
+ UnaryExpression(
1052
+ IntegerLiteral
1053
+ )
1054
+ )
1055
+ CloseParenthesis
1056
+ )
1057
+ Addition
1058
+ UnaryExpression(
1059
+ IntegerLiteral
1060
+ )
1061
+ )
1062
+ CloseParenthesis
1063
+ )
1064
+ Division
1065
+ UnaryExpression(
1066
+ OpenParenthesis
1067
+ BinaryExpression(
1068
+ UnaryExpression(
1069
+ IntegerLiteral
1070
+ )
1071
+ Multiplication
1072
+ UnaryExpression(
1073
+ IntegerLiteral
1074
+ )
1075
+ )
1076
+ CloseParenthesis
1077
+ )
1078
+ )
1079
+ Semicolon
1080
+ )
1081
+ CloseBrace
1082
+ )
1083
+ )
1084
+
1085
+ # Three levels of precedence
1086
+
1087
+ class A {1+2*3<<2;}
1088
+
1089
+ ==>
1090
+
1091
+ Specification(
1092
+ ClassDeclaration(
1093
+ class
1094
+ Whitespace
1095
+ Identifier
1096
+ Whitespace
1097
+ OpenBrace
1098
+ ExpressionStatement(
1099
+ BinaryExpression(
1100
+ BinaryExpression(
1101
+ UnaryExpression(
1102
+ IntegerLiteral
1103
+ )
1104
+ Addition
1105
+ BinaryExpression(
1106
+ UnaryExpression(
1107
+ IntegerLiteral
1108
+ )
1109
+ Multiplication
1110
+ UnaryExpression(
1111
+ IntegerLiteral
1112
+ )
1113
+ )
1114
+ )
1115
+ BitwiseShiftLeft
1116
+ UnaryExpression(
1117
+ IntegerLiteral
1118
+ )
1119
+ )
1120
+ Semicolon
1121
+ )
1122
+ CloseBrace
1123
+ )
1124
+ )
1125
+
1126
+ # Assignment expression
1127
+
1128
+ class A {i=1*2;}
1129
+
1130
+ ==>
1131
+
1132
+ Specification(
1133
+ ClassDeclaration(
1134
+ class
1135
+ Whitespace
1136
+ Identifier
1137
+ Whitespace
1138
+ OpenBrace
1139
+ ExpressionStatement(
1140
+ AssignmentExpression(
1141
+ UnaryExpression(
1142
+ Identifier
1143
+ )
1144
+ Assignment
1145
+ BinaryExpression(
1146
+ UnaryExpression(
1147
+ IntegerLiteral
1148
+ )
1149
+ Multiplication
1150
+ UnaryExpression(
1151
+ IntegerLiteral
1152
+ )
1153
+ )
1154
+ )
1155
+ Semicolon
1156
+ )
1157
+ CloseBrace
1158
+ )
1159
+ )
1160
+
1161
+ # Assignment with class member and array element access expressions
1162
+
1163
+ class A {a.b=c[1];}
1164
+
1165
+ ==>
1166
+
1167
+ Specification(
1168
+ ClassDeclaration(
1169
+ class
1170
+ Whitespace
1171
+ Identifier
1172
+ Whitespace
1173
+ OpenBrace
1174
+ ExpressionStatement(
1175
+ AssignmentExpression(
1176
+ UnaryExpression(
1177
+ UnaryExpression(
1178
+ Identifier
1179
+ )
1180
+ ClassMemberAccess(
1181
+ Period
1182
+ Identifier
1183
+ )
1184
+ )
1185
+ Assignment
1186
+ UnaryExpression(
1187
+ UnaryExpression(
1188
+ Identifier
1189
+ )
1190
+ ArrayElementAccess(
1191
+ OpenBracket
1192
+ UnaryExpression(
1193
+ IntegerLiteral
1194
+ )
1195
+ CloseBracket
1196
+ )
1197
+ )
1198
+ )
1199
+ Semicolon
1200
+ )
1201
+ CloseBrace
1202
+ )
1203
+ )