ll.h

来自「编译原理课程设计」· C头文件 代码 · 共 87 行

H
87 行
字号
#include "stdio.h"
#define SIZE 20
#define EMPTY 14
#define TABLE_SIZE 5

typedef struct table
...{
        char head;
        char  pre[8][4]; 
}table;

char ExpressionStr[SIZE];                       //Inputed Analysed Expression
char AnalysisStack[SIZE];                       //Analysis Stack
unsigned char analysis_Index;                   //
unsigned char analy_Index;                      //Current TOP_Index of Expression
unsigned char exp_Index;                        //Current Bottom_Index of Expression
unsigned char step;
table tb[TABLE_SIZE];                                               //forcast table---------------



/** *//***************************************
 @name:       InitTable
 @Describe:   Initlize the forcast table
 @Param:      void
 @Return:     void
 *****************************************/
void InitTable()
...{
     // table E
     tb[0].head = 'E';
     strcpy(tb[0].pre[0], "GT");
     strcpy(tb[0].pre[5], "GT");
     //table G
     tb[1].head = 'G';
     strcpy(tb[1].pre[1], "GT+");
     strcpy(tb[1].pre[2], "GT-");
     strcpy(tb[1].pre[6], "~");
     strcpy(tb[1].pre[7], "~");
     //table T
     tb[2].head = 'T';
     strcpy(tb[2].pre[0], "SF");
     strcpy(tb[2].pre[5], "SF");
     //table S
     tb[3].head = 'S';
     strcpy(tb[3].pre[1], "~");
     strcpy(tb[3].pre[2], "~");
     strcpy(tb[3].pre[3], "SF*");
     strcpy(tb[3].pre[4], "SF/");
     strcpy(tb[3].pre[6], "~");
     strcpy(tb[3].pre[7], "~");
     //table F
     tb[4].head = 'F';
     strcpy(tb[4].pre[0], "i");
     strcpy(tb[4].pre[5], ")E(");
}

/** *//***************************************
 @name:       PrintGenerate
 @Describe:   Printing Generate expression
 @Param:      void
 @Return:     void
 *****************************************/
 void PrintGenerate(char *ch)
 ...{
      int i = 0;
      for(i = strlen(ch) - 1; i >= 0; i--)
      ...{
            printf("%c",ch[i]);
      }
      printf(" ");
      
 }

/** *//*******************************************
*@name:        Trace
*@Description: Format output
*@Param:       void
*@Return:      void
********************************************/
void Trace()
...{
     int i = 0;
     int j = 0;
     printf(" ");
     printf("%d  ",step++);
     while(AnalysisStack[i] != '

⌨️ 快捷键说明

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