I am trying to create a NFA from a regular expression. I have a grasp on reading in the regular expression and being able to make a stack from it. The part I am struggling on is mapping the characters in the regular expression to an integer indicating the variables order in the expression. I am just not sure how to go about this. Any help is welcome. My code so far...
Code:
#include<stdio.h>
#include<stdlib.h>
#include "stack.h"
int main(void)
{
char expression[80];//array to store regular expression
char capital[130];//Array to store capital letters
int i=0,x=0,y=0,z=65;
char input;
while(scanf("%c",&input) != EOF){//check for end of input
if(!isspace((unsigned char)input)){//skip whitespaces
if((input != ')')&&(input != '(')){
for(i=i;i<80;i++){//initialize array with input
expression[x]=input;
x++;
break;
}
for(y=y;y<91;y++){//initialize letter array
if(input>=65 && input<=90){//check for capital
capital[input]=input;
pushChar(input);
}
break;
}
}
}
}
for(z=z;z<91;z++){
if(capital[z]>=65 && capital[z]<=90){//Print each letter once
printf("%c ",capital[z]);
}
}
printf("\n\n");
for(i=0;i<x;i++)//printing full regular expression
printf("%c",expression[i]);
printf("\n");
return 0;
}