词法分析的注释代码怎么写
1个回答
展开全部
while (c = getchar())
{
switch(status) {
{
case START:
if ( c == '(') status = LP;
break;
case LP:
if ( c == '*') status = COMMENT;
break;
case COMMENT:
if (c == '*') status = RP;
break;
case RP:
if (c == ')') status = END;
if (c == '*') status = RP;
else status = COMMENT;
break;
default:
//status == END;
break;
}
}
}
追答
while (c = getchar())
{
switch(status) {
{
case START:
if ( c == '(') status = LP;
if ( c == '/') status = LINE;
break;
case LP:
if ( c == '*') status = COMMENT;
break;
case COMMENT:
if (c == '*') status = RP;
break;
case RP:
if (c == ')') status = END;
if (c == '*') status = RP;
else status = COMMENT;
break;
case LINE:
if (c == '/') status = LINECOMMENT;
else status = START;
break;
case LINECOMMENT:
if (c == '\n') status = END;
break;
default:
//status == END;
break;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询