网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 交易代码 > 课程设计 > 正文

递归下降语法分析器源代码

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务
递归下降语法分析器源代码#i nclude "stdio.h"#i nclude "malloc.h"
void e();void f();void t();void t1();void e1();
struct Lchar{ char char_ch; struct Lchar *next;}Lchar,*p,*h,*temp;char ch;int right;
void e(void){ t(); e1();}
void t(void){ f(); t1();}
void t1(void){ if(h->char_ch=='*') {  h=h->next;  f();  t1(); } else  if(h->char_ch!='#'&&h->char_ch!=')'&&h->char_ch!='+')   right=0;}
void e1(void){ if(h->char_ch=='+') {  h=h->next;  t();  e1(); } else  if(h->char_ch=='#'||h->char_ch==')')   return;  else   right=0;}
void f(){ if(h->char_ch=='i')  h=h->next; else  if(h->char_ch=='(')  {   h=h->next;   e();   if(h->char_ch==')')    h=h->next;   else    right=0;  }  else   right=0;}
void main(void){ right=1; h=malloc(sizeof(Lchar)); h->next=NULL; p=h; do{  ch=getch();  putch(ch);  if(ch=='i'||ch=='+'||ch=='*'||ch=='('||ch==')'||ch=='#')  {   temp=malloc(sizeof(Lchar));   temp->next=NULL;   temp->char_ch=ch;   h->next=temp;   h=h->next;  }  else  {   temp=p->next;   printf("\nInput a wrong char!Input again:\n");   for(;;)   {        if (temp!=NULL)     printf("%c",temp->char_ch);          else     break;    temp=temp->next;   }  } }while(ch!='#'); p=p->next; h=p; e(); if(h->char_ch=='#'&&right)  printf("\nOK!\n"); else  printf("\nError!\n"); getchar();}
  • 上一篇资讯: ASP学生管理系统
  • 设为首页 | 加入收藏 | 网学首页 | 原创论文 | 计算机原创
    版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师