-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Structs #55
base: master
Are you sure you want to change the base?
Add Structs #55
Conversation
@elikaski Would you be able to review the current revision? |
Of course |
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:
I'm not sure how to do it in GitHub Desktop. |
For the implementation of |
@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 |
OK |
@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 |
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 |
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) |
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 struct {
int ???; // b-a%b
int mod;
int div;
} The function should take 2 parameters. |
Good idea |
I have already implemented dynamic return size. The only thing missing is copying of more cells. |
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 |
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 be
assert_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