Before you go changing the C code, you should probably test your
proposal by working with a copy of trace.ijs
(addons/general/misc/trace.ijs). Presumably you have already done
that, so...

... for your first question, you seem to be in p.c and looking at what
was this code:

// for speed, we encode the stack offset of the token-on-error offset
into bits 1-2 of the index of the action routine
#define PMONAD1 2+0
#define PMONAD2 4+0
#define PDYAD 4+1
#define PADV 4+8
#define PCONJ 4+9
#define PTRIDENT 2+1
#define PBIDENT 2+8
#define PASGN 2+9
#define PPAREN 6+0   // error offset immaterial, since never fails
#define PNOMATCH 0

ACTF casefuncs[] = {0, 0, jtmonad1, jttrident, jtmonad2, jtdyad,
jtpunc, 0, 0, 0, jtbident, jtis, jtadv, jtconj};

Those defines look like an indices into casefuncs, and there's a bit
of folding/overloading here which you can see in action where i is
computed from these values down below, then used. Depending on what
you are doing, you might need to do a complete rewrite of the code
that computes dci (along with a completely different set of these
defines) to unfold and separate dci from the index into casefuncs.

Thanks,

-- 
Raul




On Thu, Jul 28, 2016 at 4:58 PM, Thomas Costigliola <fo...@iocane.net> wrote:
> Henry, how does one go about adding a new parsing rule in the new parser?
>
> Previously, I would add an ACTION to define what happens and then add an
> entry to "PT cases[]". Now, it seems I have to add something like
>
> #define PMONAD1 1+0
>
> and an action in the switch statement below.
>
> But how do I know what integer to put in the number define?
>
> And what is the purpose of the statements in the action:
>
> EPZ(stack[3].a = folk(stack[1].a, stack[2].a, stack[3].a)); // Pretty
> obvious
> stack[3].t = stack[1].t;                                    // What does
> this do ?
> SM(2,0);                                                    // What does
> this do ?
> stack += 2;                         // I guess we used 3 items and got one
> back so we advanced 2 places ???
>
> Thanks.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to