Experimental study of three Recursive descent analysis program

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.