/* a translation of parts of pages 88 to ?? into C++ */ /* WARNING: this is very incomplete and will not compile */ #include #include #include class node; typedef node* ptr; class node{ public: ptr right; char id; int val; }; class node2; typedef node* ptr2; class node2{ public: ptr2 right; int val; }; ptr p,q,r; ptr2 result, p2; int error; char lex; char get(); void push(int); int pop(); int obtain(char lex) { bool found; q=p; found=false; while( (q!=NULL) and (! found) ) { if (q->id == lex) { found=true; return q->val; } else { q=q->right; } } if(! found) return error; } bool f() { if( ('a' <= lex) and (lex <='z')) { push(obtain(lex)); lex=get(); return true; } else { cout << "expected id and found trash" << endl; return false; } } int main() { return 0; }