The integer is used in the switch statement that dispatches the action,
and just has to be unique and match the case that you will add to the
switch statement, PROVIDED that the two low bits of the integer encode
the index (0-3) of the word that will be given the blame if the
execution fails. For example, adverb execution is the case
EDGE+AVN, VERB+NOUN, ADV, ANY,
and its number is 2+8 where the 2 means that the ADV word will be blamed
if there is error. (The 8 just makes the number unique).
EPZ is a macro in the file, meaning 'exit parse if result z is zero'.
Each stack entry has member a and t, where a is the A for the word and t
is the original word-number in case of error. The fork operated on
stack positions 1,2,3. The result goes to stack[3]; it includes the
result of the execution, stored to stack[3].a, and the word number to
assign to that result, which comes from an operand word, in this case
the word number of f in (f g h).
SM closes the stack by moving stack[0] to stack[2]
stack +=2 establishes a new stack pointer.
Henry
On 7/28/2016 4:58 PM, Thomas Costigliola 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