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

[BUG]负数表达式计算错误 #278

Open
357447923 opened this issue Sep 27, 2023 · 3 comments
Open

[BUG]负数表达式计算错误 #278

357447923 opened this issue Sep 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@357447923
Copy link

Describe the bug
A clear and concise description of what the bug is.

** Environment**
Environment Details sometimes important

  • OS Version: Ubuntu 22.04
  • CPU Arch(x86/arm): x86

Fast Reproduce Steps(Required)
Steps to reproduce the behavior:

miniob > calc 1-1
1
1

Expected behavior
应该为 1-1

Actual Behavior
直接运行 calc 1-1。这个bug不仅仅是出现在这种情况

Additional context
这个问题可能是出现在bision语法解析中,但我不知道应该如何进行修改。只知道运行时bison会报错。

@357447923 357447923 added the bug Something isn't working label Sep 27, 2023
@hnwyllmm
Copy link
Collaborator

这是一个已知的BUG,也已经记录在表达式文档中。这是由于 ”负号“ 与 ”负数“ 没有分清楚的原因导致的。
我有一个简单粗暴的思路,但是没有去修复它。可以把词法分析中的”负数“去掉,把 "-" digits 解析成一个 ”负号+数字“的表达式,而不是简单的负数,即可。
计算 ”1-1" 改成 calc "1- 1" 即没有此问题,可以验证上面的说法。

@hnwyllmm hnwyllmm changed the title [BUG] [BUG]负数表达式计算错误 Sep 27, 2023
@hnwyllmm
Copy link
Collaborator

hnwyllmm commented Oct 3, 2023

It's really a bug and I'll reopen it.

@hnwyllmm hnwyllmm reopened this Oct 3, 2023
@357447923
Copy link
Author

这是一个已知的BUG,也已经记录在表达式文档中。这是由于 ”负号“ 与 ”负数“ 没有分清楚的原因导致的。 我有一个简单粗暴的思路,但是没有去修复它。可以把词法分析中的”负数“去掉,把 "-" digits 解析成一个 ”负号+数字“的表达式,而不是简单的负数,即可。 计算 ”1-1" 改成 calc "1- 1" 即没有此问题,可以验证上面的说法。

这个简单粗暴的方法我尝试了一下,完全可行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants