Skip to content

Arithmetic expression parsing#120

Open
ishaangandhi wants to merge 3 commits into
colis-anr:mainfrom
ishaangandhi:arith
Open

Arithmetic expression parsing#120
ishaangandhi wants to merge 3 commits into
colis-anr:mainfrom
ishaangandhi:arith

Conversation

@ishaangandhi
Copy link
Copy Markdown
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
Copy Markdown
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