如何在c++中的lex或yacc中使用shift、reduce、error、accept和conflict关键字?
这些关键字的含义是什么:
shift
、reduce
、error
、accept
、conflict?
请对每一项进行完整描述。
switch ( oAction)
{
case SSYaccAction::shift:
oElement = shift( lookahead());
if ( !oElement) return SSTrue;
oElement->oLexeme = lookahead();
oElement->oulState = state();
push();
if ( getLexeme()) return SSTrue;
oulError++;
break;
case SSYaccAction::reduce:
oElement = reduce( production(), productionSize());
if ( !oElement) return SSTrue;
pop( productionSize());
if ( goTo( leftside())) return SSTrue;
break;
case SSYaccAction::error:
oError = SSTrue;
if ( error( state(), lookahead()))
return SSTrue;
oulError = 0;
break;
case SSYaccAction::accept:
return accept();
default:
throwException( SSExceptionYaccParse, SSYaccMsgParse);
return SSTrue;
含义是什么
lookahead()
上面代码中,和 的
reduce(production(), productionSize())
What are the meanings of these keywords:
shift
, reduce
, error
, accept
, conflict
?
Please give a full description of each.
switch ( oAction)
{
case SSYaccAction::shift:
oElement = shift( lookahead());
if ( !oElement) return SSTrue;
oElement->oLexeme = lookahead();
oElement->oulState = state();
push();
if ( getLexeme()) return SSTrue;
oulError++;
break;
case SSYaccAction::reduce:
oElement = reduce( production(), productionSize());
if ( !oElement) return SSTrue;
pop( productionSize());
if ( goTo( leftside())) return SSTrue;
break;
case SSYaccAction::error:
oError = SSTrue;
if ( error( state(), lookahead()))
return SSTrue;
oulError = 0;
break;
case SSYaccAction::accept:
return accept();
default:
throwException( SSExceptionYaccParse, SSYaccMsgParse);
return SSTrue;
In the above code, what are the meanings of
lookahead()
and
reduce(production(), productionSize())
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(在评论中回答。 )
@KLibby 写道:
(Answered in the comments.)
@KLibby wrote: