45 Commits

Author SHA1 Message Date
cron
da090876a4 turtle/tlang: numerous fixes for .indexing
Lua interface now supports it
The access/assign functions now use indexing by default
Things that deal with indexed stuff now assume its a table rather than a string
2021-08-28 23:25:59 -05:00
cron
e05a24b728 turtle/tlang: add numerical dot indexing
[1, 2, 3] now you can do .1 to get the 1st element (Lua style 1-indexed)
2021-08-28 23:25:59 -05:00
cron
42a253cc71 turtle/tlang: add . map indexing
var.key pushes the value indexed by key in var onto the stack
quotes also work for assignment
numerical keys do not work yet
2021-08-28 23:25:59 -05:00
cron
da00f89ab8 Fix widespread off by one error 2021-08-28 23:25:59 -05:00
cron
ff4c79f16d turtle/tlang: improve in_keys()
The function references should probably be replaced with the Lua-y form
2021-08-28 23:12:53 -05:00
cron
961a0d3803 turtle: add WIP nonworking tlang quarry
Will require some tlang changes, including floor division and the .elem accessing syntax
2021-08-28 23:12:53 -05:00
cron
d37b416495 turtle/tlang: make () work
Literally equivalent to {} run
2021-08-28 23:12:30 -05:00
cron
d740256b12 turtle/tlang: preliminary .key accessing
VAR.key.key = index var[key][key]
.key.key = index TOS[key][key]

The value after . can be just a number.
2021-08-28 23:12:30 -05:00
cron
48d431ffad turtle: fix dircoord swapping right and left on east and west 2021-08-28 23:12:30 -05:00
cron
75435d73f9 turtle: fix pausing 2021-08-28 23:12:30 -05:00
cron
434de43a72 turtle/tlang: add loop variable to forever 2021-08-28 23:12:30 -05:00
cron
db4f5fed9a turtle: add tlang pausing 2021-08-28 23:12:30 -05:00
cron
78d66a7125 turtle/tlang: add state pausing 2021-08-28 23:12:29 -05:00
cron
e77a5f9e83 turtle/tlang: improve API, add more boolean builtins 2021-08-28 23:12:29 -05:00
cron
76f3138dbe turtle: improve state execution and interaction 2021-08-28 23:12:29 -05:00
cron
f1dfe28848 turtle/tlang: fix binary operators being backwards 2021-08-28 23:12:29 -05:00
cron
88c675193a turtle/tlang: add else to if, fix end of scope error 2021-08-28 23:12:29 -05:00
cron
4be2c31314 turtle/tlang: add boolean conversion API, improve automatic conversion 2021-08-28 23:12:29 -05:00
cron
b7793dbb9a turtle/tlang: fix nextpop bug, improve value conversion 2021-08-28 23:12:29 -05:00
cron
3f9f50620d turtle: improve coordinate handling and task scheduling 2021-08-28 23:12:29 -05:00
cron
7b3ebdb460 turtle/tlang: add args builtin
Also fixes some bugs regarding exiting code blocks.
2021-08-28 23:12:29 -05:00
cron
627c7d9bcb turtle/tlang: add WIP API
Some things aren't _raw, other things are, its WIP
2021-08-28 23:12:29 -05:00
cron
e30c012771 turtle: add public domain dedications 2021-08-28 23:12:29 -05:00
cron
33505596ed turtle: add .tlang, fix print log 2021-08-28 23:12:29 -05:00
cron
6e8c1fb739 turtle/tlang: log prints 2021-08-28 23:12:29 -05:00
cron
632eb7e286 turtle: fix tlang integration 2021-08-28 23:12:29 -05:00
cron
16fafaa193 turtle: remove unneeded code
Other functions need to be replaced with tlang cogs.
2021-08-28 23:12:29 -05:00
cron
a0434a7225 turtle: add tlang scheduler 2021-08-28 23:12:29 -05:00
cron
0753b8d94d turtle/tlang: make more modular 2021-08-28 23:12:29 -05:00
cron
2ca6d7ef31 turtle/tlang: remove unecessary dofile replacement 2021-08-28 23:12:29 -05:00
cron
4c816f1071 turtle/tlang: add repeat
{code} count <var> repeat
2021-08-28 23:12:29 -05:00
cron
05da1be543 turtle/tlang: allow unary operators to assign to quotes, add more operators
`var -- is now possible
Added + - / % !
2021-08-28 23:12:29 -05:00
cron
e5f28d8469 turtle/tlang: make = assign to nearest defined
If identifier has never been assigned, assign it in current scope
If it has been assigned, reassign it at that scope to value
Needs a global assignment and local assignment, maybe rename = to set or something
2021-08-28 23:12:29 -05:00
cron
0c0a8236e9 turtle/tlang: force beginning and end of string literals to match 2021-08-28 23:12:29 -05:00
cron
48da01beb5 turtle/tlang: add while 2021-08-28 23:12:29 -05:00
cron
8e757040bf turtle/tlang: make access() search for newest locals first, globals last 2021-08-28 23:12:29 -05:00
cron
ac9f18f6dd turtle/tlang: fix copying error with = builtin 2021-08-28 23:12:29 -05:00
cron
0f8dd9c7f3 turtle/tlang: add forever and some other builtins
With forever, break, and (basic) if for and while can be made.
2021-08-28 23:12:29 -05:00
cron
93881793cf turtle/tlang: add comments, fix strings
Strings support '' syntax now. They can also be started with ' and ended with " or vice versa, and there is no way to put a literal ' in yet.
2021-08-28 23:12:29 -05:00
cron
d791294319 turtle/tlang: add run builtin
This changes how code is executed a bit, code from the stack is popped to an execution stack before.
This makes global executed functions and anonymous ones identical.
Not super well tested as always :]
2021-08-28 23:12:29 -05:00
cron
73d9e30816 turtle/tlang: fix lexer whitespace issues
This fixes the final whitespace issue as well as numbers requiring a final whitespace.
Maps don't need surrounding whitespace anymore.
2021-08-28 23:12:29 -05:00
cron
7f09824e89 turtle: add working tlang
Not very well tested, needs a better public API, not integrated with Minetest, ...
This is WAY bigger than a commit should be.
The next stages will be:
- unit tests
- API (allows it to be more than just a language for this project)
- integration with Minetest
2021-08-28 23:01:49 -05:00
cron
2fc69991b0 turtle: some weird ideas before the turtle language is added 2021-08-28 23:01:49 -05:00
cron
1abd79b524 turtle: add preliminary scheduling system 2021-08-28 23:01:08 -05:00
cron
96861cbe4f turtle: initial turtle mod
Don't use turtle.quarry or the mining features, they are experimental
2021-08-28 23:01:08 -05:00