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,1251 +0,0 @@
1
-
2
- Import "ng_CodeNode.clj"
3
-
4
- operator type:void all {
5
-
6
- fn is_not_limiter:boolean (c:char) {
7
- return ( (c > 32 ) &&
8
- (c != (ccode ";")) &&
9
- (c != (ccode ")")) &&
10
- (c != (ccode "(")) &&
11
- (c != (ccode "}")) &&
12
- (c != (ccode ",")) )
13
- }
14
- }
15
-
16
- class RangerLispParser {
17
-
18
- def code@(optional):SourceCode
19
- def buff@(optional):charbuffer
20
- def len:int 0
21
- def i:int 0
22
- def last_line_start 0
23
- def current_line_index 0
24
- def parents@(weak):[CodeNode]
25
- def next@(optional):CodeNode
26
- def paren_cnt:int 0
27
- def get_op_pred:int 0
28
- def rootNode@(optional):CodeNode
29
- def curr_node@(optional weak):CodeNode
30
- def had_error:boolean false
31
- def disableOperators false
32
-
33
- Constructor ( code_module:SourceCode ) {
34
- buff = (to_charbuffer code_module.code)
35
- code = code_module
36
- len = (length (( unwrap buff)))
37
- rootNode = (new CodeNode(( unwrap code) 0 0))
38
- rootNode.is_block_node = true
39
- rootNode.expression = true
40
- curr_node = rootNode
41
- push parents ( unwrap curr_node)
42
- paren_cnt = 1
43
- }
44
-
45
- fn joo:void ( cm@(lives):SourceCode) {
46
- def ll:int ( strlen cm.code)
47
- }
48
-
49
- fn parse_raw_annotation:CodeNode () {
50
- def sp:int i
51
- def ep:int i
52
- i = i + 1
53
- sp = i
54
- ep = i
55
- if (i < len ) {
56
- def a_node2@(returnvalue):CodeNode (new CodeNode(( unwrap code) sp ep))
57
- a_node2.expression = true
58
- a_node2.row = current_line_index
59
- curr_node = a_node2
60
- push parents a_node2
61
- i = i + 1
62
- paren_cnt = paren_cnt + 1
63
- this.parse(false)
64
- return a_node2
65
- } {
66
- }
67
- return (new CodeNode(( unwrap code) sp ep))
68
- }
69
-
70
- fn skip_space:boolean ( is_block_parent@(lives):boolean) {
71
- def s:charbuffer ( unwrap buff)
72
- def did_break:boolean false
73
- if (i >= len) {
74
- return true
75
- }
76
- def c:char (charAt s i)
77
- def bb:boolean c == ((ccode "."))
78
- while ((i < len) && (c <= 32)) {
79
- if( c < 8 ) {
80
- i = len
81
- return true
82
- ; throw "Invalid string"
83
- }
84
- if (is_block_parent && ((c == 10) || (c == 13))) {
85
- this.end_expression()
86
- current_line_index = current_line_index + 1
87
- did_break = true
88
- break
89
- }
90
- ; current_line_index = current_line_index + 1
91
- def had_break false
92
- while( (i < len ) && c == 10 || c == 13) {
93
- had_break = true
94
- i = i + 1
95
- if (i >= len) {
96
- return true
97
- }
98
- c = (charAt s i)
99
- if( c == 10 || c == 13) {
100
- }
101
- }
102
-
103
- if had_break {
104
- current_line_index = current_line_index + 1
105
- } {
106
- i = 1 + i
107
- if (i >= len) {
108
- return true
109
- }
110
- c = (charAt s i)
111
- }
112
-
113
- }
114
- return did_break
115
- }
116
-
117
- fn end_expression:boolean () {
118
- i = 1 + i
119
- if (i >= len) {
120
- return false
121
- }
122
- paren_cnt = paren_cnt - 1
123
- if (paren_cnt < 0) {
124
- print "Parser error ) mismatch"
125
- }
126
- removeLast parents
127
- if ((!null? curr_node)) {
128
- curr_node.ep = i
129
- curr_node.infix_operator = false
130
- }
131
- if (((array_length parents)) > 0 ) {
132
- curr_node = (itemAt parents (((array_length parents)) - 1))
133
- } {
134
- curr_node = rootNode
135
- }
136
- curr_node.infix_operator = false
137
- return true
138
- }
139
-
140
- fn getOperator:int ( disabled:boolean ) {
141
- if disabled {
142
- return 0
143
- }
144
- def s:charbuffer ( unwrap buff)
145
- if ((i + 2) >= len) {
146
- return 0
147
- }
148
- def c:char (charAt s i)
149
- def c2:char (charAt s (i + 1))
150
- switch ( c ) {
151
- case (ccode "*") {
152
- i = i + 1
153
- return 14
154
- }
155
- case (ccode "/") {
156
- i = i + 1
157
- return 14
158
- }
159
- case (ccode "%") {
160
- i = i + 1
161
- return 14
162
- }
163
- case (ccode "+") {
164
- i = i + 1
165
- return 13
166
- }
167
- case (ccode "-") {
168
- i = i + 1
169
- return 13
170
- }
171
- case (ccode "<") {
172
- if (c2 == ((ccode "="))) {
173
- i = i + 2
174
- return 11
175
- }
176
- i = i + 1
177
- return 11
178
- }
179
- case (ccode ">") {
180
- if (c2 == ((ccode "="))) {
181
- i = i + 2
182
- return 11
183
- }
184
- i = i + 1
185
- return 11
186
- }
187
- case (ccode "!") {
188
- if (c2 == ((ccode "="))) {
189
- i = i + 2
190
- return 10
191
- }
192
- return 0
193
- }
194
- case (ccode "=") {
195
- if (c2 == ((ccode "="))) {
196
- i = i + 2
197
- return 10
198
- }
199
- i = i + 1
200
- return 3
201
- }
202
- case (ccode "&") {
203
- if (c2 == ((ccode "&"))) {
204
- i = i + 2
205
- return 6
206
- }
207
- return 0
208
- }
209
- case (ccode "|") {
210
- if (c2 == ((ccode "|"))) {
211
- i = i + 2
212
- return 5
213
- }
214
- return 0
215
- }
216
- default {
217
- }
218
- }
219
- return 0
220
- }
221
-
222
- fn isOperator:int ( disabled:boolean ) {
223
- if disabled {
224
- return 0
225
- }
226
- def s:charbuffer ( unwrap buff)
227
- if ((i - 2) > len) {
228
- return 0
229
- }
230
- def c:char (charAt s i)
231
- def c2:char (charAt s (i + 1))
232
- switch (c ) {
233
- case (ccode "*") {
234
- return 1
235
- }
236
- case (ccode "/") {
237
- return 14
238
- }
239
- case (ccode "+") {
240
- return 13
241
- }
242
- case (ccode "%") {
243
- return 14
244
- }
245
- case (ccode "-") {
246
- return 13
247
- }
248
- case (ccode "<") {
249
- if (c2 == ((ccode "="))) {
250
- return 11
251
- }
252
- return 11
253
- }
254
- case (ccode ">") {
255
- if (c2 == ((ccode "="))) {
256
- return 11
257
- }
258
- return 11
259
- }
260
- case (ccode "!") {
261
- if (c2 == ((ccode "="))) {
262
- return 10
263
- }
264
- return 0
265
- }
266
- case (ccode "=") {
267
- if (c2 == ((ccode "="))) {
268
- return 10
269
- }
270
- return 3
271
- }
272
- case (ccode "&") {
273
- if (c2 == ((ccode "&"))) {
274
- return 6
275
- }
276
- return 0
277
- }
278
- case (ccode "|") {
279
- if (c2 == ((ccode "|"))) {
280
- return 5
281
- }
282
- return 0
283
- }
284
- default {
285
- }
286
- }
287
- return 0
288
- }
289
-
290
- fn getOperatorPred:int ( str@(lives):string disabled:boolean) {
291
- if(disabled) {
292
- return 0
293
- }
294
- switch (str ) {
295
- case "<" {
296
- return 11
297
- }
298
- case ">" {
299
- return 11
300
- }
301
- case "<=" {
302
- return 11
303
- }
304
- case ">=" {
305
- return 11
306
- }
307
- case "==" {
308
- return 10
309
- }
310
- case "!=" {
311
- return 10
312
- }
313
- case "=" {
314
- return 3
315
- }
316
- case "&&" {
317
- return 6
318
- }
319
- case "||" {
320
- return 5
321
- }
322
- case "+" {
323
- return 13
324
- }
325
- case "-" {
326
- return 13
327
- }
328
- case "%" {
329
- return 14
330
- }
331
- case "*" {
332
- return 14
333
- }
334
- case "/" {
335
- return 14
336
- }
337
- default {
338
- }
339
- }
340
- return 0
341
- }
342
-
343
- fn insert_node:void ( p_node@(strong lives):CodeNode) {
344
- def push_target@(optional weak lives):CodeNode curr_node
345
- if (curr_node.infix_operator) {
346
- push_target = curr_node.infix_node
347
- if (push_target.to_the_right) {
348
- push_target = push_target.right_node
349
- p_node.parent = push_target
350
- }
351
- }
352
- push push_target.children p_node
353
- }
354
-
355
- fn parse_attributes:boolean () {
356
- def s:charbuffer (unwrap buff)
357
- def last_i:int 0
358
- def do_break:boolean false
359
- def attr_name:string ""
360
- def sp:int i
361
- def ep:int i
362
- def c:char 0
363
- def cc1:char 0
364
- def cc2:char 0
365
- cc1 = (charAt s i)
366
- while (i < len) {
367
- last_i = i
368
- while ((i < len) && ((charAt s i) <= 32)) {
369
- i = (1 + i)
370
- }
371
- cc1 = (charAt s i)
372
- cc2 = (charAt s (i + 1))
373
- if (i >= len) {
374
- break _
375
- }
376
- if (cc1 == (ccode ">")) {
377
- return do_break
378
- }
379
- if ((cc1 == (ccode "/")) && (cc2 == (ccode ">"))) {
380
- i = (2 + i)
381
- return true
382
- }
383
- sp = i
384
- ep = i
385
- c = (charAt s i)
386
- while ((i < len) && (((c >= 65) && (c <= 90)) || ((c >= 97) && (c <= 122)) || ((c >= 48) && (c <= 57)) || (c == (ccode "_")) || (c == (ccode "-")))) {
387
- i = (1 + i)
388
- c = (charAt s i)
389
- }
390
- i = (i - 1)
391
- def an_sp:int sp
392
- def an_ep:int i
393
- c = (charAt s i)
394
- while ((i < len) && (c != (ccode "="))) {
395
- i = (1 + i)
396
- c = (charAt s i)
397
- }
398
- if (c == (ccode "=")) {
399
- i = (1 + i)
400
- }
401
- while ((i < len) && ((charAt s i) <= 32)) {
402
- i = (1 + i)
403
- }
404
- if (i >= len) {
405
- break _
406
- }
407
- c = (charAt s i)
408
-
409
- ; parse attribute node...
410
- if( c == (ccode "{")) {
411
-
412
- def cNode@(lives) curr_node
413
-
414
- def new_attr@(lives):CodeNode (new CodeNode(( unwrap code) sp ep))
415
- new_attr.value_type = RangerNodeType.XMLAttr
416
- new_attr.parsed_type = new_attr.value_type
417
- new_attr.vref = (substring s an_sp (an_ep + 1))
418
- new_attr.string_value = (substring s sp ep)
419
- push curr_node.attrs new_attr
420
-
421
- curr_node = new_attr
422
-
423
- paren_cnt = paren_cnt + 1
424
- def new_qnode@(lives):CodeNode (new CodeNode(( unwrap code) i i))
425
- new_qnode.expression = true
426
- this.insert_node(new_qnode)
427
- push parents new_qnode
428
- curr_node = new_qnode
429
- i = 1 + i
430
- this.parse(false)
431
-
432
- curr_node = cNode
433
-
434
- continue
435
- }
436
-
437
- if( (c == 34) || ( c == (ccode "'")) ) {
438
- i = (i + 1)
439
- sp = i
440
- ep = i
441
- c = (charAt s i)
442
- while ((i < len) && (c != 34) && ( c!= (ccode "'"))) {
443
- i = (1 + i)
444
- c = (charAt s i)
445
- }
446
- ep = i
447
- if ((i < len) && (ep > sp)) {
448
- def new_attr@(lives):CodeNode (new CodeNode(( unwrap code) sp ep))
449
- new_attr.value_type = RangerNodeType.XMLAttr
450
- new_attr.parsed_type = new_attr.value_type
451
- new_attr.vref = (substring s an_sp (an_ep + 1))
452
- new_attr.string_value = (substring s sp ep)
453
- push curr_node.attrs new_attr
454
- }
455
- i = (1 + i)
456
- }
457
- if (last_i == i) {
458
- i = (1 + i)
459
- }
460
- }
461
- return do_break
462
- }
463
-
464
- fn parseXML:void () {
465
-
466
- def s:charbuffer (unwrap buff)
467
- def c:char 0
468
- def next_c:char 0
469
- def fc:char 0
470
- def new_node:CodeNode
471
- def sp:int i
472
- def ep:int i
473
- def last_i:int 0
474
- def cc1:char 0
475
- def cc2:char 0
476
- def tag_depth 0
477
-
478
- ; print "parseXML called"
479
-
480
- while (i < len) {
481
- last_i = i
482
- if (i >= (len - 1)) {
483
- break _
484
- }
485
- cc1 = (charAt s i)
486
- cc2 = (charAt s (i + 1))
487
-
488
- if( cc1 == (ccode "{")) {
489
- def cNode@(lives) curr_node
490
- paren_cnt = paren_cnt + 1
491
- def new_qnode@(lives):CodeNode (new CodeNode(( unwrap code) i i))
492
- new_qnode.expression = true
493
- this.insert_node(new_qnode)
494
- push parents new_qnode
495
- curr_node = new_qnode
496
- i = 1 + i
497
- this.parse(false)
498
- curr_node = cNode
499
- continue
500
- }
501
-
502
- if (cc1 == (ccode ">")) {
503
- i = (i + 1)
504
- cc1 = (charAt s i)
505
- cc2 = (charAt s (i + 1))
506
- continue 1
507
- }
508
- if (((ccode "/") == cc1) && (cc2 == (ccode ">"))) {
509
- tag_depth = (tag_depth - 1)
510
- i = (i + 2)
511
- if( tag_depth <= 0 ) {
512
- removeLast parents
513
- def p_cnt:int (array_length parents)
514
- def last_parent@(lives):CodeNode (itemAt parents (p_cnt - 1))
515
- curr_node = last_parent
516
- return
517
- }
518
- continue 1
519
- }
520
- if (i >= len) {
521
- break _
522
- }
523
- if (((ccode "<") == cc1) && (cc2 == (ccode "/"))) {
524
- tag_depth = (tag_depth - 1)
525
- i = (i + 2)
526
- sp = i
527
- ep = i
528
- c = (charAt s i)
529
- while ((i < len) && (c > 32) && (c != (ccode ">"))) {
530
- i = (1 + i)
531
- c = (charAt s i)
532
- }
533
- ep = i
534
- removeLast parents
535
- def p_cnt:int (array_length parents)
536
- def last_parent@(lives):CodeNode (itemAt parents (p_cnt - 1))
537
- curr_node = last_parent
538
- if( tag_depth <= 0 ) {
539
- return
540
- }
541
- continue
542
- }
543
- if (cc1 == (ccode "<")) {
544
- i = (i + 1)
545
- sp = i
546
- ep = i
547
- c = (charAt s i)
548
- while ((i < len) && (c != (ccode ">")) && (((c >= 65) && (c <= 90)) || ((c >= 97) && (c <= 122)) || ((c >= 48) && (c <= 57)) || (c == 95) || (c == 46) || (c == 64))) {
549
- i = (1 + i)
550
- c = (charAt s i)
551
- }
552
- tag_depth = tag_depth + 1
553
- ep = i
554
- def new_tag:string (substring s sp ep)
555
- if (null? curr_node) {
556
- def new_rnode:CodeNode (new CodeNode(( unwrap code) sp ep))
557
- new_rnode.vref = new_tag
558
- new_rnode.value_type = RangerNodeType.XMLNode
559
- new_rnode.parsed_type = new_rnode.value_type
560
- rootNode = new_rnode
561
- push parents new_rnode
562
- curr_node = new_rnode
563
- } {
564
- def new_node:CodeNode (new CodeNode(( unwrap code) sp ep))
565
- new_node.vref = new_tag
566
- new_node.value_type = RangerNodeType.XMLNode
567
- new_node.parsed_type = new_node.value_type
568
- push curr_node.children new_node
569
- new_node.parent = curr_node
570
- push parents new_node
571
- curr_node = new_node
572
- }
573
- if (this.parse_attributes()) {
574
- removeLast parents
575
- def p_cnt:int (array_length parents)
576
- def last_parent@(lives):CodeNode (itemAt parents (p_cnt - 1))
577
- curr_node = last_parent
578
- tag_depth = (tag_depth - 1)
579
- if( tag_depth <= 0 ) {
580
- return
581
- }
582
- continue
583
- }
584
- continue 1
585
- }
586
- if (!null? curr_node) {
587
- sp = i
588
- ep = i
589
- c = (charAt s i)
590
- while ((i < len) && (c != (ccode "<")) && (c != (ccode "{")) ) {
591
- i = (1 + i)
592
- c = (charAt s i)
593
- }
594
- ep = i
595
- if (ep > sp) {
596
- def new_node:CodeNode (new CodeNode(( unwrap code) sp ep))
597
- new_node.string_value = (substring s sp ep)
598
- new_node.value_type = RangerNodeType.XMLText
599
- new_node.parsed_type = new_node.value_type
600
- push curr_node.children new_node
601
- new_node.parent = curr_node
602
- }
603
- }
604
- if (last_i == i) {
605
- i = (1 + i)
606
- }
607
- }
608
- }
609
-
610
-
611
- fn parse:void ( disable_ops:boolean ) {
612
- def s:charbuffer ( unwrap buff)
613
- def c:char (charAt s 0)
614
- def next_c:char 0
615
- def fc:char 0
616
- def new_node@(optional):CodeNode
617
- def sp:int 0
618
- def ep:int 0
619
- def last_i:int 0
620
- def had_lf:boolean false
621
- def disable_ops_set disable_ops
622
-
623
- while (i < len) {
624
-
625
- if(!null? curr_node) {
626
- ; called from the XML parser...
627
- if(curr_node.value_type == RangerNodeType.XMLAttr) {
628
- return
629
- }
630
- if(curr_node.value_type == RangerNodeType.XMLNode) {
631
- return
632
- }
633
- }
634
-
635
- if (had_error) {
636
- break
637
- }
638
- last_i = i
639
- def is_block_parent:boolean false
640
- if (had_lf) {
641
- had_lf = false
642
- this.end_expression()
643
- break
644
- }
645
- if ((!null? curr_node)) {
646
- if ((!null? curr_node.parent)) {
647
- def nodeParent@(optional):CodeNode curr_node.parent
648
- if (nodeParent.is_block_node) {
649
- is_block_parent = true
650
- }
651
- }
652
- }
653
- if ((this.skip_space(is_block_parent))) {
654
- break
655
- }
656
- had_lf = false
657
- c = (charAt s i)
658
- if (i < len) {
659
- c = (charAt s i)
660
-
661
- if ( (ccode "<") == c) {
662
- if( (i + 1) < len ) {
663
- def next_c (charAt s (i + 1))
664
- if ( (ccode "A") < next_c && (ccode "z") > next_c) {
665
- ; print "XML start found"
666
- def spos i
667
- ; i = i + 1
668
- this.parseXML()
669
- ; print "XML parsed at index " + i + " the leng was " + len
670
- ; print "XML was " + (substring s spos i)
671
- i = i + 1
672
- continue
673
- }
674
- }
675
- if( i > 0 ) {
676
- def prev_c (charAt s (i - 1))
677
- if ( (ccode ">") == prev_c) {
678
- ; print "XML END found"
679
- }
680
- }
681
- }
682
-
683
- ; multiline comments ?
684
- if (c == 59) {
685
- sp = i + 1
686
- while ((i < len) && (((charAt s i)) > 31)) {
687
- i = 1 + i
688
- }
689
- if (i >= len) {
690
- break
691
- }
692
- new_node = (new CodeNode(( unwrap code) sp i))
693
- new_node.parsed_type = RangerNodeType.Comment
694
- new_node.value_type = RangerNodeType.Comment
695
- new_node.string_value = (substring s sp i)
696
- push curr_node.comments ( unwrap new_node)
697
- continue
698
- }
699
-
700
- if (i < (len - 1)) {
701
- fc = (charAt s (i + 1))
702
-
703
-
704
- if ((c == 40) || (c == ((ccode "{"))) ) {
705
- paren_cnt = paren_cnt + 1
706
- if ((null? curr_node) ) {
707
- rootNode = (new CodeNode(( unwrap code) i i))
708
- curr_node = rootNode
709
- curr_node.expression = true
710
- push parents ( unwrap curr_node)
711
- } {
712
- def new_qnode@(lives):CodeNode (new CodeNode(( unwrap code) i i))
713
- new_qnode.expression = true
714
- this.insert_node(new_qnode)
715
- push parents new_qnode
716
- curr_node = new_qnode
717
- }
718
- if (c == ((ccode "{"))) {
719
- curr_node.is_block_node = true
720
- }
721
- i = 1 + i
722
- this.parse( disable_ops_set )
723
- continue
724
- }
725
- }
726
- sp = i
727
- ep = i
728
- fc = (charAt s i)
729
- ; number testing...
730
- if (((fc == 45) && (((charAt s (i + 1))) >= 46) && (((charAt s (i + 1))) <= 57)) || ((fc >= 48) && (fc <= 57))) {
731
- def is_double:boolean false
732
- sp = i
733
- i = 1 + i
734
- c = (charAt s i)
735
- while ((i < len) && (((c >= 48) && (c <= 57)) || (c == ((ccode "."))) || ((i == sp) && ((c == ((ccode "+"))) || (c == ((ccode "-"))))))) {
736
- if (c == ((ccode "."))) {
737
- is_double = true
738
- }
739
- i = 1 + i
740
- c = (charAt s i)
741
- }
742
- ep = i
743
- def new_num_node:CodeNode (new CodeNode(( unwrap code) sp ep))
744
- if (is_double ) {
745
- new_num_node.parsed_type = RangerNodeType.Double
746
- new_num_node.value_type = RangerNodeType.Double
747
- new_num_node.double_value = ( unwrap ((str2double ((substring s sp ep)))))
748
- } {
749
- new_num_node.parsed_type = RangerNodeType.Integer
750
- new_num_node.value_type = RangerNodeType.Integer
751
- new_num_node.int_value = ( unwrap ((str2int ((substring s sp ep)))))
752
- }
753
- this.insert_node(new_num_node)
754
- continue
755
- }
756
-
757
- def str_limit fc
758
- def b_had_str ( fc == 34 || fc == 96 || fc == 39 )
759
-
760
- if b_had_str {
761
- sp = i + 1
762
- ep = sp
763
- c = (charAt s i)
764
- def must_encode:boolean false
765
- while (i < len) {
766
- i = 1 + i
767
- c = (charAt s i)
768
- if (c == str_limit) {
769
- break
770
- }
771
- if (c == 92) {
772
- i = 1 + i
773
- if (i < len ) {
774
- must_encode = true
775
- c = (charAt s i)
776
- } {
777
- break
778
- }
779
- }
780
- }
781
- ep = i
782
- if (i < len) {
783
- def encoded_str:string ""
784
- if (must_encode) {
785
- ; print "parsing encoded string " + (substring s sp ep)
786
- def subs (substring s sp ep)
787
- def orig_str:charbuffer (to_charbuffer subs)
788
- def str_length:int (length orig_str)
789
- def ii:int 0
790
- while (ii < str_length) {def cc:char (charAt orig_str ii)
791
- if (cc == 92 ) {
792
- def next_ch:char (charAt orig_str (ii + 1))
793
- switch (next_ch ) {
794
- case 34 {
795
- encoded_str = encoded_str + ((strfromcode 34))
796
- }
797
- case 92 {
798
- encoded_str = encoded_str + ((strfromcode 92))
799
- }
800
- case 47 {
801
- encoded_str = encoded_str + ((strfromcode 47))
802
- }
803
- case 98 {
804
- encoded_str = encoded_str + ((strfromcode 8))
805
- }
806
- case 102 {
807
- encoded_str = encoded_str + ((strfromcode 12))
808
- }
809
- case 110 {
810
- encoded_str = encoded_str + ((strfromcode 10))
811
- }
812
- case 114 {
813
- encoded_str = encoded_str + ((strfromcode 13))
814
- }
815
- case 116 {
816
- encoded_str = encoded_str + ((strfromcode 9))
817
- }
818
- case 117 {
819
- ii = ii + 4
820
- }
821
- default {
822
- }
823
- }
824
- ii = ii + 2
825
- } {
826
- encoded_str = encoded_str + ((substring orig_str ii (1 + ii)))
827
- ii = ii + 1
828
- }
829
- }
830
- } {
831
- ; print "string without encoding"
832
- }
833
-
834
- def new_str_node:CodeNode (new CodeNode(( unwrap code) sp ep))
835
- new_str_node.parsed_type = RangerNodeType.String
836
- new_str_node.value_type = RangerNodeType.String
837
- if (must_encode ) {
838
- new_str_node.string_value = encoded_str
839
- } {
840
- new_str_node.string_value = (substring s sp ep)
841
- }
842
- this.insert_node(new_str_node)
843
- i = 1 + i
844
- continue
845
- }
846
- }
847
- if ((fc == ((ccode "t"))) && (((charAt s (i + 1))) == ((ccode "r"))) && (((charAt s (i + 2))) == ((ccode "u"))) && (((charAt s (i + 3))) == ((ccode "e")))) {
848
- def new_true_node:CodeNode (new CodeNode(( unwrap code) sp sp + 4))
849
- new_true_node.value_type = RangerNodeType.Boolean
850
- new_true_node.parsed_type = RangerNodeType.Boolean
851
- new_true_node.boolean_value = true
852
- this.insert_node(new_true_node)
853
- i = i + 4
854
- continue
855
- }
856
- if ((fc == ((ccode "f"))) && (((charAt s (i + 1))) == ((ccode "a"))) && (((charAt s (i + 2))) == ((ccode "l"))) && (((charAt s (i + 3))) == ((ccode "s"))) && (((charAt s (i + 4))) == ((ccode "e")))) {
857
- def new_f_node:CodeNode (new CodeNode(( unwrap code) sp sp + 5))
858
- new_f_node.value_type = RangerNodeType.Boolean
859
- new_f_node.parsed_type = RangerNodeType.Boolean
860
- new_f_node.boolean_value = false
861
- this.insert_node(new_f_node)
862
- i = i + 5
863
- continue
864
- }
865
-
866
- if (fc == ((ccode "@"))) {
867
- i = i + 1
868
- sp = i
869
- ep = i
870
- c = (charAt s i)
871
- while ((i < len) && (((charAt s i)) > 32) && (c != 40) && (c != 41) && (c != ((ccode "}")) )) {
872
- i = 1 + i
873
- c = (charAt s i)
874
- }
875
- ep = i
876
- if ((i < len) && (ep > sp)) {
877
- def a_node2@(lives):CodeNode (new CodeNode(( unwrap code) sp ep))
878
- def a_name:string (substring s sp ep)
879
- if( a_name == "noinfix") {
880
- disable_ops_set = true
881
- }
882
- a_node2.expression = true
883
- curr_node = a_node2
884
- push parents a_node2
885
- i = i + 1
886
- paren_cnt = paren_cnt + 1
887
- this.parse(disable_ops_set)
888
- def use_first:boolean false
889
- if (1 == ((array_length a_node2.children))) {
890
- def ch1:CodeNode (itemAt a_node2.children 0)
891
- use_first = (ch1.isPrimitive())
892
- }
893
- if (use_first ) {
894
- def theNode:CodeNode (array_extract a_node2.children 0)
895
- set curr_node.props a_name theNode
896
- } {
897
- set curr_node.props a_name a_node2
898
- }
899
- push curr_node.prop_keys a_name
900
- continue
901
- }
902
- }
903
- def ns_list@(temp):[string]
904
- def last_ns:int i
905
- def ns_cnt:int 1
906
- def vref_had_type_ann:boolean false
907
- def vref_ann_node@(optional temp):CodeNode
908
- def vref_end:int i
909
- if ((i < len) && (((charAt s i)) > 32) && (c != 58) && (c != 40) && (c != 41) && (c != ((ccode "}")) ) ) {
910
- if (curr_node.is_block_node == true) {
911
- def new_expr_node:CodeNode (new CodeNode(( unwrap code) sp ep))
912
- new_expr_node.parent = curr_node
913
- new_expr_node.expression = true
914
- push curr_node.children new_expr_node
915
- curr_node = new_expr_node
916
- push parents new_expr_node
917
- paren_cnt = 1 + paren_cnt
918
- this.parse(disable_ops_set)
919
- continue
920
- }
921
- }
922
- def op_c:int 0
923
- ; if (((array_length curr_node.children)) >= 0) {
924
- op_c = (this.getOperator(disable_ops_set))
925
- ; }
926
- def last_was_newline:boolean false
927
- if (op_c > 0 ) {
928
- } {
929
-
930
- while ((i < len) && (((charAt s i)) > 32) && (c != 58) && (c != 40) && (c != 41) && (c != ((ccode "}"))) ) {
931
- if (i > sp) {
932
- def is_opchar:int (this.isOperator(disable_ops_set))
933
- if (is_opchar > 0) {
934
- break
935
- }
936
- }
937
- i = 1 + i
938
- c = (charAt s i)
939
- if ((c == 10) || (c == 13)) {
940
- last_was_newline = true
941
- break
942
- }
943
- if (c == ((ccode "."))) {
944
- push ns_list (substring s last_ns i)
945
- last_ns = i + 1
946
- ns_cnt = 1 + ns_cnt
947
- }
948
- if ((i > vref_end) && (c == ((ccode "@")))) {
949
- vref_had_type_ann = true
950
- vref_end = i
951
- vref_ann_node = (this.parse_raw_annotation())
952
- c = (charAt s i)
953
- break
954
- }
955
- }
956
- }
957
- ep = i
958
- if (vref_had_type_ann) {
959
- ep = vref_end
960
- }
961
-
962
- push ns_list (substring s last_ns ep)
963
- c = (charAt s i)
964
- while ((i < len) && (c <= 32) && (false == last_was_newline)) {
965
- i = 1 + i
966
- c = (charAt s i)
967
- if (is_block_parent && ((c == 10) || (c == 13))) {
968
- i = i - 1
969
- c = (charAt s i)
970
- had_lf = true
971
- break
972
- }
973
- }
974
- if ( (false == disable_ops_set) && (c == (ccode ":") ) ) {
975
- i = i + 1
976
- while ((i < len) && (((charAt s i)) <= 32)) {
977
- i = 1 + i
978
- }
979
- def vt_sp:int i
980
- def vt_ep:int i
981
- c = (charAt s i)
982
- if (c == ((ccode "("))) {
983
-
984
- ; tring to parser as annotation...
985
- def vann_arr2@(lives):CodeNode (this.parse_raw_annotation())
986
- vann_arr2.expression = true
987
-
988
- ;def a_node3@(lives):CodeNode (new CodeNode(( unwrap code) sp ep))
989
- ;a_node3.expression = true
990
- ;curr_node = a_node3
991
- ;push parents a_node3
992
- ;i = i + 1
993
- ;this.parse(disable_ops_set)
994
- def new_expr_node:CodeNode (new CodeNode(( unwrap code) sp vt_ep))
995
- new_expr_node.vref = (substring s sp ep)
996
- new_expr_node.ns = ns_list
997
- new_expr_node.expression_value = vann_arr2
998
- new_expr_node.parsed_type = RangerNodeType.ExpressionType
999
- new_expr_node.value_type = RangerNodeType.ExpressionType
1000
- if (vref_had_type_ann) {
1001
- new_expr_node.vref_annotation = vref_ann_node
1002
- new_expr_node.has_vref_annotation = true
1003
- }
1004
- push curr_node.children new_expr_node
1005
- continue
1006
- }
1007
- if (c == ((ccode "["))) {
1008
- i = i + 1
1009
- vt_sp = i
1010
- def hash_sep:int 0
1011
- def had_array_type_ann:boolean false
1012
- c = (charAt s i)
1013
- while ((i < len) && (c > 32) && (c != 93)) {
1014
- i = 1 + i
1015
- c = (charAt s i)
1016
- if (c == ((ccode ":"))) {
1017
- hash_sep = i
1018
- }
1019
- if (c == ((ccode "@"))) {
1020
- had_array_type_ann = true
1021
- break
1022
- }
1023
- }
1024
- vt_ep = i
1025
- if (hash_sep > 0 ) {
1026
- vt_ep = i
1027
- def type_name:string (substring s (1 + hash_sep) vt_ep)
1028
- def key_type_name:string (substring s vt_sp hash_sep)
1029
- def new_hash_node:CodeNode (new CodeNode(( unwrap code) sp vt_ep))
1030
- new_hash_node.vref = (substring s sp ep)
1031
- new_hash_node.ns = ns_list
1032
- new_hash_node.parsed_type = RangerNodeType.Hash
1033
- new_hash_node.value_type = RangerNodeType.Hash
1034
- new_hash_node.array_type = type_name
1035
- new_hash_node.key_type = key_type_name
1036
- if (vref_had_type_ann) {
1037
- new_hash_node.vref_annotation = vref_ann_node
1038
- new_hash_node.has_vref_annotation = true
1039
- }
1040
- if (had_array_type_ann) {
1041
- def vann_hash:CodeNode (this.parse_raw_annotation())
1042
- new_hash_node.type_annotation = vann_hash
1043
- new_hash_node.has_type_annotation = true
1044
- }
1045
- new_hash_node.parent = curr_node
1046
- push curr_node.children new_hash_node
1047
- i = 1 + i
1048
- continue
1049
- } {
1050
- vt_ep = i
1051
- def type_name:string (substring s vt_sp vt_ep)
1052
- def new_arr_node:CodeNode (new CodeNode(( unwrap code) sp vt_ep))
1053
- new_arr_node.vref = (substring s sp ep)
1054
- new_arr_node.ns = ns_list
1055
- new_arr_node.parsed_type = RangerNodeType.Array
1056
- new_arr_node.value_type = RangerNodeType.Array
1057
- new_arr_node.array_type = type_name
1058
- new_arr_node.parent = curr_node
1059
- push curr_node.children new_arr_node
1060
- if (vref_had_type_ann) {
1061
- new_arr_node.vref_annotation = vref_ann_node
1062
- new_arr_node.has_vref_annotation = true
1063
- }
1064
- if (had_array_type_ann) {
1065
- def vann_arr:CodeNode (this.parse_raw_annotation())
1066
- new_arr_node.type_annotation = vann_arr
1067
- new_arr_node.has_type_annotation = true
1068
- print "--> parsed ARRAY TYPE annotation"
1069
- }
1070
- i = 1 + i
1071
- continue
1072
- }
1073
- }
1074
- def had_type_ann:boolean false
1075
- ; is_not_limiter
1076
- ; while ((i < len) && (((charAt s i)) > 32) && (c != 58) && (c != 40) && (c != 41) && (c != ((ccode "}"))) && (c != ((ccode ",")))) {
1077
- ; while ((i < len) && (((charAt s i)) > 32) && (c != 58) && (is_not_limiter c) ) {
1078
-
1079
- while ( (i < len) && (is_not_limiter c) ) {
1080
- i = 1 + i
1081
- c = (charAt s i)
1082
- if (c == ((ccode "@"))) {
1083
- had_type_ann = true
1084
- break
1085
- }
1086
- }
1087
- if (i < len) {
1088
- vt_ep = i
1089
- def type_name:string (substring s vt_sp vt_ep)
1090
- def new_ref_node:CodeNode (new CodeNode(( unwrap code) sp ep))
1091
- new_ref_node.vref = (substring s sp ep)
1092
- new_ref_node.ns = ns_list
1093
- new_ref_node.parsed_type = RangerNodeType.VRef
1094
- new_ref_node.value_type = RangerNodeType.VRef
1095
- new_ref_node.type_name = (substring s vt_sp vt_ep)
1096
- new_ref_node.parent = curr_node
1097
- if (vref_had_type_ann) {
1098
- new_ref_node.vref_annotation = vref_ann_node
1099
- new_ref_node.has_vref_annotation = true
1100
- }
1101
- push curr_node.children new_ref_node
1102
- if (had_type_ann) {
1103
- def vann:CodeNode (this.parse_raw_annotation())
1104
- new_ref_node.type_annotation = vann
1105
- new_ref_node.has_type_annotation = true
1106
- }
1107
- continue
1108
- }
1109
- } {
1110
- if ((i < len) && (ep > sp)) {
1111
- def new_vref_node:CodeNode (new CodeNode(( unwrap code) sp ep))
1112
- new_vref_node.vref = (substring s sp ep)
1113
- new_vref_node.parsed_type = RangerNodeType.VRef
1114
- new_vref_node.value_type = RangerNodeType.VRef
1115
- new_vref_node.ns = ns_list
1116
- new_vref_node.parent = curr_node
1117
- def op_pred:int (this.getOperatorPred(new_vref_node.vref disable_ops_set))
1118
- if (new_vref_node.vref == ",") {
1119
- curr_node.infix_operator = false
1120
- continue
1121
- }
1122
- def pTarget@(optional weak):CodeNode curr_node
1123
- if (curr_node.infix_operator) {
1124
- def iNode@(optional):CodeNode curr_node.infix_node
1125
- if ((op_pred > 0) || (iNode.to_the_right == false) ) {
1126
- pTarget = iNode
1127
- } {
1128
- def rn@(optional lives):CodeNode iNode.right_node
1129
- new_vref_node.parent = rn
1130
- pTarget = rn
1131
- }
1132
- }
1133
- push pTarget.children new_vref_node
1134
- if (vref_had_type_ann) {
1135
- new_vref_node.vref_annotation = vref_ann_node
1136
- new_vref_node.has_vref_annotation = true
1137
- }
1138
- if ( (i + 1) < len ) {
1139
- if ((((charAt s (i + 1))) == ((ccode "("))) || (((charAt s (i + 0))) == ((ccode "(")))) {
1140
- if ((0 == op_pred) && curr_node.infix_operator && (1 == ((array_length curr_node.children)))) {
1141
- }
1142
- }
1143
- }
1144
-
1145
- if (((op_pred > 0) && curr_node.infix_operator) || ((op_pred > 0) && (((array_length curr_node.children)) >= 2))) {
1146
- if ((op_pred == 3) && (2 == ((array_length curr_node.children))) ) {
1147
- def n_ch:CodeNode (array_extract curr_node.children 0)
1148
- push curr_node.children n_ch
1149
- } {
1150
- if (false == curr_node.infix_operator) {
1151
- def if_node@(temp lives):CodeNode (new CodeNode(( unwrap code) sp ep))
1152
- curr_node.infix_node = if_node
1153
- curr_node.infix_operator = true
1154
- if_node.infix_subnode = true
1155
- curr_node.value_type = RangerNodeType.NoType
1156
- curr_node.parsed_type = curr_node.value_type
1157
- curr_node.expression = true
1158
- if_node.expression = true
1159
- def ch_cnt:int (array_length curr_node.children)
1160
- def ii:int 0
1161
- def start_from:int ch_cnt - 2
1162
- def keep_nodes:CodeNode (new CodeNode(( unwrap code) sp ep))
1163
- while (ch_cnt > 0) {
1164
- def n_ch:CodeNode (array_extract curr_node.children 0)
1165
- def p_target:CodeNode if_node
1166
- if ((ii < start_from) || n_ch.infix_subnode) {
1167
- p_target = keep_nodes
1168
- }
1169
- push p_target.children n_ch
1170
- ch_cnt = ch_cnt - 1
1171
- ii = 1 + ii
1172
- }
1173
- for keep_nodes.children keep:CodeNode i2 {
1174
- push curr_node.children keep
1175
- }
1176
- push curr_node.children if_node
1177
- }
1178
- def ifNode@(optional lives):CodeNode curr_node.infix_node
1179
- def new_op_node@(temp):CodeNode (new CodeNode(( unwrap code) sp ep))
1180
- new_op_node.expression = true
1181
- new_op_node.parent = ifNode
1182
- def until_index:int ((array_length ifNode.children)) - 1
1183
- def to_right:boolean false
1184
- def just_continue:boolean false
1185
- if ((ifNode.operator_pred > 0) && (ifNode.operator_pred < op_pred)) {
1186
- to_right = true
1187
- }
1188
- if ((ifNode.operator_pred > 0) && (ifNode.operator_pred > op_pred)) {
1189
- ifNode.to_the_right = false
1190
- }
1191
- if ((ifNode.operator_pred > 0) && (ifNode.operator_pred == op_pred)) {
1192
- to_right = ifNode.to_the_right
1193
- }
1194
- def opTarget@(optional):CodeNode ifNode
1195
- if (to_right ) {
1196
- def op_node:CodeNode (array_extract ifNode.children until_index)
1197
- def last_value:CodeNode (array_extract ifNode.children (until_index - 1))
1198
- push new_op_node.children op_node
1199
- push new_op_node.children last_value
1200
- } {
1201
- if (false == just_continue) {
1202
- while (until_index > 0) {
1203
- def what_to_add:CodeNode (array_extract ifNode.children 0)
1204
- push new_op_node.children what_to_add
1205
- until_index = until_index - 1
1206
- }
1207
- }
1208
- }
1209
- if (to_right || (false == just_continue)) {
1210
- push ifNode.children new_op_node
1211
- }
1212
- if (to_right) {
1213
- ifNode.right_node = new_op_node
1214
- ifNode.to_the_right = true
1215
- }
1216
- ifNode.operator_pred = op_pred
1217
- continue
1218
- }
1219
- }
1220
- continue
1221
- }
1222
- }
1223
-
1224
- ;
1225
- if ( (c == 41) || (c == ((ccode "}")))) {
1226
- if ((c == ((ccode "}"))) && is_block_parent && (((array_length curr_node.children)) > 0)) {
1227
- this.end_expression()
1228
- }
1229
- i = 1 + i
1230
- paren_cnt = paren_cnt - 1
1231
- if (paren_cnt < 0) {
1232
- break
1233
- }
1234
- removeLast parents
1235
- if ((!null? curr_node)) {
1236
- curr_node.ep = i
1237
- }
1238
- if (((array_length parents)) > 0 ) {
1239
- curr_node = (itemAt parents (((array_length parents)) - 1))
1240
- } {
1241
- curr_node = rootNode
1242
- }
1243
- break
1244
- }
1245
- if (last_i == i) {
1246
- i = 1 + i
1247
- }
1248
- }
1249
- }
1250
- }
1251
- }