Skip to content

Calculator support for constant value expressions - #27

Merged
ehsanmok merged 1 commit into
ehsanmok:masterfrom
themisir:fix/constant_exprs
Jan 3, 2026
Merged

Calculator support for constant value expressions#27
ehsanmok merged 1 commit into
ehsanmok:masterfrom
themisir:fix/constant_exprs

Conversation

@themisir

@themisir themisir commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

The grammar allows programs that evaluate constant value, but the parser does not handle it properly. The existing parser implementation didn't handle ~ Term part of the language grammar because its definition was unfolded into Int | Expr.

I implemented the fix by removing _ prefix to disable rule folding and handled Term rules explicitly. The alternative would be to handle Int case individually or introducing a new Const rule that defines Int (and Float as a part of the exercise) and handling it separately.

@themisir themisir changed the title Support constant value expressions Calculator support for constant value expressions Jan 3, 2026

@ehsanmok ehsanmok left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good catch! thanks.

@ehsanmok
ehsanmok merged commit 9803de1 into ehsanmok:master Jan 3, 2026
1 check passed
@themisir
themisir deleted the fix/constant_exprs branch January 3, 2026 14:38
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