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

运算符优先级问题 #1

Open
lemoneater opened this issue Oct 28, 2020 · 0 comments
Open

运算符优先级问题 #1

lemoneater opened this issue Oct 28, 2020 · 0 comments

Comments

@lemoneater
Copy link

连接运算符优先级比选择运算符高,下面的源码需要调整

int isp(char c)
{
switch (c)
{
case '#': return 0;
case '(': return 1;
case '': return 7;
case '|': return 5;
case '+': return 3;
case ')': return 8;
}
//若走到这一步,说明出错了
cerr << "ERROR!" << endl;
return false;
}
//in coming priority 栈外优先级,当前扫描到的字符的优先级
int icp(char c)
{
switch (c)
{
case '#': return 0;
case '(': return 8;
case '
': return 6;
case '|': return 4;
case '+': return 2;
case ')': return 1;
}
//若走到这一步,说明出错了
cerr << "ERROR!" << endl;
return false;
}

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

No branches or pull requests

1 participant