ranger-compiler 2.1.70 → 3.0.3

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 (363) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +956 -133
  3. package/{compiler/Lang.clj → dist/Lang.rgr} +2345 -75
  4. package/dist/README.md +116 -0
  5. package/dist/{bin/api.d.ts → api.d.ts} +430 -154
  6. package/dist/api.js +34345 -0
  7. package/{lib/Ajax.clj → dist/lib/Ajax.rgr} +1 -1
  8. package/{lib/CmdParams.clj → dist/lib/CmdParams.rgr} +72 -72
  9. package/{lib/Crypto.clj → dist/lib/Crypto.rgr} +1 -1
  10. package/{lib/DOMLib.clj → dist/lib/DOMLib.rgr} +2 -2
  11. package/{lib/Engine3D.clj → dist/lib/Engine3D.rgr} +1 -1
  12. package/{lib/ImmutableVector.clj → dist/lib/ImmutableVector.rgr} +364 -364
  13. package/{lib/IndexedDB.clj → dist/lib/IndexedDB.rgr} +1 -1
  14. package/{lib/JSON.clj → dist/lib/JSON.rgr} +105 -2
  15. package/{lib/JinxProcess.clj → dist/lib/JinxProcess.rgr} +3 -3
  16. package/{lib/Storage.clj → dist/lib/Storage.rgr} +1 -1
  17. package/{lib/Timers.clj → dist/lib/Timers.rgr} +176 -170
  18. package/{lib/ViewLib.clj → dist/lib/ViewLib.rgr} +1 -1
  19. package/dist/lib/lib/ACEEditor.rgr +5 -0
  20. package/dist/lib/lib/Ajax.rgr +196 -0
  21. package/dist/lib/lib/CmdParams.rgr +72 -0
  22. package/dist/lib/lib/Crypto.rgr +90 -0
  23. package/dist/lib/lib/DOMLib.rgr +307 -0
  24. package/{examples/3D/Engine3D.clj → dist/lib/lib/Engine3D.rgr} +870 -857
  25. package/dist/lib/lib/ImmutableVector.rgr +364 -0
  26. package/dist/lib/lib/IndexedDB.rgr +32 -0
  27. package/{compiler/JSON.clj → dist/lib/lib/JSON.rgr} +106 -3
  28. package/dist/lib/lib/JinxProcess.rgr +838 -0
  29. package/dist/lib/lib/SQL.rgr +44 -0
  30. package/dist/lib/lib/ServiceLib.rgr +9 -0
  31. package/dist/lib/lib/Storage.rgr +89 -0
  32. package/dist/lib/lib/Time.rgr +75 -0
  33. package/dist/lib/lib/Timers.rgr +176 -0
  34. package/dist/lib/lib/TypedArrays.rgr +14 -0
  35. package/dist/lib/lib/ViewLib.rgr +851 -0
  36. package/dist/lib/lib/WebLib.rgr +47 -0
  37. package/dist/lib/lib/WebServerLib.rgr +137 -0
  38. package/{lib/ranger-dir.clj → dist/lib/lib/ranger-dir.rgr} +1 -1
  39. package/{compiler/stdlib.clj → dist/lib/lib/stdlib.rgr} +42 -19
  40. package/{lib/stdops.clj → dist/lib/lib/stdops.rgr} +1 -1
  41. package/dist/lib/ranger-dir.rgr +175 -0
  42. package/{lib/stdlib.clj → dist/lib/stdlib.rgr} +2 -2
  43. package/dist/lib/stdops.rgr +168 -0
  44. package/dist/package.json +47 -0
  45. package/{compiler/bin/output.js → dist/rgrc.js} +15377 -7936
  46. package/dist/stdops.rgr +168 -0
  47. package/package.json +196 -39
  48. package/adventofcode/day1/bin/LambdaSignature1.java +0 -3
  49. package/adventofcode/day1/bin/LambdaSignature2.java +0 -3
  50. package/adventofcode/day1/bin/LambdaSignature3.java +0 -3
  51. package/adventofcode/day1/bin/day1.cpp +0 -124
  52. package/adventofcode/day1/bin/day1.go +0 -75
  53. package/adventofcode/day1/bin/day1.js +0 -45
  54. package/adventofcode/day1/bin/day1.php +0 -46
  55. package/adventofcode/day1/bin/day1.scala +0 -48
  56. package/adventofcode/day1/bin/day1.swift +0 -48
  57. package/adventofcode/day1/bin/day1_part2.cpp +0 -180
  58. package/adventofcode/day1/bin/day1_part2.go +0 -123
  59. package/adventofcode/day1/bin/day1_part2.js +0 -76
  60. package/adventofcode/day1/bin/day1_part2.php +0 -88
  61. package/adventofcode/day1/bin/day1_part2.scala +0 -81
  62. package/adventofcode/day1/bin/day1_part2.swift +0 -91
  63. package/adventofcode/day1/bin/day_one.java +0 -38
  64. package/adventofcode/day1/bin/day_one_part_two.java +0 -57
  65. package/adventofcode/day1/bin/operatorsOf.java +0 -37
  66. package/adventofcode/day1/bin/operatorsOf_5.java +0 -10
  67. package/adventofcode/day1/bin/operatorsOfboolean_5.java +0 -10
  68. package/adventofcode/day1/bin/variant.hpp +0 -2416
  69. package/adventofcode/day1/compile.bat +0 -7
  70. package/adventofcode/day1/compile2.bat +0 -7
  71. package/adventofcode/day1/day1.clj +0 -19
  72. package/adventofcode/day1/day1_part2.clj +0 -43
  73. package/adventofcode/day1/input1.txt +0 -1
  74. package/adventofcode/day2/bin/LambdaSignature1.class +0 -0
  75. package/adventofcode/day2/bin/LambdaSignature1.java +0 -3
  76. package/adventofcode/day2/bin/LambdaSignature2.class +0 -0
  77. package/adventofcode/day2/bin/LambdaSignature2.java +0 -3
  78. package/adventofcode/day2/bin/day2.cpp +0 -133
  79. package/adventofcode/day2/bin/day2.go +0 -85
  80. package/adventofcode/day2/bin/day2.js +0 -45
  81. package/adventofcode/day2/bin/day2.php +0 -59
  82. package/adventofcode/day2/bin/day2.scala +0 -54
  83. package/adventofcode/day2/bin/day2.swift +0 -62
  84. package/adventofcode/day2/bin/day2_part2.cpp +0 -150
  85. package/adventofcode/day2/bin/day2_part2.go +0 -101
  86. package/adventofcode/day2/bin/day2_part2.js +0 -54
  87. package/adventofcode/day2/bin/day2_part2.php +0 -80
  88. package/adventofcode/day2/bin/day2_part2.scala +0 -68
  89. package/adventofcode/day2/bin/day2_part2.swift +0 -82
  90. package/adventofcode/day2/bin/day_two.java +0 -61
  91. package/adventofcode/day2/bin/day_two_part_two$1$1$1.class +0 -0
  92. package/adventofcode/day2/bin/day_two_part_two$1$1.class +0 -0
  93. package/adventofcode/day2/bin/day_two_part_two$1.class +0 -0
  94. package/adventofcode/day2/bin/day_two_part_two.class +0 -0
  95. package/adventofcode/day2/bin/day_two_part_two.java +0 -80
  96. package/adventofcode/day2/bin/operatorsOf.class +0 -0
  97. package/adventofcode/day2/bin/operatorsOf.java +0 -18
  98. package/adventofcode/day2/bin/variant.hpp +0 -2416
  99. package/adventofcode/day2/compile.bat +0 -7
  100. package/adventofcode/day2/compile2.bat +0 -7
  101. package/adventofcode/day2/day2.clj +0 -60
  102. package/adventofcode/day2/day2_part2.clj +0 -69
  103. package/adventofcode/day2/input1.txt +0 -1
  104. package/adventofcode/day3/bin/Grid.java +0 -92
  105. package/adventofcode/day3/bin/GridRow.java +0 -5
  106. package/adventofcode/day3/bin/LambdaSignature1.java +0 -3
  107. package/adventofcode/day3/bin/LambdaSignature2.java +0 -3
  108. package/adventofcode/day3/bin/LambdaSignature3.java +0 -3
  109. package/adventofcode/day3/bin/day3.cpp +0 -64
  110. package/adventofcode/day3/bin/day3.go +0 -55
  111. package/adventofcode/day3/bin/day3.js +0 -42
  112. package/adventofcode/day3/bin/day3.php +0 -41
  113. package/adventofcode/day3/bin/day3.scala +0 -52
  114. package/adventofcode/day3/bin/day3.swift +0 -43
  115. package/adventofcode/day3/bin/day3_part2.cpp +0 -216
  116. package/adventofcode/day3/bin/day3_part2.go +0 -188
  117. package/adventofcode/day3/bin/day3_part2.js +0 -123
  118. package/adventofcode/day3/bin/day3_part2.php +0 -135
  119. package/adventofcode/day3/bin/day3_part2.swift +0 -131
  120. package/adventofcode/day3/bin/day_three_part_two.java +0 -43
  121. package/adventofcode/day3/bin/day_two.java +0 -42
  122. package/adventofcode/day3/bin/operatorsOf.java +0 -14
  123. package/adventofcode/day3/bin/variant.hpp +0 -2416
  124. package/adventofcode/day3/compile.bat +0 -7
  125. package/adventofcode/day3/compile2.bat +0 -7
  126. package/adventofcode/day3/day3.clj +0 -42
  127. package/adventofcode/day3/day3_part2.clj +0 -112
  128. package/adventofcode/day4/bin/LambdaSignature1.java +0 -3
  129. package/adventofcode/day4/bin/day4.cpp +0 -118
  130. package/adventofcode/day4/bin/day4.go +0 -75
  131. package/adventofcode/day4/bin/day4.js +0 -40
  132. package/adventofcode/day4/bin/day4.php +0 -52
  133. package/adventofcode/day4/bin/day4.scala +0 -47
  134. package/adventofcode/day4/bin/day4.swift +0 -56
  135. package/adventofcode/day4/bin/day4_part2.go +0 -129
  136. package/adventofcode/day4/bin/day4_part2.js +0 -72
  137. package/adventofcode/day4/bin/day_four.java +0 -41
  138. package/adventofcode/day4/bin/inputData.java +0 -7
  139. package/adventofcode/day4/bin/operatorsOf.java +0 -11
  140. package/adventofcode/day4/bin/variant.hpp +0 -2416
  141. package/adventofcode/day4/compile.bat +0 -7
  142. package/adventofcode/day4/compile2.bat +0 -7
  143. package/adventofcode/day4/day4.clj +0 -32
  144. package/adventofcode/day4/day4_part2.clj +0 -44
  145. package/adventofcode/day4/input.clj +0 -519
  146. package/adventofcode/day4/input.txt +0 -512
  147. package/bin/api.ts +0 -24471
  148. package/bin/compiler.ts +0 -24482
  149. package/bin/output.js +0 -23819
  150. package/compiler/ColorConsole.clj +0 -22
  151. package/compiler/ContextOperators.clj +0 -75
  152. package/compiler/FlowEnterVarDef.clj +0 -223
  153. package/compiler/InputFileSystem.clj +0 -276
  154. package/compiler/RangerDocs.clj +0 -7
  155. package/compiler/TFactory.clj +0 -146
  156. package/compiler/TFiles.clj +0 -23
  157. package/compiler/TFlow.clj +0 -39
  158. package/compiler/TNodeFactory.clj +0 -84
  159. package/compiler/TTypes.clj +0 -188
  160. package/compiler/VirtualCompiler.clj +0 -807
  161. package/compiler/bin/ng_Compiler.js +0 -23779
  162. package/compiler/commonmark_plugin.clj +0 -359
  163. package/compiler/feat2.bat +0 -2
  164. package/compiler/feats.bat +0 -9
  165. package/compiler/feature_tests.clj +0 -192
  166. package/compiler/index.js +0 -2
  167. package/compiler/issue_57.clj +0 -25
  168. package/compiler/makefile_plugin.clj +0 -135
  169. package/compiler/markdown_plugin.clj +0 -386
  170. package/compiler/maven_plugin.clj +0 -162
  171. package/compiler/ng_AndroidPageWriter.clj +0 -299
  172. package/compiler/ng_CodeNode.clj +0 -756
  173. package/compiler/ng_CodeNodeCompilerExtensions.clj +0 -839
  174. package/compiler/ng_Compiler.clj +0 -49
  175. package/compiler/ng_CompilerGeneric.clj +0 -260
  176. package/compiler/ng_CompilerOrig.clj +0 -854
  177. package/compiler/ng_DictNode.clj +0 -346
  178. package/compiler/ng_DictNode2.clj +0 -316
  179. package/compiler/ng_Execute.clj +0 -138
  180. package/compiler/ng_Execute1.clj +0 -129
  181. package/compiler/ng_FlowWork.clj +0 -3951
  182. package/compiler/ng_LiveCompiler.clj +0 -1109
  183. package/compiler/ng_RagnerJavaScriptClassWriter.clj +0 -402
  184. package/compiler/ng_RangerActiveOperators.clj +0 -86
  185. package/compiler/ng_RangerAppClassDesc.clj +0 -400
  186. package/compiler/ng_RangerAppEnums.clj +0 -86
  187. package/compiler/ng_RangerAppFunctionDesc.clj +0 -127
  188. package/compiler/ng_RangerAppMessages.clj +0 -15
  189. package/compiler/ng_RangerAppOperatorDesc.clj +0 -20
  190. package/compiler/ng_RangerAppParamDesc.clj +0 -388
  191. package/compiler/ng_RangerAppWriterContext.clj +0 -1793
  192. package/compiler/ng_RangerArgMatch.clj +0 -638
  193. package/compiler/ng_RangerCSharpClassWriter.clj +0 -484
  194. package/compiler/ng_RangerCppClassWriter.clj +0 -1023
  195. package/compiler/ng_RangerDocGenerator.clj +0 -305
  196. package/compiler/ng_RangerFlowParser.clj +0 -4992
  197. package/compiler/ng_RangerFlowParserOrig.clj +0 -4002
  198. package/compiler/ng_RangerGenericClassWriter.clj +0 -573
  199. package/compiler/ng_RangerGolangClassWriter.clj +0 -1766
  200. package/compiler/ng_RangerImmutableExtension.clj +0 -77
  201. package/compiler/ng_RangerJava7ClassWriter.clj +0 -961
  202. package/compiler/ng_RangerJavaScriptClassWriter.clj +0 -1040
  203. package/compiler/ng_RangerKotlinClassWriter.clj +0 -372
  204. package/compiler/ng_RangerLanguageWriters.clj +0 -14
  205. package/compiler/ng_RangerLispParser.clj +0 -873
  206. package/compiler/ng_RangerPHPClassWriter.clj +0 -643
  207. package/compiler/ng_RangerPlugin.clj +0 -41
  208. package/compiler/ng_RangerRangerClassWriter.clj +0 -357
  209. package/compiler/ng_RangerRustClassWriter.clj +0 -420
  210. package/compiler/ng_RangerScalaClassWriter.clj +0 -818
  211. package/compiler/ng_RangerSerializeClass.clj +0 -502
  212. package/compiler/ng_RangerServiceBuilder.clj +0 -63
  213. package/compiler/ng_RangerSwift3ClassWriter.clj +0 -809
  214. package/compiler/ng_RangerSwiftClassWriter.clj +0 -0
  215. package/compiler/ng_RangerTypeClass.clj +0 -45
  216. package/compiler/ng_SourceParser.clj +0 -241
  217. package/compiler/ng_SourceParser2.clj +0 -214
  218. package/compiler/ng_WebPageWriter.clj +0 -39
  219. package/compiler/ng_jsonParser.clj +0 -340
  220. package/compiler/ng_p_test.clj +0 -1711
  221. package/compiler/ng_parser.clj +0 -911
  222. package/compiler/ng_parser2.clj +0 -735
  223. package/compiler/ng_parser2_backup.clj +0 -1679
  224. package/compiler/ng_parser_backup.clj +0 -886
  225. package/compiler/ng_parser_ok.clj +0 -1718
  226. package/compiler/ng_parser_ok2.clj +0 -1717
  227. package/compiler/ng_parser_std_match.clj +0 -687
  228. package/compiler/ng_parser_std_match2.clj +0 -1012
  229. package/compiler/ng_parser_v2.clj +0 -1251
  230. package/compiler/ng_ui.clj +0 -403
  231. package/compiler/ng_ui_test.clj +0 -18
  232. package/compiler/ng_writer.clj +0 -338
  233. package/compiler/ng_xmlParser.clj +0 -472
  234. package/compiler/ng_xmlParser2.clj +0 -317
  235. package/compiler/ng_xmlParser3.clj +0 -251
  236. package/compiler/opdoc.bat +0 -4
  237. package/compiler/operators.md +0 -290
  238. package/compiler/p.bat +0 -4
  239. package/compiler/package.json +0 -10
  240. package/compiler/pcmd.bat +0 -4
  241. package/compiler/pcmd2.bat +0 -3
  242. package/compiler/plaintext_plugin.clj +0 -69
  243. package/compiler/plugin.bat +0 -19
  244. package/compiler/plugin2.bat +0 -4
  245. package/compiler/plugin_app.bat +0 -3
  246. package/compiler/plugin_apps.clj +0 -27
  247. package/compiler/plugins.bat +0 -10
  248. package/compiler/reveal_plugin.clj +0 -409
  249. package/compiler/simplePlugin.clj +0 -780
  250. package/compiler/t.bat +0 -3
  251. package/compiler/test_any.clj +0 -43
  252. package/compiler/test_call.clj +0 -141
  253. package/compiler/test_chain.clj +0 -79
  254. package/compiler/test_json.clj +0 -10
  255. package/compiler/test_lambda.clj +0 -153
  256. package/compiler/test_pcmd.clj +0 -32
  257. package/compiler/test_pcmd2.clj +0 -29
  258. package/compiler/test_plugin.clj +0 -237
  259. package/compiler/test_readfile.clj +0 -13
  260. package/compiler/test_reveal.clj +0 -19
  261. package/compiler/test_slides.clj +0 -312
  262. package/compiler/test_types.clj +0 -143
  263. package/compiler/test_types2.clj +0 -49
  264. package/compiler/test_types3.clj +0 -53
  265. package/compiler/test_var.clj +0 -40
  266. package/compiler/tonpm.bat +0 -14
  267. package/compiler/tonpm2.bat +0 -12
  268. package/compiler/ui_plugin.clj +0 -507
  269. package/compiler/ui_plugin2.clj +0 -427
  270. package/compiler/update-git.bat +0 -3
  271. package/compiler/vcomp.bat +0 -4
  272. package/compiler/viewbuilder_Android.clj +0 -176
  273. package/compiler/viewbuilder_Web.clj +0 -105
  274. package/dist/bin/api.js +0 -32422
  275. package/dist/bin/compiler.d.ts +0 -1638
  276. package/dist/bin/compiler.js +0 -32444
  277. package/examples/3D/bin/test_3d.js +0 -329
  278. package/examples/3D/test_3d.clj +0 -385
  279. package/examples/EVGColor/EVGColor.clj +0 -310
  280. package/examples/EVGColor/EVGColorContext.clj +0 -176
  281. package/examples/EVGColor/bin/EVGColor.js +0 -286
  282. package/examples/EVGColor/bin/minimized.js +0 -286
  283. package/examples/SVGPath/SVGPath.clj +0 -625
  284. package/examples/SVGPath/Vec2.clj +0 -103
  285. package/examples/SVGPath/bin/SVGPath.cpp +0 -887
  286. package/examples/SVGPath/bin/SVGPath.js +0 -682
  287. package/examples/SVGPath/bin/SVGPath.ts +0 -711
  288. package/examples/SVGPath/bin/minimized.js +0 -578
  289. package/examples/SVGPath/bin/variant.hpp +0 -2416
  290. package/examples/minification/Vec2.clj +0 -103
  291. package/examples/minification/bin/minified.js +0 -44
  292. package/examples/minification/bin/test.js +0 -117
  293. package/examples/minification/test.clj +0 -13
  294. package/fiddle/VirtualCompiler.js +0 -23495
  295. package/fiddle/browser_editor.js +0 -13240
  296. package/fiddle/compileEnv.js +0 -1
  297. package/fiddle/compileEnv.json +0 -1
  298. package/fiddle/lang_data.js +0 -1
  299. package/index.html +0 -18
  300. package/native/httpd/HttpTester.clj +0 -33
  301. package/native/httpd/RangerWebService.clj +0 -81
  302. package/operators.md +0 -290
  303. package/tsconfig.json +0 -29
  304. package/versions/cpp/compiler.cpp +0 -15032
  305. package/versions/es6/compiler.js +0 -12860
  306. package/versions/go/compiler.go +0 -21338
  307. package/versions/java/AfterCodeNode.java +0 -4
  308. package/versions/java/ClassJoinPoint.java +0 -6
  309. package/versions/java/CodeFile.java +0 -42
  310. package/versions/java/CodeFileSystem.java +0 -72
  311. package/versions/java/CodeNode.java +0 -807
  312. package/versions/java/CodeSlice.java +0 -13
  313. package/versions/java/CodeWriter.java +0 -185
  314. package/versions/java/ColorConsole.java +0 -8
  315. package/versions/java/CompilerInterface.java +0 -213
  316. package/versions/java/DictNode.java +0 -353
  317. package/versions/java/LiveCompiler.java +0 -772
  318. package/versions/java/NodeEvalState.java +0 -24
  319. package/versions/java/OpFindResult.java +0 -6
  320. package/versions/java/RangerAppArrayValue.java +0 -7
  321. package/versions/java/RangerAppClassDesc.java +0 -217
  322. package/versions/java/RangerAppEnum.java +0 -14
  323. package/versions/java/RangerAppFunctionDesc.java +0 -20
  324. package/versions/java/RangerAppHashValue.java +0 -11
  325. package/versions/java/RangerAppInterfaceImpl.java +0 -6
  326. package/versions/java/RangerAppMethodVariants.java +0 -6
  327. package/versions/java/RangerAppParamDesc.java +0 -321
  328. package/versions/java/RangerAppTodo.java +0 -6
  329. package/versions/java/RangerAppValue.java +0 -10
  330. package/versions/java/RangerAppWriterContext.java +0 -800
  331. package/versions/java/RangerArgMatch.java +0 -317
  332. package/versions/java/RangerBackReference.java +0 -7
  333. package/versions/java/RangerCSharpClassWriter.java +0 -287
  334. package/versions/java/RangerCompilerMessage.java +0 -9
  335. package/versions/java/RangerCppClassWriter.java +0 -725
  336. package/versions/java/RangerFlowParser.java +0 -2142
  337. package/versions/java/RangerGenericClassWriter.java +0 -367
  338. package/versions/java/RangerGolangClassWriter.java +0 -1379
  339. package/versions/java/RangerJava7ClassWriter.java +0 -652
  340. package/versions/java/RangerJavaScriptClassWriter.java +0 -305
  341. package/versions/java/RangerKotlinClassWriter.java +0 -380
  342. package/versions/java/RangerLispParser.java +0 -845
  343. package/versions/java/RangerNodeValue.java +0 -9
  344. package/versions/java/RangerPHPClassWriter.java +0 -527
  345. package/versions/java/RangerParamEventHandler.java +0 -6
  346. package/versions/java/RangerParamEventList.java +0 -5
  347. package/versions/java/RangerParamEventMap.java +0 -27
  348. package/versions/java/RangerRangerClassWriter.java +0 -268
  349. package/versions/java/RangerRefForce.java +0 -7
  350. package/versions/java/RangerScalaClassWriter.java +0 -365
  351. package/versions/java/RangerSerializeClass.java +0 -148
  352. package/versions/java/RangerSwift3ClassWriter.java +0 -548
  353. package/versions/java/RangerTypeClass.java +0 -17
  354. package/versions/java/SourceCode.java +0 -65
  355. package/versions/php/compiler.php +0 -13830
  356. package/versions/swift3/compiler.swift +0 -12542
  357. /package/{lib/ACEEditor.clj → dist/lib/ACEEditor.rgr} +0 -0
  358. /package/{lib/SQL.clj → dist/lib/SQL.rgr} +0 -0
  359. /package/{lib/ServiceLib.clj → dist/lib/ServiceLib.rgr} +0 -0
  360. /package/{lib/Time.clj → dist/lib/Time.rgr} +0 -0
  361. /package/{lib/TypedArrays.clj → dist/lib/TypedArrays.rgr} +0 -0
  362. /package/{lib/WebLib.clj → dist/lib/WebLib.rgr} +0 -0
  363. /package/{lib/WebServerLib.clj → dist/lib/WebServerLib.rgr} +0 -0
@@ -1,1679 +0,0 @@
1
- (
2
-
3
- (Enum RangerNodeRefType:int (
4
- NoType
5
- ))
6
-
7
- (Enum RangerNodeType:int
8
- (
9
- NoType
10
- InvalidType
11
- Double
12
- Integer
13
- String
14
- Boolean
15
- Array
16
- Hash
17
- Object
18
- VRef
19
- Comment
20
- Enum
21
- Char
22
- CharBuffer
23
- Expression
24
- ExpressionType
25
- Lambda
26
- XMLNode
27
- XMLText
28
- XMLAttr
29
- XMLCDATA
30
- Dictionary
31
- Any
32
- Class
33
- GenericClass
34
- ClassRef
35
- Method
36
- ClassVar
37
- Function
38
- Literal
39
- Quasiliteral
40
- Null
41
- )
42
- )
43
-
44
- ( CreateClass CodeNode {
45
-
46
- (def code:SourceCode)
47
- (def sp:int 0)
48
- (def ep:int 0)
49
-
50
- (def has_operator:boolean false)
51
- (def op_index:int 0)
52
-
53
- ; could be also vref_annotation
54
- (def mutable_def:boolean false)
55
-
56
- (def expression:boolean false)
57
- (def vref:string "")
58
- (def is_block_node:boolean false) ; specifically marked as a block node
59
-
60
- (def infix_operator:boolean false) ; if we are collecting infix nodex like 4 + 2 * 10
61
- (def infix_node:CodeNode @weak(true))
62
- (def infix_subnode:boolean false)
63
-
64
- (def operator_pred:int 0)
65
- (def to_the_right:boolean false)
66
- (def right_node:CodeNode @weak(true))
67
-
68
- (def type_type:string "") ; hash, function, array ?
69
- (def type_name:string "")
70
- (def key_type:string "")
71
- (def array_type:string "")
72
-
73
- (def ns:[string])
74
-
75
- (def has_vref_annotation:boolean false)
76
- (def vref_annotation:CodeNode)
77
-
78
- (def has_type_annotation:boolean false)
79
- (def type_annotation:CodeNode)
80
-
81
- ; (def typeClass:RangerTypeClass @weak(true))
82
-
83
- (def value_type:RangerNodeType RangerNodeType.NoType)
84
-
85
- ; after node has been evaluated
86
- (def eval_type:RangerNodeType RangerNodeType.NoType)
87
- (def eval_type_name:string "")
88
- (def eval_key_type:string "")
89
- (def eval_array_type:string "")
90
-
91
- (def flow_done:boolean false)
92
- (def ref_change_done:boolean false)
93
-
94
- ; if the node references to object, if this reference is weak or not
95
- (def ref_type:RangerNodeRefType RangerNodeRefType.NoType)
96
- (def ref_need_assign:int 0)
97
-
98
- (def double_value:double 0.0)
99
- (def string_value:string "")
100
- (def int_value:int 1)
101
- (def boolean_value:boolean false )
102
- (def expression_value:CodeNode)
103
-
104
- (def props:[string:CodeNode])
105
- (def prop_keys:[string])
106
-
107
- (def comments:[CodeNode])
108
- (def children:[CodeNode])
109
- (def parent:CodeNode @weak(true))
110
-
111
- (def didReturnAtIndex:int -1)
112
-
113
- (def hasVarDef:boolean false)
114
- (def hasClassDescription:boolean false)
115
- (def hasNewOper:boolean false)
116
- (def hasFnCall:boolean false)
117
- (def hasParamDesc:boolean false)
118
-
119
- (Constructor (source:SourceCode start:int end:int)
120
- (
121
- (= sp start)
122
- (= ep end)
123
- (= code source)
124
- )
125
- )
126
-
127
- fn getCode:string () {
128
- return "--code--"
129
- }
130
-
131
- (PublicMethod isPrimitive:boolean ()
132
- (
133
- (if (||
134
- (== value_type RangerNodeType.Double)
135
- (== value_type RangerNodeType.String)
136
- (== value_type RangerNodeType.Integer)
137
- (== value_type RangerNodeType.Boolean)
138
- )
139
- (
140
- (return true)
141
- )
142
- )
143
- (return false)
144
- )
145
- )
146
-
147
- ( PublicMethod walk:void () (
148
-
149
- (switch value_type (
150
- (case RangerNodeType.Double {
151
- print "Double " + double_value
152
- })
153
- (case RangerNodeType.String
154
- (
155
- (print ( + "String : " string_value))
156
- )
157
- )
158
- (case RangerNodeType.Integer
159
- (
160
- (print ( + "Integer : " int_value))
161
- )
162
- )
163
- (case RangerNodeType.Boolean
164
- (
165
- (if boolean_value
166
- (print ( "Boolean : true "))
167
- (print ( "Boolean : false" ))
168
- )
169
- )
170
- )
171
- (case RangerNodeType.VRef
172
- (
173
- (print ( "VREF : " + vref + " : " + type_name))
174
- )
175
- )
176
- (case RangerNodeType.Array
177
- (
178
- (print ( "Array : " + vref + " : " + array_type))
179
-
180
- )
181
- )
182
- (case RangerNodeType.Hash
183
- (
184
- (print ( "Hash : " + vref + " : [" + key_type + ":" + array_type + "]"))
185
-
186
- )
187
- )
188
- (case RangerNodeType.ExpressionType
189
- (
190
- (print ( + "Expression type : " vref ))
191
- (print "----- expression starts ------")
192
- (expression_value.walk ())
193
- (print "----- expression ends ------")
194
- )
195
- )
196
- (case RangerNodeType.Comment
197
- (
198
- (print ( + "Comment : " string_value))
199
- )
200
- )
201
- (default {
202
-
203
- })
204
-
205
- )
206
-
207
- )
208
-
209
- (if expression
210
- (print "(")
211
- (print (substring code.code sp ep))
212
- )
213
-
214
- (for children item:CodeNode i
215
- (item.walk())
216
- )
217
-
218
- (if expression
219
- (print ")")
220
- )
221
-
222
-
223
- ))
224
-
225
-
226
-
227
- })
228
-
229
- (class SourceCode {
230
- def code:string ""
231
- def sp:int 0
232
- def ep:int 0
233
-
234
- (Constructor (code_str:string ) {
235
- code = code_str
236
- })
237
- })
238
-
239
-
240
- ( CreateClass RangerLispParser:void {
241
- (def code:SourceCode)
242
- (def buff:charbuffer)
243
- (def len:int 0)
244
- (def i:int 0)
245
- (def parents@(weak):[CodeNode] )
246
- (def next:CodeNode)
247
-
248
- (def paren_cnt:int 0)
249
- (def get_op_pred:int 0)
250
-
251
- (def rootNode:CodeNode )
252
- (def curr_node@(weak):CodeNode @weak(true) )
253
-
254
- (def had_error:boolean false)
255
-
256
-
257
- (Constructor (code_module:SourceCode )
258
- (
259
- (= buff (to_charbuffer code_module.code))
260
- (= code code_module)
261
-
262
- (= len (length (unwrap buff)))
263
-
264
- (= rootNode (new CodeNode ( (unwrap code) 0 0)))
265
- (= rootNode.is_block_node true)
266
- (= rootNode.expression true)
267
- (= curr_node rootNode)
268
- (push parents (unwrap curr_node))
269
- (= paren_cnt 1)
270
-
271
- )
272
- )
273
-
274
- ( PublicMethod getCode:string () {
275
- return (rootNode.getCode())
276
- })
277
-
278
-
279
- ( PublicMethod parse_raw_annotation:CodeNode () {
280
-
281
- (def sp:int i)
282
- (def ep:int i)
283
-
284
- ; skip annotation mark and continue
285
- (= i (+ i 1))
286
- (= sp i)
287
- (= ep i)
288
-
289
- (if (< i len) {
290
- ; parse new expression as variable type
291
- (def a_node2@(returnvalue):CodeNode (new CodeNode((unwrap code) sp ep)))
292
-
293
- (= a_node2.expression true)
294
- (= curr_node a_node2)
295
-
296
- (push parents a_node2)
297
- (= i (+ i 1))
298
- (= paren_cnt (+ paren_cnt 1))
299
-
300
- (this.parse())
301
-
302
- return a_node2
303
- } {
304
-
305
- }
306
- )
307
- return (new CodeNode((unwrap code) sp ep))
308
- })
309
-
310
- ( PublicMethod skip_space:boolean (is_block_parent : boolean) {
311
- (def s:charbuffer (unwrap buff))
312
- (def did_break:boolean false)
313
-
314
-
315
- (if (i >= len) {
316
- return true
317
- })
318
-
319
- (def c:char (charAt s i))
320
-
321
-
322
- def bb:boolean (== c (charcode "."))
323
-
324
- ; --> skipping of comma (== c (charcode ",")) removed
325
- (while ( && (< i len)
326
- (<= c 32 ) )
327
- (
328
-
329
- (if (&& is_block_parent (|| (== c 10) (== c 13) ))
330
- (
331
-
332
- (this.end_expression())
333
- (= did_break true)
334
- (break _)
335
- )
336
- )
337
-
338
- (= i (+ 1 i))
339
-
340
- (if (i >= len) {
341
- return true
342
- })
343
- (= c (charAt s i))
344
- )
345
- )
346
- return did_break
347
- }
348
- )
349
-
350
-
351
- ( PublicMethod end_expression:boolean () (
352
-
353
- (= i (+ 1 i))
354
- (if (i >= len) {
355
- return false
356
- })
357
-
358
- (= paren_cnt (- paren_cnt 1))
359
- (if (< paren_cnt 0)
360
- (print "Parser error ) mismatch")
361
- )
362
-
363
- (removeLast parents)
364
- (if (!null? curr_node)
365
- (
366
- (= curr_node.ep i)
367
- (= curr_node.infix_operator false)
368
- )
369
- )
370
-
371
- (if (> (array_length parents) 0)
372
- (
373
- (= curr_node (itemAt parents (- (array_length parents) 1 ) ))
374
- )
375
- (
376
- (= curr_node rootNode)
377
- )
378
- )
379
- (= curr_node.infix_operator false)
380
- (return true)
381
- ))
382
-
383
- (PublicMethod getOperator:int () {
384
-
385
- (def s:charbuffer (unwrap buff))
386
-
387
- if ( i + 2 >= len ) {
388
- return 0
389
- }
390
-
391
- def c:char (charAt s i)
392
- def c2:char (charAt s (+ i 1))
393
-
394
- switch c {
395
-
396
- case ( (charcode "*" ) ) {
397
- i = i + 1
398
- return 14
399
- }
400
-
401
- case ( (charcode "/" ) ) {
402
- i = i + 1
403
- return 14
404
- }
405
-
406
- case ( (charcode "+" ) ) {
407
- i = i + 1
408
- return 13
409
- }
410
-
411
- case ( (charcode "-" ) ) {
412
- i = i + 1
413
- return 13
414
- }
415
-
416
- case ( (charcode "<" ) ) {
417
- if (c2 == (charcode "=")) {
418
- i = i + 2
419
- return 11
420
- }
421
- i = i + 1
422
- return 11
423
- }
424
-
425
- case ( (charcode ">" ) ) {
426
- if (c2 == (charcode "=")) {
427
- i = i + 2
428
- return 11
429
- }
430
- i = i + 1
431
- return 11
432
- }
433
-
434
- case ( (charcode "!" ) ) {
435
- if (c2 == (charcode "=")) {
436
- i = i + 2
437
- return 10
438
- }
439
- return 0 ; currently negation not supported
440
- }
441
- case ( (charcode "=" ) ) {
442
- if (c2 == (charcode "=")) {
443
- i = i + 2
444
- return 10 ; == operator
445
- }
446
- i = i + 1
447
- return 3 ; assigment operator
448
- }
449
-
450
- case ( (charcode "&" ) ) {
451
- if (c2 == (charcode "&")) {
452
- i = i + 2
453
- return 6 ; && operator
454
- }
455
- return 0
456
- }
457
-
458
- case ( (charcode "|" ) ) {
459
- if (c2 == (charcode "|")) {
460
- i = i + 2
461
- return 5 ; && operator
462
- }
463
- return 0
464
- }
465
-
466
- default {
467
-
468
- }
469
-
470
- }
471
-
472
- return 0
473
- })
474
-
475
- (PublicMethod isOperator:int () {
476
-
477
- (def s:charbuffer (unwrap buff))
478
-
479
- if ( i - 2 > len ) {
480
- return 0
481
- }
482
-
483
- def c:char (charAt s i)
484
- def c2:char (charAt s (+ i 1))
485
-
486
- switch c {
487
-
488
- case ( (charcode "*" ) ) {
489
- return 1
490
- }
491
-
492
- case ( (charcode "/" ) ) {
493
- return 14
494
- }
495
-
496
- case ( (charcode "+" ) ) {
497
- return 13
498
- }
499
-
500
- case ( (charcode "-" ) ) {
501
- return 13
502
- }
503
-
504
- case ( (charcode "<" ) ) {
505
- if (c2 == (charcode "=")) {
506
- return 11
507
- }
508
- return 11
509
- }
510
-
511
- case ( (charcode ">" ) ) {
512
- if (c2 == (charcode "=")) {
513
- return 11
514
- }
515
- return 11
516
- }
517
-
518
- case ( (charcode "!" ) ) {
519
- if (c2 == (charcode "=")) {
520
- return 10
521
- }
522
- return 0 ; currently negation not supported
523
- }
524
- case ( (charcode "=" ) ) {
525
- if (c2 == (charcode "=")) {
526
- return 10 ; == operator
527
- }
528
- return 3 ; assigment operator
529
- }
530
-
531
- case ( (charcode "&" ) ) {
532
- if (c2 == (charcode "&")) {
533
- return 6 ; && operator
534
- }
535
- return 0
536
- }
537
-
538
- case ( (charcode "|" ) ) {
539
- if (c2 == (charcode "|")) {
540
- return 5 ; && operator
541
- }
542
- return 0
543
- }
544
- default {
545
-
546
- }
547
- }
548
-
549
- return 0
550
- })
551
-
552
-
553
- (PublicMethod getOperatorPred:int (str:string)
554
- {
555
-
556
- switch str {
557
- case ( "<" ) {
558
- return 11
559
- }
560
- case ( ">" ) {
561
- return 11
562
- }
563
- case ( "<=" ) {
564
- return 11
565
- }
566
- case ( ">=" ) {
567
- return 11
568
- }
569
- case ( "==" ) {
570
- return 10
571
- }
572
-
573
- case ( "!=" ) {
574
- return 10
575
- }
576
- case ( "=" ) {
577
- return 3
578
- }
579
- case "&&" {
580
- return 6
581
- }
582
- case "||" {
583
- return 5
584
- }
585
- case "+" {
586
- return 13
587
- }
588
-
589
- case "-" {
590
- return 13
591
- }
592
- case "*" {
593
- return 14
594
- }
595
- case "/" {
596
- return 14
597
- }
598
- default {
599
-
600
- }
601
- }
602
- return 0
603
- }
604
- )
605
- (PublicMethod insert_node:void (p_node@(strong lives):CodeNode) {
606
- def push_target:CodeNode curr_node
607
-
608
- if(curr_node.infix_operator) {
609
- push_target = curr_node.infix_node
610
- if(push_target.to_the_right) {
611
- push_target = push_target.right_node
612
- p_node.parent = push_target
613
- }
614
- }
615
- push push_target.children p_node
616
-
617
- })
618
-
619
- ( PublicMethod parse:void () (
620
-
621
- (def s:charbuffer (unwrap buff))
622
-
623
- @onError(
624
- (if (!null? curr_node)
625
- (
626
- (def line_index:int (call curr_node getLine ()))
627
- (= line_index (call curr_node getLine ()))
628
- (print (+ (call curr_node getFilename ()) " Line: " line_index))
629
- (print "Parser error close to")
630
- (print (call curr_node getLineString(line_index)))
631
-
632
- (= had_error true)
633
- )
634
- )
635
- )
636
-
637
- (def c:char (charAt s 0))
638
- (def next_c:char 0)
639
- (def fc:char 0)
640
-
641
- (def new_node:CodeNode)
642
-
643
- (def sp:int 0)
644
- (def ep:int 0)
645
-
646
- (def last_i:int 0)
647
- (def had_lf:boolean false)
648
-
649
- (while (< i len)
650
- (
651
-
652
- (if had_error (break _))
653
- ; (print i)
654
- (= last_i i)
655
-
656
- (def is_block_parent:boolean false)
657
-
658
- (if had_lf
659
- (
660
- (= had_lf false)
661
- (this.end_expression())
662
- (break _)
663
- )
664
- )
665
-
666
-
667
- (if (!null? curr_node)
668
- (
669
-
670
- (if (!null? curr_node.parent)
671
- (
672
- (def nodeParent:CodeNode curr_node.parent)
673
- (if nodeParent.is_block_node (
674
- (= is_block_parent true)
675
- ))
676
- )
677
- )
678
- )
679
- )
680
-
681
-
682
- ; comma expression
683
- ; (|| (<= (charAt s i) 32 ) (== (charAt s i) (charcode ","))
684
-
685
- ; original: (<= (charAt s i) 32 ) )
686
- ; new with comma: (|| (<= (charAt s i) 32 ) (== (charAt s i) (charcode ",")))
687
-
688
- (if (this.skip_space(is_block_parent)) {
689
- break _
690
- })
691
-
692
- (= had_lf false)
693
- (= c (charAt s i))
694
-
695
- (if (< i len)
696
- (
697
- (= c (charAt s i))
698
- (if (== c 59)
699
- (
700
- (= sp (+ i 1))
701
- ; read the comment
702
- (while ( && (< i len)
703
- (> (charAt s i) 31 ) )
704
- (
705
- ; (print "-- comment --")
706
- (= i (+ 1 i))
707
- )
708
- )
709
-
710
- (if (i >= len)
711
- (break _)
712
- )
713
-
714
- (= new_node (new CodeNode((unwrap code) sp i)))
715
- (= new_node.value_type RangerNodeType.Comment)
716
- (= new_node.string_value (substring s sp i))
717
- (push curr_node.comments (unwrap new_node))
718
-
719
- (continue _)
720
- ))
721
-
722
- ; NEW S-EXPRESSION STARTS HERE!!!!!
723
- (if (< i (- len 1))
724
- (
725
- (= fc (charAt s (+ i 1)))
726
- (if (||
727
- (== c 40)
728
- (== c (charcode "{")) ; support also braces for now
729
- (&& (== c 39) (== fc 40) )
730
- (&& (== c 96) (== fc 40) ) )
731
- (
732
- ; (print "Found ( ")
733
- (= paren_cnt (+ paren_cnt 1))
734
- (if (null? curr_node)
735
- (
736
- (= rootNode (new CodeNode((unwrap code) i i)))
737
- (= curr_node rootNode)
738
- (if (== c 96) (= curr_node.value_type RangerNodeType.Quasiliteral))
739
- (if (== c 39) (= curr_node.value_type RangerNodeType.Literal))
740
- (= curr_node.expression true)
741
- (push parents (unwrap curr_node))
742
- ; (print "-> new root node")
743
- )
744
- (
745
- (def new_qnode@(lives):CodeNode (new CodeNode((unwrap code) i i)))
746
- (if (== c 96) (= new_qnode.value_type RangerNodeType.Quasiliteral))
747
- (if (== c 39) (= new_qnode.value_type RangerNodeType.Literal))
748
- (= new_qnode.expression true)
749
-
750
- (this.insert_node(new_qnode))
751
- ; (push curr_node.children new_qnode)
752
- (push parents new_qnode) ; lifetime?
753
- (= curr_node new_qnode)
754
-
755
- ; (print "added a new child node")
756
- )
757
- )
758
- (if (== c (charcode "{"))
759
- (
760
- ( = curr_node.is_block_node true )
761
- )
762
- )
763
- (= i (+ 1 i))
764
- (this.parse())
765
- (continue _)
766
-
767
- ))
768
- )
769
- )
770
-
771
- (= sp i)
772
- (= ep i)
773
- (= fc (charAt s i))
774
-
775
- (if ( || ( && (== fc 45) (>= (charAt s (+ i 1)) 46) (<= (charAt s (+ i 1)) 57) )
776
- ( && (>= fc 48) (<= fc 57) ) )
777
- (
778
- ; (print "Found number ")
779
- (def is_double:boolean false)
780
- (= sp i)
781
- (= i (+ 1 i))
782
- (= c (charAt s i))
783
- (while ( && (< i len)
784
- ( || ( && (>= c 48) (<= c 57))
785
- ;( == c (charcode "e"))
786
- ;( == c (charcode "E"))
787
- ( == c (charcode "."))
788
- (&& (== i sp)
789
- ( || ( == c (charcode "+"))
790
- ( == c (charcode "-")) ) )
791
-
792
- )
793
- )
794
- (
795
- (if ( == c (charcode "."))
796
- (
797
- (= is_double true)
798
- )
799
- )
800
- (= i (+ 1 i))
801
- (= c (charAt s i))
802
- )
803
- )
804
- (= ep i)
805
-
806
- (def new_num_node:CodeNode (new CodeNode((unwrap code) sp ep)))
807
-
808
- (if is_double
809
- (
810
- (= new_num_node.value_type RangerNodeType.Double)
811
- (= new_num_node.double_value (unwrap (str2double (substring s sp ep))))
812
- )
813
- (
814
- (= new_num_node.value_type RangerNodeType.Integer)
815
- (= new_num_node.int_value (unwrap (str2int (substring s sp ep))))
816
- )
817
-
818
- )
819
-
820
-
821
- (this.insert_node(new_num_node))
822
- ; (push curr_node.children new_num_node)
823
- ; (print (call new_node getString ()))
824
- ; set type to number...
825
- (continue _ )
826
-
827
- ))
828
-
829
- ; if " then we have a string value
830
- (if (== fc 34)
831
- (
832
- ; (= i (+ i 1))
833
- (= sp (+ i 1))
834
- (= ep sp)
835
- (= c (charAt s i))
836
-
837
- (def must_encode:boolean false)
838
- ; find the end of ""
839
- (while (< i len)
840
- (
841
- (= i (+ 1 i))
842
- (= c (charAt s i))
843
- (if (== c 34)
844
- (break _)
845
- )
846
- (if (== c 92)
847
- (
848
- ; escape character after \...
849
- ; \"\"
850
- (= i (+ 1 i))
851
- (if (< i len)
852
- (
853
- (= must_encode true)
854
- (= c (charAt s i))
855
- )
856
- (break _)
857
- )
858
- )
859
- )
860
- )
861
- )
862
- (= ep i)
863
- (if (< i len)
864
- (
865
- (def encoded_str:string "")
866
- (if must_encode
867
- (
868
-
869
- (def orig_str:charbuffer (to_charbuffer (substring s sp ep)))
870
- (def str_length:int (length orig_str))
871
- (def ii:int 0)
872
-
873
- ; a bit slow algorithm, could be improved much faster by copying
874
- ; longer slices
875
- (while (< ii str_length)
876
- (
877
- (def cc:char (charAt orig_str ii))
878
-
879
- (if (== cc 92)
880
- (
881
- (def next_ch:char (charAt orig_str (+ ii 1)))
882
- (switch next_ch (
883
- (case 34 ( ( = encoded_str (+ encoded_str (strfromcode 34 ) ) ) ) )
884
- (case 92 ( ( = encoded_str (+ encoded_str (strfromcode 92 ) ) ) ) )
885
- (case 47 ( ( = encoded_str (+ encoded_str (strfromcode 47 ) ) ) ) )
886
-
887
- (case 98
888
- ( = encoded_str (+ encoded_str (strfromcode 8 ) ) )
889
- )
890
- (case 102
891
- ( = encoded_str (+ encoded_str (strfromcode 12 ) ) )
892
- )
893
- (case 110
894
- (
895
- ( = encoded_str (+ encoded_str (strfromcode 10 ) ) )
896
- )
897
-
898
- )
899
- (case 114
900
- ( = encoded_str (+ encoded_str (strfromcode 13 ) ) )
901
- )
902
- (case 116
903
- ( = encoded_str (+ encoded_str (strfromcode 9 ) ) )
904
- )
905
- (case 117
906
- (
907
- ;; \uxxxx
908
- ;; then have to create UTF encoded string using the hex values
909
- ;; TODO
910
- ( = ii (+ ii 4)) ; 2 + 4
911
- )
912
- )
913
- (default ())
914
- )
915
- )
916
- ( = ii (+ ii 2))
917
- )
918
- (
919
- ; add normal char to the string
920
- ( = encoded_str (+ encoded_str (substring orig_str ii (+ 1 ii))))
921
- ( = ii (+ ii 1))
922
- )
923
- )
924
- )
925
- )
926
- )
927
- )
928
-
929
- (def new_str_node:CodeNode (new CodeNode((unwrap code) sp ep)))
930
- (= new_str_node.value_type RangerNodeType.String)
931
-
932
- (if must_encode
933
- (= new_str_node.string_value encoded_str)
934
- (= new_str_node.string_value (substring s sp ep))
935
- )
936
-
937
- (this.insert_node(new_str_node))
938
- ;(push curr_node.children new_str_node)
939
-
940
- ; (print (call new_node getString ()))
941
- ; set type to number...
942
- (= i (+ 1 i))
943
- (continue _ )
944
-
945
- )
946
- )
947
- )
948
- ) ; if " " ends
949
-
950
- ; test for true / false
951
- (if ( && (== fc (charcode "t"))
952
- (== (charAt s (+ i 1)) (charcode "r"))
953
- (== (charAt s (+ i 2)) (charcode "u"))
954
- (== (charAt s (+ i 3)) (charcode "e")) )
955
- (
956
-
957
- (def new_true_node:CodeNode (new CodeNode((unwrap code) sp (+ sp 4))))
958
- (= new_true_node.value_type RangerNodeType.Boolean)
959
- (= new_true_node.boolean_value true)
960
-
961
- (this.insert_node(new_true_node))
962
- ; (push curr_node.children new_true_node)
963
-
964
- (= i (+ i 4))
965
- (continue _)
966
- )
967
- )
968
-
969
- (if ( && (== fc (charcode "f"))
970
- (== (charAt s (+ i 1)) (charcode "a"))
971
- (== (charAt s (+ i 2)) (charcode "l"))
972
- (== (charAt s (+ i 3)) (charcode "s"))
973
- (== (charAt s (+ i 4)) (charcode "e")) )
974
- (
975
-
976
-
977
- (def new_f_node:CodeNode (new CodeNode((unwrap code) sp (+ sp 5))))
978
- (= new_f_node.value_type RangerNodeType.Boolean)
979
- (= new_f_node.boolean_value false)
980
-
981
- (this.insert_node(new_f_node))
982
- ; (push curr_node.children new_f_node)
983
-
984
- (= i (+ i 5))
985
- (continue _)
986
- )
987
- )
988
-
989
- ; expression annotation...
990
- ; @prop(true)
991
- (if (== fc (charcode "@"))
992
- (
993
- ; skip annotation mark and continue
994
- (= i (+ i 1))
995
- (= sp i)
996
- (= ep i)
997
- (= c (charAt s i))
998
-
999
- ; read the annontation element
1000
- (while ( && (< i len)
1001
- (> (charAt s i) 32 )
1002
- (!= c 40)
1003
- (!= c 41)
1004
- (!= c (charcode "}"))
1005
-
1006
- )
1007
- (
1008
- ; (print (+ "char:" c))
1009
- (= i (+ 1 i))
1010
- (= c (charAt s i))
1011
- )
1012
- )
1013
- (= ep i)
1014
-
1015
- (if (&& (< i len) (> ep sp) )
1016
- (
1017
- ; parse new expression as variable type
1018
- (def a_node2@(lives):CodeNode (new CodeNode((unwrap code) sp ep)))
1019
- (def a_name:string (substring s sp ep))
1020
-
1021
- (= a_node2.expression true)
1022
- (= curr_node a_node2)
1023
-
1024
- (push parents a_node2)
1025
- (= i (+ i 1))
1026
- (= paren_cnt (+ paren_cnt 1))
1027
-
1028
- (this.parse())
1029
-
1030
- @todo("add get strong reference from array")
1031
- ; the branching is mildly proglematic...
1032
- (def use_first:boolean false)
1033
- (if (== 1 (array_length a_node2.children))
1034
- (
1035
- (def ch1:CodeNode (itemAt a_node2.children 0))
1036
- (= use_first (ch1.isPrimitive()))
1037
- )
1038
- )
1039
- (if use_first
1040
- (
1041
- (def theNode:CodeNode (array_extract a_node2.children 0))
1042
- (set curr_node.props a_name theNode)
1043
- )(
1044
- (set curr_node.props a_name a_node2)
1045
- )
1046
- )
1047
-
1048
- (push curr_node.prop_keys a_name)
1049
- (continue _)
1050
-
1051
- )
1052
- )
1053
- )
1054
- )
1055
-
1056
- ; collect namespaces like obj.foo.x into separate array
1057
- ; ["obj", "foo", "x"]
1058
- (def ns_list:[string])
1059
- (def last_ns:int i)
1060
- (def ns_cnt:int 1)
1061
-
1062
- (def vref_had_type_ann:boolean false)
1063
- (def vref_ann_node:CodeNode )
1064
- (def vref_end:int i)
1065
-
1066
- ; collect the reference symbol.
1067
- ; change: if the parent node is a block node the reference is interpreted
1068
- ; as a new S-expression
1069
- (if ( && (< i len)
1070
- (> (charAt s i) 32 )
1071
- (!= c 58)
1072
- (!= c 40)
1073
- (!= c 41)
1074
- (!= c (charcode "}"))
1075
-
1076
- )
1077
- (
1078
- ; if reference symbol is observed in block node, make it a call immediately
1079
- (if (== curr_node.is_block_node true)
1080
- (
1081
- (def new_expr_node:CodeNode (new CodeNode((unwrap code) sp ep)))
1082
- (= new_expr_node.parent curr_node)
1083
- (= new_expr_node.expression true)
1084
- (push curr_node.children new_expr_node)
1085
- (= curr_node new_expr_node)
1086
- (push parents new_expr_node)
1087
- (= paren_cnt (+ 1 paren_cnt))
1088
-
1089
- (this.parse())
1090
- (continue _)
1091
- )
1092
- )
1093
- )
1094
- )
1095
-
1096
- ; op check
1097
-
1098
- (def op_c:int 0)
1099
- (if (>= (array_length curr_node.children) 0)
1100
- (
1101
- (= op_c (this.getOperator()))
1102
- )
1103
- )
1104
-
1105
- (def last_was_newline:boolean false)
1106
- (if (> op_c 0)
1107
- (
1108
- ; (print "--> found operator !!!")
1109
- )
1110
- (
1111
- (while ( && (< i len)
1112
- (> (charAt s i) 32 )
1113
- (!= c 58)
1114
- (!= c 40)
1115
- (!= c 41)
1116
- (!= c (charcode "}"))
1117
-
1118
- )
1119
- (
1120
-
1121
- (if (> i sp)
1122
- (
1123
- (def is_opchar:int (this.isOperator()))
1124
- (if (> is_opchar 0)
1125
- (
1126
- ; (print (+ "opchar around " (substring s last_ns (+ i 1))))
1127
- (break _)
1128
- )
1129
- )
1130
- )
1131
- )
1132
-
1133
- ; (print (+ "char:" c))
1134
- (= i (+ 1 i))
1135
- (= c (charAt s i))
1136
-
1137
- (if ( || (== c 10) (== c 13))
1138
- (
1139
- (= last_was_newline true)
1140
- (break _)
1141
- )
1142
- )
1143
-
1144
-
1145
- ; obj.
1146
- (if (== c (charcode "."))
1147
- (
1148
- (push ns_list (substring s last_ns i))
1149
- (= last_ns (+ i 1))
1150
- (= ns_cnt (+ 1 ns_cnt))
1151
- )
1152
- )
1153
-
1154
- (if ( && ( > i vref_end ) (== c (charcode "@")) )
1155
- (
1156
- (= vref_had_type_ann true)
1157
- (= vref_end i)
1158
- (= vref_ann_node (this.parse_raw_annotation ()))
1159
- ; (print "found annotation node")
1160
- (= c (charAt s i))
1161
- (break _)
1162
- )
1163
- )
1164
- )
1165
- )
1166
-
1167
- )
1168
- )
1169
-
1170
- (= ep i)
1171
-
1172
- (if vref_had_type_ann
1173
- (
1174
- (= ep vref_end)
1175
- )
1176
- )
1177
- (push ns_list (substring s last_ns ep))
1178
-
1179
-
1180
- ;(if (skip_space is_block_parent)
1181
- ; (break _)
1182
- ;)
1183
- ;(= c (charAt s i))
1184
-
1185
- ; skip empty space
1186
- (= c (charAt s i))
1187
- (while ( && (< i len)
1188
- (<= c 32 )
1189
- (== false last_was_newline)
1190
- )
1191
- (
1192
- ; (print "-- space --")
1193
- (= i (+ 1 i))
1194
- (= c (charAt s i))
1195
-
1196
- ; no newlines allowed here...
1197
- ;
1198
- (if (&& is_block_parent ( || (== c 10) (== c 13)))
1199
- (
1200
- (= i (- i 1))
1201
- (= c (charAt s i))
1202
- (= had_lf true)
1203
- (break _)
1204
- )
1205
- )
1206
- )
1207
- )
1208
-
1209
- ; : found, i:int or similar, variable type definition comes here
1210
- (if (== c 58)
1211
- (
1212
- ; (print "==> variable type")
1213
- (= i (+ i 1))
1214
-
1215
- ; skip whitespace
1216
- (while ( && (< i len) (<= (charAt s i) 32 ) ) (= i (+ 1 i)) )
1217
-
1218
- ; type definition start, end
1219
- (def vt_sp:int i)
1220
- (def vt_ep:int i)
1221
-
1222
- (= c (charAt s i))
1223
-
1224
- ; if variable type is function declaration like
1225
- ; (def f:(_:int(_:int _int)))
1226
- (if (== c (charcode "("))
1227
- (
1228
- ; parse new expression as variable type
1229
- (def a_node3@(lives):CodeNode (new CodeNode((unwrap code) sp ep)))
1230
- (= a_node3.expression true)
1231
- (= curr_node a_node3)
1232
-
1233
- (push parents a_node3)
1234
- (= i (+ i 1))
1235
-
1236
- (this.parse())
1237
-
1238
- (def new_expr_node:CodeNode (new CodeNode((unwrap code) sp vt_ep)))
1239
- (= new_expr_node.vref (substring s sp ep))
1240
- (= new_expr_node.ns ns_list)
1241
- (= new_expr_node.expression_value a_node3)
1242
- (= new_expr_node.value_type RangerNodeType.ExpressionType)
1243
-
1244
- (if vref_had_type_ann
1245
- (
1246
- (= new_expr_node.vref_annotation vref_ann_node)
1247
- (= new_expr_node.has_vref_annotation true)
1248
- )
1249
- )
1250
- (push curr_node.children new_expr_node)
1251
-
1252
- (continue _)
1253
-
1254
- )
1255
- )
1256
-
1257
- (if (== c (charcode "["))
1258
- (
1259
- ; handle start of array
1260
- (= i (+ i 1))
1261
- (= vt_sp i)
1262
-
1263
- (def hash_sep:int 0)
1264
- (def had_array_type_ann:boolean false)
1265
- (= c (charAt s i))
1266
- (while (&& (< i len) (> c 32)
1267
- (!= c 93) )
1268
- (
1269
- (= i (+ 1 i))
1270
- (= c (charAt s i))
1271
- (if (== c (charcode ":"))
1272
- (
1273
- (= hash_sep i)
1274
- )
1275
- )
1276
-
1277
- (if (== c (charcode "@"))
1278
- (
1279
- (= had_array_type_ann true)
1280
- (break _)
1281
- )
1282
- )
1283
- )
1284
- )
1285
- (= vt_ep i)
1286
- (if (> hash_sep 0)
1287
- (
1288
- ; hash
1289
- ; (print "Found HASH type")
1290
- ; (print (substring s sp ep))
1291
- (= vt_ep i)
1292
- (def type_name:string (substring s (+ 1 hash_sep) vt_ep))
1293
- (def key_type_name:string (substring s vt_sp hash_sep))
1294
-
1295
- ; also add namespace....
1296
- (def new_hash_node:CodeNode (new CodeNode((unwrap code) sp vt_ep)))
1297
- (= new_hash_node.vref (substring s sp ep))
1298
- (= new_hash_node.ns ns_list)
1299
- (= new_hash_node.value_type RangerNodeType.Hash)
1300
-
1301
- (= new_hash_node.array_type type_name)
1302
- (= new_hash_node.key_type key_type_name)
1303
-
1304
- (if vref_had_type_ann
1305
- (
1306
- (= new_hash_node.vref_annotation vref_ann_node)
1307
- (= new_hash_node.has_vref_annotation true)
1308
- )
1309
- )
1310
-
1311
- (if had_array_type_ann
1312
- (
1313
- (def vann_hash:CodeNode (this.parse_raw_annotation ()))
1314
- (= new_hash_node.type_annotation vann_hash)
1315
- (= new_hash_node.has_type_annotation true)
1316
- (print "--> parsed HASH TYPE annotation")
1317
- )
1318
- )
1319
-
1320
- (= new_hash_node.parent curr_node)
1321
- (push curr_node.children new_hash_node)
1322
- ; (print new_node.vref)
1323
- (= i (+ 1 i))
1324
- (continue _)
1325
-
1326
- )
1327
- (
1328
- ; array
1329
- (= vt_ep i)
1330
- (def type_name:string (substring s vt_sp vt_ep))
1331
- ; (print type_name)
1332
- ; also add namespace....
1333
- (def new_arr_node:CodeNode (new CodeNode((unwrap code) sp vt_ep)))
1334
- (= new_arr_node.vref (substring s sp ep))
1335
- (= new_arr_node.ns ns_list)
1336
- (= new_arr_node.value_type RangerNodeType.Array)
1337
-
1338
- (= new_arr_node.array_type type_name)
1339
- (= new_arr_node.parent curr_node)
1340
- (push curr_node.children new_arr_node)
1341
-
1342
-
1343
- (if vref_had_type_ann
1344
- (
1345
- (= new_arr_node.vref_annotation vref_ann_node)
1346
- (= new_arr_node.has_vref_annotation true)
1347
- )
1348
- )
1349
-
1350
- (if had_array_type_ann
1351
- (
1352
- (def vann_arr:CodeNode (this.parse_raw_annotation ()))
1353
- (= new_arr_node.type_annotation vann_arr)
1354
- (= new_arr_node.has_type_annotation true)
1355
- (print "--> parsed ARRAY TYPE annotation")
1356
- )
1357
- )
1358
-
1359
- (= i (+ 1 i))
1360
- (continue _)
1361
-
1362
- )
1363
- )
1364
- )
1365
- )
1366
-
1367
- ; parse normal type like :int, :double etc.
1368
- (def had_type_ann:boolean false)
1369
- (while ( && (< i len)
1370
- (> (charAt s i) 32 )
1371
- (!= c 58)
1372
- (!= c 40)
1373
- (!= c 41)
1374
- (!= c (charcode "}"))
1375
- (!= c (charcode ","))
1376
-
1377
- )
1378
- (
1379
- ; (print (+ "char:" c))
1380
- (= i (+ 1 i))
1381
- (= c (charAt s i))
1382
-
1383
- (if (== c (charcode "@"))
1384
- (
1385
- (= had_type_ann true)
1386
- ;(= i (- i 1))
1387
- (break _)
1388
- )
1389
- )
1390
- )
1391
- )
1392
- (if (< i len)
1393
- (
1394
- (= vt_ep i)
1395
- (def type_name:string (substring s vt_sp vt_ep))
1396
-
1397
- ; if current node is a block node then the expression will be the first child of
1398
- ; a new S-expression
1399
-
1400
- ; also add namespace....
1401
- (def new_ref_node:CodeNode (new CodeNode((unwrap code) sp ep)))
1402
- (= new_ref_node.vref (substring s sp ep))
1403
- (= new_ref_node.ns ns_list)
1404
- (= new_ref_node.value_type RangerNodeType.VRef)
1405
- (= new_ref_node.type_name (substring s vt_sp vt_ep))
1406
- (= new_ref_node.parent curr_node)
1407
-
1408
- (if vref_had_type_ann
1409
- (
1410
- (= new_ref_node.vref_annotation vref_ann_node)
1411
- (= new_ref_node.has_vref_annotation true)
1412
- )
1413
- )
1414
-
1415
- ; (print (+ "Found type " new_node.type_name))
1416
- (push curr_node.children new_ref_node)
1417
- (if had_type_ann
1418
- (
1419
- (def vann:CodeNode (this.parse_raw_annotation ()))
1420
- (= new_ref_node.type_annotation vann)
1421
- (= new_ref_node.has_type_annotation true)
1422
- ; (print "--> parsed TYPE annotation")
1423
- )
1424
- )
1425
- (continue _)
1426
- )
1427
- )
1428
- )
1429
- (
1430
- ; variable without a type definition
1431
-
1432
- ; (= c (charAt s i))
1433
-
1434
- (if ( && (< i len) (> ep sp) )
1435
- (
1436
- (def new_vref_node:CodeNode (new CodeNode((unwrap code) sp ep)))
1437
- (= new_vref_node.vref (substring s sp ep))
1438
- (= new_vref_node.value_type RangerNodeType.VRef)
1439
- (= new_vref_node.ns ns_list)
1440
- (= new_vref_node.parent curr_node)
1441
-
1442
- ; test if this is operator
1443
- (def op_pred:int (this.getOperatorPred(new_vref_node.vref)))
1444
-
1445
- ; comma will stop the infix processing...
1446
-
1447
- (if (== new_vref_node.vref ",")
1448
- (
1449
- (= curr_node.infix_operator false)
1450
- (continue _)
1451
- )
1452
- )
1453
-
1454
- ; TODO: check the IF below...
1455
- (def pTarget:CodeNode curr_node)
1456
- (if curr_node.infix_operator {
1457
- pTarget = curr_node.infix_node
1458
- if( op_pred == 0 && pTarget.to_the_right) {
1459
- def rn:CodeNode pTarget.right_node
1460
- new_vref_node.parent = rn
1461
- pTarget = rn
1462
- }
1463
- })
1464
-
1465
- (push pTarget.children new_vref_node)
1466
-
1467
-
1468
- (if vref_had_type_ann
1469
- (
1470
- ; (def vann:CodeNode (this.parse_raw_annotation ()))
1471
- (= new_vref_node.vref_annotation vref_ann_node)
1472
- (= new_vref_node.has_vref_annotation true)
1473
- ; (print "--> had a normal vref annotation")
1474
- ; (print (substring s sp ep))
1475
- )
1476
- )
1477
-
1478
- ; call operator consideration here, not implemented because it is hard if not impossible to determine
1479
- ; if the expression is starting simply a new list or is it actually a call.
1480
- (if ( || (== (charAt s (+ i 1)) (charcode "(") ) (== (charAt s (+ i 0)) (charcode "(")) )
1481
- (
1482
- (if ( && (== 0 op_pred) curr_node.infix_operator (== 1 (array_length curr_node.children)))
1483
- (
1484
- ; TODO: consider options for call operator here.
1485
- )
1486
- )
1487
- )
1488
- )
1489
-
1490
-
1491
- (if ( || ( && (> op_pred 0) curr_node.infix_operator) ( && (> op_pred 0) (>= (array_length curr_node.children) 2) ) )
1492
- (
1493
-
1494
- ; assigment operator...
1495
- (if ( && (== op_pred 3) ( == 2 (array_length curr_node.children) ) )
1496
- (
1497
- ; just swap the first and second node...
1498
- (def n_ch:CodeNode (array_extract curr_node.children 0))
1499
- (push curr_node.children n_ch)
1500
-
1501
- )
1502
- (
1503
-
1504
- (if (== false curr_node.infix_operator)
1505
- (
1506
- ; (print "we should create a new infix_operator node right here...")
1507
- (def if_node:CodeNode (new CodeNode((unwrap code) sp ep)))
1508
- (= curr_node.infix_node if_node)
1509
- (= curr_node.infix_operator true)
1510
- (= if_node.infix_subnode true)
1511
-
1512
- (= curr_node.value_type RangerNodeType.NoType)
1513
- (= curr_node.expression true)
1514
-
1515
- (= if_node.expression true)
1516
-
1517
- ; move the nodes to the infix node and use that node instead
1518
- (def ch_cnt:int (array_length curr_node.children))
1519
- (def ii:int 0)
1520
- (def start_from:int (- ch_cnt 2))
1521
- ; possible memory leak:
1522
- (def keep_nodes:CodeNode (new CodeNode((unwrap code) sp ep)))
1523
- (while (> ch_cnt 0)
1524
- (
1525
- (def n_ch:CodeNode (array_extract curr_node.children 0))
1526
- (def p_target:CodeNode if_node)
1527
- (if ( || (< ii start_from) n_ch.infix_subnode )
1528
- ( = p_target keep_nodes)
1529
- )
1530
- (push p_target.children n_ch)
1531
- (= ch_cnt (- ch_cnt 1))
1532
- (= ii (+ 1 ii))
1533
- )
1534
- )
1535
- (for keep_nodes.children keep:CodeNode i
1536
- (
1537
- (push curr_node.children keep)
1538
- )
1539
- )
1540
- (push curr_node.children if_node)
1541
- ; infix_node
1542
- )
1543
- )
1544
-
1545
- (def ifNode:CodeNode curr_node.infix_node)
1546
-
1547
- ; (print ( + "operator" new_vref_node.vref " close to") )
1548
- ; (def c_line_index:int (call curr_node getLine ()))
1549
- ; (print (call curr_node getLineString(c_line_index)))
1550
- ; (print (+ "now has " (array_length curr_node.children) " nodes "))
1551
-
1552
-
1553
- (def new_op_node:CodeNode (new CodeNode((unwrap code) sp ep)))
1554
- (= new_op_node.expression true)
1555
- (= new_op_node.parent ifNode)
1556
-
1557
- (def until_index:int (- (array_length ifNode.children) 1))
1558
- (def to_right:boolean false)
1559
- (def just_continue:boolean false)
1560
-
1561
- (if ( && (> ifNode.operator_pred 0) ( < ifNode.operator_pred op_pred) )
1562
- (
1563
- (= to_right true)
1564
- )
1565
- )
1566
-
1567
- (if ( && (> ifNode.operator_pred 0) ( > ifNode.operator_pred op_pred) )
1568
- (
1569
- (= ifNode.to_the_right false)
1570
- )
1571
- )
1572
-
1573
- (if ( && (> ifNode.operator_pred 0) ( == ifNode.operator_pred op_pred) )
1574
- (
1575
- (= to_right ifNode.to_the_right)
1576
- )
1577
- )
1578
-
1579
- (def opTarget:CodeNode ifNode)
1580
- (if to_right
1581
- (
1582
- ; 3 * 4 + 5 * 7
1583
- (def op_node:CodeNode (array_extract ifNode.children until_index))
1584
- (def last_value:CodeNode (array_extract ifNode.children (- until_index 1)))
1585
-
1586
- (push new_op_node.children op_node)
1587
- (push new_op_node.children last_value)
1588
-
1589
- (= ifNode.right_node new_op_node)
1590
- (= ifNode.to_the_right true)
1591
-
1592
- )
1593
- (
1594
- (if (== false just_continue)
1595
- (
1596
- (while (> until_index 0)
1597
- (
1598
- (def what_to_add:CodeNode (array_extract ifNode.children 0))
1599
- (push new_op_node.children what_to_add)
1600
- (= until_index (- until_index 1))
1601
- )
1602
- )
1603
- )
1604
- )
1605
- )
1606
- )
1607
- (push opTarget.children new_op_node)
1608
-
1609
- (= ifNode.operator_pred op_pred)
1610
- (continue _)
1611
-
1612
-
1613
- )
1614
- )
1615
-
1616
-
1617
-
1618
- )
1619
- )
1620
-
1621
- (continue _)
1622
- )
1623
- )
1624
- )
1625
- )
1626
-
1627
- (if ( || (== c 41) (== c (charcode "}")) )
1628
- (
1629
- ; } is the same as newline and if we have { return "foobar" } it is required to end the current expression first
1630
- (if (&& (== c (charcode "}")) is_block_parent ( > (array_length curr_node.children) 0) )
1631
- (
1632
- (this.end_expression())
1633
- )
1634
- )
1635
-
1636
- ; (print "Found ) ")
1637
- (= i (+ 1 i))
1638
- (= paren_cnt (- paren_cnt 1))
1639
- (if (< paren_cnt 0) {
1640
- ; was throwing exception here...
1641
- break _
1642
- })
1643
-
1644
- (removeLast parents)
1645
- (if (!null? curr_node)
1646
- (= curr_node.ep i)
1647
- )
1648
-
1649
- (if (> (array_length parents) 0)
1650
- (
1651
- (= curr_node (itemAt parents (- (array_length parents) 1 ) ))
1652
- )
1653
- (
1654
- (= curr_node rootNode)
1655
- )
1656
- )
1657
- (break _)
1658
-
1659
- ))
1660
-
1661
- (if (== last_i i)
1662
- (= i (+ 1 i))
1663
- )
1664
- )
1665
- )
1666
-
1667
- )
1668
- )
1669
-
1670
- )
1671
- }
1672
- )
1673
- )
1674
-
1675
-
1676
-
1677
-
1678
-
1679
-