First, Experimental Purpose
compile a recursive descent analysis program.
Second, experimental content and requirements
Input: Normal type
Output: Determine if the normal formula is correct.
Third, test methods, procedures and results
1. source program name: Recursive descent analysis program . C
executable name: Recursive descent analysis program . EXE
2.
3. main procedural paragraphs and their explanations:
#include <stdio.h> #include <string> char str[50]; int index=0; void E (); e->tx; void X (); X->+tx | e void T (); t->fy void Y (); Y->*fy | e void F (); F-> (E) | I int main ()/* recursive parsing */{int len; int m; printf ("Please enter the number of times to test:"); scanf ("%d", &m); while (m--) {printf ("Please enter string (length <50>): \ n"); scanf ("%s", str); Len=strlen (str); str[len]= ' # '; str[len+1]= ' + '; E (); printf ("%s is a valid symbolic string!\n", str); strcpy (str, ""); index=0; } return 0; } void E () {T (); X ();} void X () {if (str[index]== ' + ') {index++; T (); X (); }} void T () {F (); Y (); } void Y () {if (str[index]== ' * ') {index++; F (); Y (); }} void F () {if (str[index]== ' I ') {index++;} else if (str[index]== ' (') {index++; E); if (str[index]== ') ') {index++;} else {printf ("\ nthe illegal symbolic string!\n"); Exit (0); }} else {printf ("illegal symbol string!\n"); Exit (0); } }
4.operational results and analysis
Four, Experimental Summary
Through this experiment, for recursion and have a new understanding of the work principle is further mastered. This experiment has helped me a lot.
Experimental study of three Recursive descent analysis program