Exemple #1
0
        //20170403
        //#include "pgenheaders.h"
        //#include "grammar.h"
        //#include "node.h"
        //#include "token.h"
        //#include "parser.h"

//		static void fixdfa(grammar *, dfa *);
//		static void fixstate(grammar *, state *);

        public static void PyGrammar_AddAccelerators(grammar g)
        {
            dfaPtr d;
            int    i;

                #if _DEBUG
            fprintf(stderr, "Adding parser accelerators ...\n");
                #endif
            d = new dfaPtr(g.g_dfa);
            for (i = g.g_ndfas; --i >= 0; d.inc())
            {
                fixdfa(g, d[0]);
            }
            g.g_accel = 1;
                #if _DEBUG
            fprintf(stderr, "Done.\n");
                #endif
        }
Exemple #2
0
        public static void PyGrammar_RemoveAccelerators(grammar g)
        {
            dfaPtr d;
            int    i;

            g.g_accel = 0;
            d         = new dfaPtr(g.g_dfa);
            for (i = g.g_ndfas; --i >= 0; d.inc())
            {
                statePtr s;
                int      j;
                s = new statePtr(d[0].d_state);
                for (j = 0; j < d[0].d_nstates; j++, s.inc())
                {
                    if (null != s[0].s_accel)
                    {
                        PyMem_DEL(ref s[0].s_accel);
                    }
                    s[0].s_accel = null;
                }
            }
        }