Skip to content
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

Redo CONST evaluation and use the element string directly. #435

Merged
merged 3 commits into from
Jan 20, 2024

Conversation

mkilgore
Copy link
Contributor

I ended up taking #429 father and simply changed Evaluate_Expression$ to use the string of elements directly, rather than converting it from elements back to a regular string. This has the big advantage of removing all the ambiguous situations we had to account for. It additionally made it fairly straight forward to add in String support, meaning the old evaluateconst() is unnecessary and could be removed completely. Combining numeric and string support also meant I could fairly easily add support for CHR$() and ASC(), which are nice additions.

To facilitate testing I moved a decent amount of functions and definitions out of qb64pe.bas and into separate utilities/ files. These were largely left unchanged, beyond any additional utility functions I added (Ex. there's many new element* functions that make working with the element strings easier).

For Evaluate_Expression$ itself, the base design is still there (search for parens and evaluate starting with the innermost set), but to make the elements work and also fix #196 I ended up rewriting the parser to use a recursive-decent parser, which works fairly well. Because parens are not evaluated as part of the recursive-decent parser it doesn't actually get all that deep as far as function calls go.

Fixes: #192
Fixes: #196
Fixes: #359

This moves the CONST replacement up before we turn the elements into a
single string. The advantage is that we don't have to worry about
splitting the string properly to find the CONST names as the elements
are already split for us.t
@mkilgore mkilgore merged commit 76107e3 into QB64-Phoenix-Edition:main Jan 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants