برنامه اسکنر زبان بیسیک :
/*######################################################################*/
#include <stdio.h>
#include<process.h>
#include<stdlib.h>
#include <conio.h>
#include <string.h>
#include <dir.h>
void scan(void);
char str[6],n[20],enter[20];
int comp,counter,count,last=0,get=0,grade=0,rad=0,ch,j=0;
char *word[9]={"let","goto","print","end","to","step","next","if","for"};
char *operand[13]={"/","-","+","^","=","*",")","(","<>","<=",">=","<",">"};
void main(void)
{
clrscr();
textbackground(13);
gotoxy(2,2);
printf(" enter a statement in programing basic :\n");
gets(enter);
strcpy(n,enter);
scan();
}
/*############################ üَ¬گ ùُ‘÷¤“ ِ‘‘• ########################*/
void scan(void)
{
textmode(BW40);
textcolor(10);
textbackground(13);
int j=0,rad=0,get=0,last=0;
for(counter=0; counter<6;counter++)
str[counter]='\0';
while(n[grade] != ' '&& n[grade] != NULL)
{
str[j]=n[grade];
j++;
grade++;
}/*END OF WHILE*/
grade++;
for(count=0;count<9;count++)
{
comp=strcmp(str,word[count]);
if(!comp)
{
printf(" %s IS A KEY WORD .\n",word[count]);
last=1;
}/*END OF IF*/
} /*END OF FOR*/
if(last)
scan();
else
if(!last)
for(count=0;count<13;count++)
{
comp=strcmp(str,operand[count]);
if(!comp)
{
printf(" %s IS A FAILUR SIGN.\n",operand[count]);
get=1;
} /*END OF IF*/
}/*END OF FOR*/
if(get)
scan();
else
if(!get)
for(ch='a';ch<='z';ch++)
{
if(str[0] == ch)
{
printf(" %s IS A VARIABL.\n",str);
rad=1;
}/*END OF IF*/
}/*END OF FOR*/
if(rad)
scan();
else
if(!rad)
{
if(n[grade]== '\0')
exit(0);
printf(" %d IS A NUMBER .\n",atoi(str));
scan();
getch();
}/*END OF IF*/
}/*END OF SCAN*/
/*#####################################################################*/