C program for Syntax Analyzer

C program for Syntax Analyzer

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{
int i,j,k=0,count,inc=0,n;
char name[30],open[30],ch,chh,o[30];
char op[20]={'=','+','-','*','/','%','^','&','|'};
clrscr();
textcolor(3);
cprintf("--Syntax Analyser--");
printf("\n");
printf("\n Enter Syntax");
printf("\n");
scanf("%s",name);
n=strlen(name);
for(i=0;i<n;i++)
{
ch=tolower(name[i]);
for(j=0;j<9;j++)
{
if(ch==op[j])
{
open[k]=i;
o[k]=ch;
k++;
}
}
}
for(i=0;i<k;i++)
{
count=open[i];
ch=tolower(name[count-1]);
chh=tolower(name[count+1]);
if(isalpha(ch)&&isalpha(chh)||isdigit(chh))
++inc;
}
if(k==inc)
printf("\n %s is a valid syntax",name);
else
printf("\n %s is an invalid syntax",name);
getch();
}
Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

7 thoughts on “C program for Syntax Analyzer

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in