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

Improved math expressions #6

Merged
merged 4 commits into from
Jan 21, 2023
Merged

Improved math expressions #6

merged 4 commits into from
Jan 21, 2023

Conversation

Irev-Dev
Copy link
Collaborator

@Irev-Dev Irev-Dev commented Jan 19, 2023

There was a bit more to it than I was expecting, dealing with order and precedence was a little tricky but mostly works now.

There are a few quirks but the base is there.

resolves #5

Things are in a better state, + - / * work now for basic const var = 5 <operator> 1

Though the current method I'm using to make the ast isn't really going to work for dealing with precedence rules so some refactoring is needed going forward
@vercel
Copy link

vercel bot commented Jan 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
untitled-lang ✅ Ready (Inspect) Visit Preview Jan 21, 2023 at 9:53AM (UTC)

Node that identifiers are working, call expressions are not, that's a TODO
/ * % + - are working both other things like exponent and logical operators are also not working.
Recasting is the most important thing to implement next
@@ -1296,6 +1313,61 @@ export function findClosingBrace(
return findClosingBrace(tokens, index + 1, _braceCount, searchOpeningBrace)
}

// function findOpeningBrace(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended not needing this, but might be useful in future, I danno maybe I should have just deleted it.

if (part.type === 'Literal') {
return part.value
} else if (part.type === 'Identifier') {
return programMemory.root[part.name].value
} else if (part.type === 'BinaryExpression') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now works with expressions with more than a single operator 🎉

@Irev-Dev Irev-Dev marked this pull request as ready for review January 21, 2023 10:22
@Irev-Dev Irev-Dev merged commit e37f684 into main Jan 21, 2023
@Irev-Dev Irev-Dev deleted the kurt-5-math-expressions branch January 21, 2023 10:23
jessfraz added a commit that referenced this pull request Apr 12, 2024
# This is the 1st commit message:

updates;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #2:

docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #3:

remove descriptions

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #4:

get snippet tests

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #5:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #6:

more autocomplete tests

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #7:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #8:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #9:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #10:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #11:

tab to end of snippets

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #12:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #13:

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

# This is the commit message #14:

A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

# This is the commit message #15:

A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get math expressions and precedence working properly
1 participant