godprotocol 1.0.5 → 1.0.6

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 (91) hide show
  1. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  2. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  3. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  4. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  5. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  6. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  7. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  8. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  9. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  10. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  11. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  12. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  13. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  14. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  15. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  16. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  17. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451 +1 -0
  18. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  19. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/46931496c37b22cb91df1929ca4d44b3349c68ec818b37b63dd8583f31e3015b +1 -0
  20. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/4c061633d7fc20f5202cf7d5940b8623c12064c5ede02977e8b5e9e6e7fb9687 +1 -0
  21. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/a20ee8d03f370f8bc61adaf18b681b3e2c4017defd3ad38cb99d2111167ca479 +1 -0
  22. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/ad1e584a505553ddda31fe599dad98fc35a04bd0ff5a654035f85137aa633842 +1 -0
  23. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/bb3d37eee86ecb7262c8ac311a2ddd7f6b9f6298682e348bc784e91511d41638 +1 -0
  24. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/be574e4859c2aba2a2e6a4eb7cf51f006fe2d493ad0268a1f6341e50f0beba90 +1 -0
  25. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5822a8abd3cb9f230711a1ceac473518a38f8824164c9536ae2d20ca264a385 +1 -0
  26. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5bbe585b2c9ef9a1dca11d1520b40847dc0858a0da1e509f646963be5d3866b +1 -0
  27. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f8127f98684c7e3ab56acdc33af3a3ffe02fbcce9740184d2fa64cc7f3db7fdc +1 -0
  28. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  29. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  30. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  31. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  32. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  33. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  34. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  35. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  36. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  37. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  38. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/51a3716d770009c68d68a8f39f912020972c5219187f79f77bdf996e6d3cc530 +1 -0
  39. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  40. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  41. package/Aircode/functions/parse_expression.js +117 -0
  42. package/Aircode/functions/parse_to_obj.js +26 -0
  43. package/Aircode/functions/parse_variable.js +35 -0
  44. package/Aircode/functions/tokenise.js +118 -0
  45. package/Aircode/functions/utils.js +11 -0
  46. package/Aircode/keywords/conditional.js +104 -0
  47. package/Aircode/keywords/parse.js +20 -0
  48. package/Aircode/main.js +94 -0
  49. package/Aircode/native_classes/Variable.js +36 -0
  50. package/Aircode/native_classes/datatypes/Number.js +20 -0
  51. package/Aircode/native_classes/datatypes/String.js +20 -0
  52. package/Aircode/native_classes/global.js +21 -0
  53. package/Aircode/native_classes/native.js +23 -0
  54. package/Aircode/native_classes/operators.js +47 -0
  55. package/Aircode/native_classes/parse.js +42 -0
  56. package/Aircode/utils/format_instructions.js +36 -0
  57. package/Aircode/utils/traverse.js +13 -0
  58. package/Index.js +19 -20
  59. package/Objects/Account.js +90 -98
  60. package/Objects/Block.js +45 -0
  61. package/Objects/Blockweb.js +30 -12
  62. package/Objects/Chain.js +96 -0
  63. package/Objects/Explorer.js +18 -62
  64. package/Objects/Filesystem.js +163 -12
  65. package/Objects/Frame.js +11 -1
  66. package/Objects/Manager.js +56 -0
  67. package/Objects/Opcodes.js +13 -17
  68. package/Objects/Oracle.js +35 -0
  69. package/Objects/Virtual_machine.js +72 -70
  70. package/Objects/folder.js +8 -83
  71. package/framer.js +27 -4
  72. package/opcodes/add.js +15 -38
  73. package/opcodes/jmp.js +9 -3
  74. package/opcodes/std.js +5 -0
  75. package/opcodes.js +19 -10
  76. package/package.json +1 -1
  77. package/utils/create_server.js +23 -12
  78. package/utils/hash.js +1 -38
  79. package/utils/services.js +25 -15
  80. package/.keypair +0 -1
  81. package/Datatypes/Array.js +0 -33
  82. package/Datatypes/Number.js +0 -21
  83. package/Datatypes/String.js +0 -23
  84. package/Datatypes/Twain.js +0 -42
  85. package/Objects/Blockchain.js +0 -135
  86. package/Objects/Emitter.js +0 -38
  87. package/Objects/Queries.js +0 -13
  88. package/Objects/file.js +0 -21
  89. package/Socket.js +0 -83
  90. package/index.d.ts +0 -50
  91. package/utils/gen_key_pair.js +0 -36
