You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Demonstrate a lexical analyzer for given language. Although the syntax specification states that identifiers can be arbitrarily long, you may restrict the length to some reasonable value. Simulate the same in C language.
#include<stdio.h>#include<string.h>intmain()
{
charkeywords[32][8] = {
"auto", "double", "int", "struct", "break", "else", "long",
"switch", "case", "enum", "register", "typedef", "char",
"extern", "return", "union", "const", "float", "short",
"unsigned", "continue", "for", "signed", "void", "default",
"goto", "sizeof", "volatile", "do", "if", "static", "while"};
charinput[6];
inti, flag=0;
printf("Enter value : ");
scanf("%s", input);
for (i=0; i<32; i++)
if (strcmp(input, keywords[i]) ==0)
flag=1;
if (flag==1)
printf("%s is a keyword.", input);
elseprintf("%s is not a keyword.", input);
}