0
我想定義char(即'a AND'a'),但我在檢查錯誤時遇到問題。 在這裏,我如何編寫規則和檢查:flex,定義char
char " ' " {letter}
代碼
{char} {
int x =input() ;
//printf("%d",'a');
if(x == 10)
{
return(tCharunterm);
}
else if(x == '\'')
{
return(tChar);
}
else
{
yyerror("char overflow");
}
最後檢查它:
'a
token = tCharunterm, value = "(null)"
'a'
token = tChar, value = "(null)"
'as
char overflow
'asddd
char overflow
token = tIdentifier, value = "ddd"
^Z