⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nepcmain.c

📁 一个小计算器的实现(编译原理),用Lex和bison
💻 C
字号:
#include <stdio.h>#include "nepc.tab.h"#include "nepc.h"extern int yyparse();extern FILE * yyin;void yyerror(char *s) 
{
    fprintf(stdout, "%s\n", s);
}void motd(){    printf("--------------------------------------------------------------\n");    printf(">> nepc-0.2-r2 - A mini limited precision interpreting calculator.\n");    printf(">> Copyright (C) 2005 neplusultra@linuxsir.org\n");    printf(">> nepc is open software; you can redistribute it and/or modify\n\   it under the terms of the version 2.1 of the GNU Lesser \n\   General Public License as published by the Free Software\n\   Foundation.\n>> Type 'exit' to quit, type 'help' to get help.\n");    printf("--------------------------------------------------------------\n");}void init(){  sysInfo.first=0;  sysInfo.sysHead=sysInfo.sysTail=NULL;  sysInfo.G_sys_number=0;
  sentenceArrayLen=0;}int main(void) {	nodeType *p;    nodeType *p2;    int size;     nodeType *test[3];//////////////////////////////////////////////////////////////   int i=0;   int result=0;   nodeType * itp;   nodeType * itp2;   init();    motd();	i=sizeof(sysType);	printf("sysType  size::%d\n",i);	i=sizeof(nodeType);	printf("nodeType  size::%d\n",i);    G_line=1;	G_level=1;    yyin=fopen("c:\\input.c","r"); /* set parse stream to standard input */    if(yyin==NULL)    	{    	  printf("open error!\n");	  return 0;    	}    result=yyparse(); /* begin parse */	if(result)	{		printf("error happen !!!!!!!!:%d\n",G_line);	}    fclose(yyin);     for(i=0;i<sentenceArrayLen;i++)    	{    	itp=sentenceArray[i];    	interpret(itp);     	}    printf("line:%d\n",G_line);////////////////////////////////////////////////////////////////////////    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -