1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #include <iostream> using namespace std;
#ifndef LL1_H #define LL1_H
#define LEN_VT 8 #define LEN_VN 5
struct stack { char ch; stack *next; stack *front; };
class LL1 { public: LL1(char input[], int len); void stack_pop(char *ch); void stack_push(char ch); bool isVn(char ch); int getIndex(char ch, char table[], int len);
void Atable(); void show(int step, char *in, string CA, string action); private: stack *bp,*sp; char X, Y; char Vt[8] = {'i', '(', ')', '*', '/', '+', '-', '#'}; char Vn[5] = {'E', 'G', 'T', 'S', 'F'}; char input[10];
string vTable[5][8] = { {"E->TG", "E->TG", "Error", "Error", "Error", "Error", "Error", "Error"}, {"Error", "Error", "G->~", "Error", "Error", "G->+TG", "G->-TG", "G->~"}, {"T->FS", "T->FS", "Error", "Error", "Error", "Error", "Error", "Error"}, {"Error", "Error", "S->~", "S->*FS", "S->/FS", "S->~", "S->~", "S->~"}, {"F->i", "(E)", "Error", "Error", "Error", "Error", "Error", "Error"} }; };
#endif
|