private void SetState(int state) {
                if (state == token_source.curLexState)
                        return;

                Token root = new Token(), last=root;
                root.next = null;

                // First, we build a list of tokens to push back, in backwards order
                while (token.next != null) {
                        Token t = token;
                        // Find the token whose token.next is the last in the chain
                        while (t.next != null && t.next.next != null)
                                t = t.next;

                        // put it at the end of the new chain
                        last.next = t.next;
                        last = t.next;

                        // If there are special tokens, these go before the regular tokens,
                        // so we want to push them back onto the input stream in the order
                        // we find them along the specialToken chain.

                        if (t.next.specialToken != null) {
                                Token tt=t.next.specialToken;
                                while (tt != null) {
                                        last.next = tt;
                                        last = tt;
                                        tt.next = null;
                                        tt = tt.specialToken;
                                }
                        }
                        t.next = null;
                }

        if ( root.next != null ) {
                token_source.backup( root.next.endColumn - last.beginColumn + 1 );
        }

                //while (root.next != null) {
                //	token_source.backup(root.next.image.length());
                //	root.next = root.next.next;
                //}
                jj_ntk = -1;
                token_source.SwitchTo(state);
        }