@@ -0,0 +1 @@
1
+ "./Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/bb3d37eee86ecb7262c8ac311a2ddd7f6b9f6298682e348bc784e91511d41638"
@@ -0,0 +1 @@
1
+ {"op0":"Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451"}
@@ -0,0 +1 @@
1
+ {"op0":"Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b"}
@@ -0,0 +1 @@
1
+ {"inputs":"./Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f8127f98684c7e3ab56acdc33af3a3ffe02fbcce9740184d2fa64cc7f3db7fdc"}
@@ -0,0 +1 @@
1
+ "./Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451"
@@ -0,0 +1 @@
1
+ {"inputs":"Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/a20ee8d03f370f8bc61adaf18b681b3e2c4017defd3ad38cb99d2111167ca479"}
@@ -0,0 +1 @@
1
+ {"inputs":"Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/4c061633d7fc20f5202cf7d5940b8623c12064c5ede02977e8b5e9e6e7fb9687"}
@@ -0,0 +1 @@
1
+ {"op0":"./Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451"}
@@ -0,0 +1 @@
1
+ "./Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5822a8abd3cb9f230711a1ceac473518a38f8824164c9536ae2d20ca264a385"
@@ -0,0 +1,117 @@
1
+ import parse_to_obj from "./parse_to_obj";
2
+
3
+ const slice_expression = (tokens, pos, parent, compiler) => {
4
+ let expr = [];
5
+
6
+ while (true) {
7
+ let token = tokens[pos];
8
+ if (!token) break;
9
+
10
+ if (compiler.expr_types.includes(token.type)) {
11
+ if (!expr.length) {
12
+ expr.push(token);
13
+ pos++;
14
+ } else {
15
+ if (expr.slice(-1)[0].type !== "operator") break;
16
+ else {
17
+ expr.push(token);
18
+ pos++;
19
+ }
20
+ }
21
+ } else if (token.type === "operator") {
22
+ expr.push(token);
23
+ pos++;
24
+ } else {
25
+ break;
26
+ }
27
+ }
28
+
29
+ return { expr, pos };
30
+ };
31
+
32
+ let op_precedence = [
33
+ "(",
34
+ ">",
35
+ "<",
36
+ "<=",
37
+ ">=",
38
+ "==",
39
+ "**",
40
+ "/",
41
+ "*",
42
+ "+",
43
+ "-",
44
+ "~/",
45
+ "~*",
46
+ "~+",
47
+ "~-",
48
+ ];
49
+
50
+ const has_op = (expr, op) => {
51
+ let found = null;
52
+
53
+ for (let e = 0; e < expr.length; e++) {
54
+ let x = expr[e];
55
+
56
+ if (x.value === op) {
57
+ found = e;
58
+ break;
59
+ }
60
+ }
61
+
62
+ return found;
63
+ };
64
+
65
+ const resolve_expression = (expr, parent) => {
66
+ if (expr.length === 1) {
67
+ expr[0] = parse_to_obj(expr[0]);
68
+ } else {
69
+ while (expr.length > 1) {
70
+ for (let i = 0; i < op_precedence.length; i++) {
71
+ let op = op_precedence[i];
72
+ let e = has_op(expr, op);
73
+
74
+ while (e != null) {
75
+ let tok_obj = parse_to_obj(expr[e], parent);
76
+ tok_obj.push(
77
+ parse_to_obj(expr[e - 1], parent, {
78
+ is_expr: tok_obj.token.value !== "=",
79
+ })
80
+ );
81
+
82
+ tok_obj.push(parse_to_obj(expr[e + 1], parent, { is_expr: true }));
83
+
84
+ expr.splice(e - 1, 3, tok_obj);
85
+ e = has_op(expr, op);
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ return expr[0];
92
+ };
93
+
94
+ const parse_expression = (tokens, parent, compiler) => {
95
+ let pos = 0,
96
+ obj;
97
+ let token = tokens[pos];
98
+ if (!token) return;
99
+
100
+ if (compiler.expr_types.includes(token.type)) {
101
+ let { pos: pos_, expr } = slice_expression(tokens, pos, parent, compiler);
102
+ pos = pos_;
103
+
104
+ let is_assign = expr.findIndex(
105
+ (e) => e.type === "operator" && e.value === "="
106
+ );
107
+ if (is_assign >= 0) {
108
+ obj = parse_to_obj(token, parent);
109
+ let expr_obj = resolve_expression(expr.slice(2), parent);
110
+ obj.assign(expr_obj);
111
+ } else obj = resolve_expression(expr, parent);
112
+ }
113
+
114
+ return { pos, obj };
115
+ };
116
+
117
+ export { parse_expression };
@@ -0,0 +1,26 @@
1
+ import Variable from "../native_classes/Variable";
2
+ import Num from "../native_classes/datatypes/Number";
3
+ import Operator from "../native_classes/operators";
4
+ import { traverse } from "../utils/traverse";
5
+
6
+ const parse_to_obj = (token, parent, meta = {}) => {
7
+ let obj;
8
+ if (token.type === "operator") obj = new Operator(token);
9
+ else if (token.type === "number") obj = new Num(token);
10
+ else if (token.type === "variable") {
11
+ obj = new Variable(token);
12
+ if (meta && meta.is_expr) {
13
+ let declaration = traverse(parent, obj);
14
+
15
+ if (!declaration) {
16
+ throw new Error(`Variable is not declared!`);
17
+ }
18
+
19
+ obj.declaration = declaration;
20
+ }
21
+ }
22
+
23
+ return obj || token;
24
+ };
25
+
26
+ export default parse_to_obj;
@@ -0,0 +1,35 @@
1
+ import Variable from "../native_classes/Variable";
2
+ import { parse_expression } from "./parse_expression";
3
+
4
+ const parse_variable = (token, pos, parent) => {
5
+ pos++;
6
+ let obj = new Variable(token);
7
+
8
+ let next_tok = compiler.tokens[pos];
9
+
10
+ if (next_tok.type === "operator") {
11
+ if (next_tok.value === "=") {
12
+ pos++;
13
+
14
+ let { obj: obj_, pos: pos_ } = parse_expression(
15
+ compiler.tokens.slice(pos),
16
+ obj
17
+ );
18
+ pos = pos_;
19
+ obj.assign(obj_);
20
+ } else {
21
+ // Its an expression
22
+
23
+ let { obj: obj_, pos: pos_ } = parse_expression(
24
+ compiler.tokens.slice(pos),
25
+ parent
26
+ );
27
+ pos = pos_;
28
+ obj = obj_;
29
+ }
30
+ }
31
+
32
+ return { obj, pos };
33
+ };
34
+
35
+ export default parse_variable;
@@ -0,0 +1,118 @@
1
+ const tokenise = (code) => {
2
+ let pos = 0,
3
+ col = 1,
4
+ line = 1;
5
+
6
+ let keywords = [
7
+ "if",
8
+ "for",
9
+ "while",
10
+ "import",
11
+ "fn",
12
+ "class",
13
+ "throw",
14
+ "parse",
15
+ ];
16
+ let nums = "0123456789";
17
+ let signs = "+-/*=<>!";
18
+ let tokens = new Array();
19
+ let var_chars =
20
+ "abcdefghijklmnopqrstuvwxyzABCSEFGHUJKLMNOPQRSTUVWXYZ0123456789";
21
+ let separators = ";:";
22
+
23
+ while (pos < code.length) {
24
+ let curr_char = code[pos];
25
+
26
+ if (!curr_char) pos++;
27
+ else if (separators.includes(curr_char)) {
28
+ pos++;
29
+ col++;
30
+ tokens.push({ type: "separator", value: curr_char, pos, line, col });
31
+ } else if (signs.includes(curr_char)) {
32
+ let acc = curr_char;
33
+ pos++;
34
+ col++;
35
+ curr_char = code[pos];
36
+ if (curr_char === "=") {
37
+ acc = `${acc}${curr_char}`;
38
+ pos++;
39
+ col++;
40
+ }
41
+ tokens.push({ type: "operator", value: acc, pos, line, col });
42
+ } else if (curr_char === "\n") {
43
+ line++;
44
+ col = 1;
45
+ pos++;
46
+ } else if (curr_char === " ") {
47
+ pos++;
48
+ col++;
49
+ } else if ("[]{}()".includes(curr_char)) {
50
+ tokens.push({ type: "params", value: curr_char, col, line, pos });
51
+ pos++;
52
+ col++;
53
+ } else if (nums.includes(curr_char)) {
54
+ let acc = curr_char;
55
+ pos++;
56
+ curr_char = code[pos];
57
+ col++;
58
+
59
+ while (nums.includes(curr_char)) {
60
+ acc = `${acc}${curr_char}`;
61
+ col++;
62
+ pos++;
63
+ curr_char = code[pos];
64
+ }
65
+ tokens.push({
66
+ type: "number",
67
+ value: acc,
68
+ line,
69
+ col: col - acc.length,
70
+ pos,
71
+ });
72
+ } else if (['"', "'"].includes(curr_char)) {
73
+ let acc = "";
74
+ let opening_quote = curr_char;
75
+ pos++;
76
+ col++;
77
+ curr_char = code[pos];
78
+ while (curr_char !== opening_quote) {
79
+ acc = `${acc}${curr_char}`;
80
+ pos++;
81
+ col++;
82
+ curr_char = code[pos];
83
+ }
84
+ pos++;
85
+ col++;
86
+ tokens.push({
87
+ type: "string",
88
+ value: acc,
89
+ line,
90
+ col: col - (acc.length + 2),
91
+ pos,
92
+ });
93
+ } else if (var_chars.includes(curr_char)) {
94
+ let acc = curr_char;
95
+ pos++;
96
+ col++;
97
+ curr_char = code[pos];
98
+ while (var_chars.includes(curr_char)) {
99
+ acc = `${acc}${curr_char}`;
100
+ pos++;
101
+ col++;
102
+ curr_char = code[pos];
103
+ }
104
+ tokens.push({
105
+ type: keywords.includes(acc) ? "keyword" : "variable",
106
+ value: acc,
107
+ col,
108
+ pos,
109
+ line,
110
+ });
111
+ }
112
+ }
113
+ console.log(tokens);
114
+
115
+ return tokens;
116
+ };
117
+
118
+ export default tokenise;
@@ -0,0 +1,11 @@
1
+ const is_token_value = (token, value, type) => {
2
+ if (!Array.isArray(value)) value = [value];
3
+ if (!Array.isArray(type)) type = [type];
4
+
5
+ if (!type.includes(token.type)) return;
6
+ if (!value.includes(token.value)) return;
7
+
8
+ return true;
9
+ };
10
+
11
+ export { is_token_value };
@@ -0,0 +1,104 @@
1
+ import { privateDecrypt } from "crypto";
2
+ import { parse_expression } from "../functions/parse_expression";
3
+ import { is_token_value } from "../functions/utils";
4
+
5
+ const kw_conditional = (tokens, pos, parent, compiler) => {
6
+ console.log("what is going on?");
7
+ let token = tokens[pos];
8
+ let predicates = new Array();
9
+ console.log(token);
10
+ pos++;
11
+ let { obj: pred, pos: pos_ } = parse_expression(
12
+ tokens.slice(pos),
13
+ parent,
14
+ compiler
15
+ );
16
+
17
+ console.log(pos_);
18
+
19
+ pos += pos_;
20
+ predicates.push({ pred, body: [], type: "if" });
21
+
22
+ token = tokens[pos];
23
+ console.log(token);
24
+ if (!is_token_value(token, ":", "separator")) {
25
+ console.log("Something aint right!");
26
+ }
27
+ pos++;
28
+
29
+ let parens = 0,
30
+ depth = 0,
31
+ body = new Array();
32
+
33
+ while (true) {
34
+ token = tokens[pos];
35
+
36
+ if (is_token_value(token, null, "keyword")) {
37
+ if (is_token_value(token, ["else", "else if", "if"])) {
38
+ if (!depth) {
39
+ if (is_token_value(token, "if")) {
40
+ depth++;
41
+ body.push(token);
42
+ pos++;
43
+ continue;
44
+ } else if (is_token_value(token, "else")) {
45
+ pos++;
46
+ predicates.slice(-1)[0].body.push(...body);
47
+ predicates.push({
48
+ pred: null,
49
+ type: token.value,
50
+ body: new Array(),
51
+ });
52
+ body = new Array();
53
+ } else {
54
+ predicates.slice(-1)[0].body.push(...body);
55
+ body = new Array();
56
+ pred = parse_expression(tokens.slice(pos + 1), parent, compiler);
57
+ pos = pred.pos;
58
+ predicates.push({
59
+ pred: pred.obj,
60
+ body: new Array(),
61
+ type: token.value,
62
+ });
63
+ }
64
+ if (!is_token_value(tokens[pos], ":", "separator")) {
65
+ throw new Error("something aint right");
66
+ }
67
+ pos++;
68
+ } else {
69
+ if (is_token_value(token, "if")) depth++;
70
+ pos++;
71
+ body.push(token);
72
+ }
73
+ } else if (is_token_value(token, compiler.block_keywords)) {
74
+ depth++;
75
+ pos++;
76
+ body.push(token);
77
+ }
78
+ } else if (is_token_value(token, "paren")) {
79
+ if (compiler.open_parens.includes(token.value)) parens += 1;
80
+ else if (compiler.close_paren.includes(token.value)) parens -= 1;
81
+
82
+ pos++;
83
+ body.push(token);
84
+ } else if (is_token_value(token, ":", "separator")) {
85
+ if (parens) {
86
+ pos++;
87
+ body.push(token);
88
+ } else if (depth) {
89
+ depth--;
90
+ pos++;
91
+ body.push(token);
92
+ } else {
93
+ pos++;
94
+ break;
95
+ }
96
+ }
97
+ }
98
+
99
+ predicates.slice(-1)[0].body.push(...body);
100
+
101
+ console.log(token);
102
+ };
103
+
104
+ export { kw_conditional };
@@ -0,0 +1,20 @@
1
+ import { parse_expression } from "../functions/parse_expression";
2
+ import Parse from "../native_classes/parse";
3
+
4
+ const kw_parse = (tokens, pos, parent, compiler) => {
5
+ let token = tokens[pos];
6
+ pos++;
7
+
8
+ let { obj, pos: pos_ } = parse_expression(
9
+ tokens.slice(pos),
10
+ parent,
11
+ compiler
12
+ );
13
+ pos += pos_;
14
+
15
+ let key_obj = new Parse(token, obj);
16
+
17
+ return { obj: key_obj, pos };
18
+ };
19
+
20
+ export { kw_parse };