GLR Machine

References: Constituent Structure

parseSS calls machine/8 using:

machine([0],ZLSS,[],[],accept,[],SS,_)
The parameters are:

Index Parameter Input/Output Value Description
1 Control Stack Input [0] List encodes stack. Begin at state 0.
2 Input Input Output of parsePF List of (zero-level) constituents.
3 Structure Stack Input [] List encodes stack. Each element is a constituent.
4 Environment Stack Input [] List encodes stack. Used for local storage during LR parsing.
5 Control Stack Output accept Not a stack anymore. Just the end state.
6 Input Output [] Input consumed.
7 Structure Stack Output Parse Not a stack anymore. Just a single constituent.
8 Environment Stack Output _ Don't care.

Definition of machine/8:

machine(accept,    []    ,[SS],_, accept,[],SS, _  ) :- !.
machine([State|CS],[I|Is],SS,  ES,CS2,   I2,SS2,ES2) :-
	ss0Cat(I,C),
	glrMachineHook,				  % platform-specific
	action(State,C,[State|CS],[I|Is],SS,ES,CS1,I1,SS1,ES1,_, _Action),
	machine(CS1,I1,SS1,ES1,CS2,I2,SS2,ES2).

% need to deal with the endmarker $ as a special category
ss0Cat(I,C) :- cat(I,C), !.
ss0Cat('$','$').
Non-determinism in the machine is expressed in the predicate action/12.

References: Constituent Structure