fork download
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <ctype.h>
  4.  
  5. char buffer[30];//For storing the input string
  6. int i=0;//index into the array of input string
  7. void S();
  8. void E();
  9. void T();
  10. void T1();
  11. void F();
  12. void A();
  13. void E1();
  14. void S()
  15. {
  16. printf("\nThe Production S => A=E is used");
  17. A();
  18. if(buffer[i]=='=')
  19. {
  20. printf("\n......Match the terminal =");
  21. i++;
  22. E();
  23. }
  24. else
  25. {
  26. printf("\nError Condition ");
  27. exit();
  28. }
  29. }
  30. void A()
  31. {
  32. if(isalpha(buffer[i]))
  33. {
  34. printf("\n......Match the terminal %c",buffer[i]);
  35. i++;
  36. }
  37. else
  38. {
  39. printf("\nError condition");
  40. exit();
  41. }
  42. }
  43. void E()
  44. {
  45. printf("\nThe Production E => T E1 is used");
  46. T();
  47. E1();
  48. }
  49. void E1()
  50. {
  51. if(buffer[i]=='+')
  52. {
  53. printf("\nThe production E1 => +T E1 is used");
  54. printf("\n......Match the terminal +");
  55. i++;
  56. T();
  57. E1();
  58. }
  59. else
  60. printf("\nThe production E1 => <Epsilon> is used");
  61. }
  62. void T()
  63. {
  64. printf("\nThe Production T => F T1 is used");
  65. F();
  66. T1();
  67. }
  68. void T1()
  69. {
  70. if(buffer[i]=='*')
  71. {
  72. printf("\nThe production T1 => *F T1 is used");
  73. printf("\n......Match the terminal *");
  74. i++;
  75. F();
  76. T1();
  77. }
  78. else
  79. printf("\nThe production T1 => <Epsilon> is used");
  80. }
  81. void F()
  82. {
  83. if(buffer[i]=='(')
  84. {
  85. printf("\nThe production F => (E) is used");
  86. printf("\n......Match the terminal (");
  87. i++;
  88. E();
  89. if(buffer[i]==')')
  90. {
  91. printf("\n.....Match the terminal )");
  92. i++;
  93. }
  94. else
  95. {
  96. printf("\nError condition");
  97. exit();
  98. }
  99. return;
  100. }
  101. if(buffer[i]=='a')
  102. {
  103. printf("\nThe production F => a is used");
  104. printf("\n......Match the terminal a");
  105. i++;
  106. return;
  107. }
  108. if(buffer[i]=='b')
  109. {
  110. printf("\nThe production F => b is used");
  111. printf("\n......Match the terminal b");
  112. i++;
  113. return;
  114. }
  115. printf("\nError condition");
  116. exit();
  117. }
  118. void main()
  119. {
  120. clrscr();
  121. printf("\nEnter input string:");
  122. gets(buffer);
  123. S();
  124. printf("\nIt is a valid string");
  125. getch();
  126. }
  127.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.m:2:19: fatal error: conio.h: No such file or directory
compilation terminated.
stdout
Standard output is empty