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

Arithmetic expression parsing #120

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ishaangandhi
Copy link
Contributor

Adds arithmetic expressions to the concrete syntax tree. Previously they were treated as word literals, and not being parsed correctly, especially in cases of nested expressions. IE, $((x += $((2*3)) )) had [(Literal "2"); GlobAll; (Literal "3")] in its parse tree.

I added a new test case, and fixed some existing ones.

This is for ongoing work with @mgree integrating Morbig with the SMOOSH shell.

@ishaangandhi
Copy link
Contributor Author

Also, please note that the current way of tracking the nested levels of double parenthesis might not be complete. For example, $(( ((2 + 1) * 3) + 4 )) has two double left parenthesis, and only 1 double right parenthesis, but is still a valid arithmetic expression. However, the current function requires # double left = # double right.

I'd be happy to fix this. Since this is an orthogonal bug, however, it might make sense to do so in a new pull request. Let me know what you think.

@ishaangandhi ishaangandhi changed the title Arith Arithmetic expression parsing Oct 2, 2020
@Niols Niols changed the base branch from master to main March 31, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant