Hello I want to define char (ie 'a AND 'a') but I am having issues in checking errors. Here how I write the rule and check:
char " ' " {letter}
code
{char} {
int x =input() ;
//printf("%d",'a');
if(x == 10)
{
return(tCharunterm);
}
else if(x == '\'')
{
return(tChar);
}
else
{
yyerror("char overflow");
}
And finally checking it:
'a
token = tCharunterm, value = "(null)"
'a'
token = tChar, value = "(null)"
'as
char overflow
'asddd
char overflow
token = tIdentifier, value = "ddd"
^Z