Open NeeEoo opened 3 years ago
@elikaski Would you be able to review the current revision?
@elikaski Would you be able to review the current revision?
Of course I'm currently busy with the switch-case, so after that :) But if you're blocked and can't advance then let me know and I'll switch to this
Continue with the switch-case since that is more closer to being finished than this.
Can I help, by any chance? I'm working on a sort of programming language (called FlowLang) which can only support mathematical operations
@abhra2020-smart Sure.
If you don't know how to get my changes, you can get either,
Here are some instructions If you use GitHub Cli:
gh repo clone abhra2020-smart/BF-it BF-it-NeeEoo
in a terminalgit checkout add-structs
in a terminalgh pr create
in a terminalI'm not sure how to do it in GitHub Desktop.
For the implementation of s[2].list[3]
, if you change return get_array_index_expression
to return (index_expression, index_expression.__sizeof__()*2+3)
, life's a bit easier. Then you have to change EVERY function call to get_array_index_expression()[0]
Also: index_expression.__ sizeof __()
returns the size of index_expression
(object. __ sizeof __
returns the size of said object)
EDIT: Correction: You only need to change the function calls for when you want the first element
@abhra2020-smart I'll try your way with the index expression after i finish fixing a bug.
I also use PyCharm and i use the git tool included in PyCharm, but i make my pull requests with GitHub Cli. GitHub Cli just makes it easier to interact with GitHub. I don't see how that would make you need to use Notepad.
@elikaski I probably need help with Accessing structs in structs
. Since that would require a rewrite of the way the .field
is represented by the compiler. It should also be able to store an array index.
@elikaski I probably need help with
Accessing structs in structs
. Since that would require a rewrite of the way the.field
is represented by the compiler. It should also be able to store an array index.
OK Unfortunately I haven't had the time to look at this yet :( I will let you know when I get started
@elikaski Do you know how to update a branch so that it contains the new stuff from master? Would the correct way be to make a pull request that merges master
to NeeEoo/add-structs
(this pull request), and then i merge that pull request?
@elikaski Do you know how to update a branch so that it contains the new stuff from master? Would the correct way be to make a pull request that merges
master
toNeeEoo/add-structs
(this pull request), and then i merge that pull request?
I think you can just pull normally and then rebase your commits over the latest master commit
I've read that rebase is bad and that it might cause issues. But i might be wrong.
I'm not sure what the correct git commands are for doing that.
You can also "git pull" and a merge commit will be created. That will work too Or we could keep this branch separated and merge it with master when it's ready
It's more because there are some bug fixes such as the for loop scope bug which isn't on this branch, and when i test i need to copy the changes from that commit onto my working branch and then when i want to commit i remove that code.
I merged and made a pull request (not sure that was necessary) Let me know if it helps
I think i did it correctly
Some of the old comments needs to be changed.
When implementing setting structs as a return type, the data type handling would need to be changed since it need to keep track of structs, it would need to store info such as which struct_id it is.
There could be a new library function called divmod
which has a return type of a struct with the definition:
struct {
int ???; // b-a%b
int mod;
int div;
}
The function should take 2 parameters.
There could be a new library function called
divmod
which has a return type of a struct with the definition:struct { int ???; // b-a%b int mod; int div; }
The function should take 2 parameters.
Good idea It will require implementing a mechanism that makes the return value size arbitrary, and not always 1 cell
I have already implemented dynamic return size. The only thing missing is copying of more cells.
There could be a new library function called
divmod
which has a return type of a struct with the definition:struct { int ???; // b-a%b int mod; int div; }
The function should take 2 parameters.
Good idea It will require implementing a mechanism that makes the return value size arbitrary, and not always 1 cell
The library part is easy to implement. I've done some research on how compilation works. With the way C (and C++) does it, they use a preprocessor. I've implemented one; look into #74 (I should change it to a draft as it is a bit buggy with strings, but I will fix it after finishing this comment). And the ???
bit I think should be called something along the lines of nearestMultiplebelow
.
Closes #30 Closes #29
I feel like that there is so much that could be improved, so I'm opening this as a draft. If you have any questions about my code, ask me.
Here is the progress:
s[2].list[3]
. Tip: Make it soget_array_index_expression
returns (data_size*(2) + 3)s.list = {1,2,3,4};
s[2].list = {1,2,3,4};
struct point p = { 1, 2 }
andstruct point p = { .x = 1, .y = 2 }
(This might be to hard)sizeof(int)
)Some thoughts
The function named
get_variable_size_from_token
in General.py could use a better name.Some of the comments in Node.py could be improved
There should be a util in parser that returns True or False if the tokens match.
check_next_tokens_are
andcheck_current_tokens_are
, assert and raise if it doesn't match. There could beassert_next_tokens_are
,assert_current_tokens_are
,check_next_tokens_are
andcheck_current_tokens_are
. The old functions should be renamed to the assert ones.Extras
I realized that namedtuple is used wrongly, correcting it makes it not work. Converting the data into a class is better.
The way the array access currently works on
arr[5].list
,arr.list[2]
andarr[5].list[2]
, is that in the second one it passes the struct object toget_array_index_expression
and in the first one it doesn't. The way this works is that it calculates the data size of the array and multiplies the index if it is the first one, and in the last one it adds both.I made some debug tools: https://gist.github.com/NeeEoo/bf88c058fd48793a00cb53e5554d4500