Skip to content

Unary binary feature#10

Merged
sidrasali merged 3 commits intomainfrom
Unary-Binary-Feature
Aug 7, 2025
Merged

Unary binary feature#10
sidrasali merged 3 commits intomainfrom
Unary-Binary-Feature

Conversation

@JoudiAlakkad
Copy link
Copy Markdown
Contributor

@JoudiAlakkad JoudiAlakkad commented Aug 7, 2025

We added the feature of Unary Expression, where we support negation (-) and complement (~). Then we added Binary Expression where we support binary operations (-,+,*,%). The features were reflected on both lexer and parser. We built the parser based on left-associative expressions with precedence climbing. Furthermore, we added Tests for parser.

@JoudiAlakkad JoudiAlakkad requested a review from sidrasali August 7, 2025 21:39
@JoudiAlakkad JoudiAlakkad self-assigned this Aug 7, 2025
// Symbols
object PLUS : TokenType()

object MINUS : TokenType()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can remove this line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes sure.

@sidrasali sidrasali merged commit 6a91f01 into main Aug 7, 2025
2 checks passed
TokenType.NEGATION to 45,
TokenType.MULTIPLY to 50,
TokenType.DIVIDE to 50,
TokenType.REMAINDER to 50
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you explain these numbers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Those numbers are based on the book, you can check page 95.

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.

2 participants