Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/t20src/diupattoken.req
There are 4 other files named diupattoken.req in the archive. Click here to see a list.
!	COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1986.
!	ALL RIGHTS RESERVED.
!
!	THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY  BE  USED  AND
!	COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH
!	THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.   THIS  SOFTWARE  OR
!	ANY  OTHER  COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
!	AVAILABLE TO ANY OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE
!	SOFTWARE IS HEREBY TRANSFERRED.
!
!	THE INFORMATION IN THIS SOFTWARE IS  SUBJECT  TO  CHANGE  WITHOUT
!	NOTICE  AND  SHOULD  NOT  BE CONSTRUED AS A COMMITMENT BY DIGITAL
!	EQUIPMENT CORPORATION.
!
!	DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF
!	ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.
!
! DIUPATTOKEN.REQ

!++
! FACILITY: 	PAT Parser
!
! ABSTRACT:
!
!	PATTOKEN.REQ is the external specification for the
!	parser token buffer management routines.
!
! ENVIRONMENT:	VAX/VMS user mode
!
! AUTHOR:  Charlie Mitchell, CREATION DATE:  9-Nov-1981
!
! MODIFIED BY:
! 001 - C. Richardson 25-May-84 Remove VMS dependencies.
!
!  253  Rename file to DIUPATTOKEN.
!       Gregory A. Scott 1-Jul-86
!
!--

require 'DIUPATREQPRO';

library 'DIUPATLANGSP';
! PAT$TOKEN_CURRENT_PTR is the current token pointer.  It is set everytime
! that PAT$TOKEN_GET is called.  Thus, it contains a pointer to
! a "future" lexical token when parse ahead is being done.

%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_CURRENT_PTR			=	TOKCUR %;	! 001
%FI								! 001

external
    PAT$TOKEN_CURRENT_PTR;
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_INIT_BUFFER			=	TOKINB %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_INIT_BUFFER : novalue;

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine initializes the token buffer and should
!	be called at the start of a parse.
!
! FORMAL PARAMETERS:
!
!	NONE
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_GET				=	TOKGET %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_GET;

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine gets the next token either by taking it from the
!	list of tokens which have been read but not consumed or, if
!	there are none, by calling the lexical analyzer.
!	A pointer to then new token is assigned to PAT$TOKEN_CURRENT_PTR.
!
! FORMAL PARAMETERS:
!
!	CONSUME		- Boolean variable.  If TRUE then tokens are consumed,
!			  if FALSE then they are saved for future use.
!
! IMPLICIT OUTPUTS:
!
!	PAT$TOKEN_CURRENT_PTR
!
! ROUTINE VALUE:
!
!	Terminal symbol number of token that was fetched
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_BUF_HEAD			=	TOKBHD %,	! 001
PAT$TOKEN_BUF_TAIL			=	TOKBTL %;	! 001
%FI								! 001

! This macro is equivalent to a call to PAT$TOKEN_GET (TRUE)

macro
    PAT$TOKEN_GET_CONSUME =
	begin

	external
	    PAT$TOKEN_BUF_HEAD,
	    PAT$TOKEN_BUF_TAIL;

	if (.PAT$TOKEN_BUF_HEAD eql .PAT$TOKEN_BUF_TAIL)
	then 					! Empty buffer
	    PAT$TOKEN_CURRENT_PTR = LS_GET_LEX_TOKEN
	else 					! Unread tokens in buffer
	    begin
	    PAT$TOKEN_CURRENT_PTR = ..PAT$TOKEN_BUF_HEAD;
	    PAT$TOKEN_ADVANCE (PAT$TOKEN_BUF_HEAD);
	    end;

	LS_LEX_TERM (PAT$TOKEN_CURRENT_PTR)
	end
    %;
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_SAVE				=	TOKSAV %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_SAVE : novalue;

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine saves TOKEN_PTR in the token buffer
!	so that it will be the next one returned by PAT$TOKEN_GET.
!	If PERMANENT is FALSE, this change will only affect
!	the current error recovery attempt.
!
! FORMAL PARAMETERS:
!
!	TOKEN_PTR	Token to be saved
!
!	PERMANENT	TRUE if definite correction,
!			FALSE if temporary change for trial correction
!
!--

! This macro is equivalent to a call to PAT$TOKEN_SAVE (XXX, TRUE)

macro
    PAT$TOKEN_SAVE_PERMANENT (TOKEN_PTR) =
	begin

	external
	    PAT$TOKEN_BUF_HEAD;

	PAT$TOKEN_BACKUP (PAT$TOKEN_BUF_HEAD);
	.PAT$TOKEN_BUF_HEAD = (TOKEN_PTR);
	end
    %;
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_SAVE_BUF		=	TKSVBF %;		! 001
%FI								! 001

external routine
    PAT$TOKEN_SAVE_BUF;

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine saves the first n tokens (or all tokens) in the
!	token buffer in temporary storage so that they can be
!	restored after an error recovery attempt.  The tokens can
!	be restored by calling PAT$TOKEN_RESTORE_BUF.
!
! FORMAL PARAMETERS:
!
!	SAVE_UPTO	- number of tokens to be saved
!
! RETURN VALUE:
!
!	Number of tokens saved
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_RESTORE_BUF			=	TKRSBF %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_RESTORE_BUF : novalue;

!++
! FUNCTIONAL DESCRIPTION
!
!	This routine restores tokens saved by the previous call
!	to PAT$TOKEN_SAVE_BUF.
!
! FORMAL PARAMTERS:
!
!	NUM_TOKENS	- Value returned on prior call to
!			  PAT$TOKEN_SAVE_BUF.
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_RESET_BUFFER		=	TKRSTB %;		! 001
%FI								! 001

external routine
    PAT$TOKEN_RESET_BUFFER : novalue;

!++
! FUNCTIONAL DESCRIPTION
!
!	This routine undoes the effect of non-consumed gets (via
!	calls to PAT$TOKEN_GET) and non-permanent saves (via calls
!	to PAT$TOKEN_SAVE) since the last consumed get or permanent
!	save.
!
! FORMAL PARAMTERS:
!
!	NONE
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_TEMP_HEAD			=	TOKTMH %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_TEMP_HEAD;

!++
! FUNCTIONAL DESCRIPTION
!
!	Routines PAT$TOKEN_TEMP_HEAD and PAT$TOKEN_SET_TEMP_HEAD
!	are used to save and restore the pointer to
!	the "first" token in the temporary token buffer.
!
!	Example of usage:
!
!	    begin
!		local SAVED_TEMP_HEAD;
!		SAVED_TEMP_HEAD = PAT$TOKEN_TEMP_HEAD ();
!		...
!		PAT$TOKEN_SET_TEMP_HEAD (.SAVED_TEMP_HEAD)
!
!	PAT$TOKEN_SET_HEAD can be used to modify the actual buffer.
!
! FORMAL PARAMTERS:
!
!	NONE
!
! RETURN VALUE:
!
!	Pointer to the first token in the temporary token buffer.
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_DET_TEMP_HEAD		=	TOKSTH %;		! 001
%FI								! 001

external routine
    PAT$TOKEN_SET_TEMP_HEAD : novalue;

!++
! FUNCTIONAL DESCRIPTION
!
!	See PAT$TOKEN_TEMP_HEAD.
!
! FORMAL PARAMTERS:
!
!	TEMP_HEAD	Value returned on previous call to
!			PAT$TOKEN_TEMP_HEAD
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_SET_HEAD			=	TOKSEH %;	! 001
%FI								! 001

external routine
    PAT$TOKEN_SET_HEAD : novalue;

!++
! FUNCTIONAL DESCRIPTION
!
!	See PAT$TOKEN_TEMP_HEAD.
!
! FORMAL PARAMTERS:
!
!	HEAD		Value returned on previous call to
!			PAT$TOKEN_TEMP_HEAD
!
!--
! The macros that follow are not intended for direct use outside of
! PATTOKEN.


%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$TOKEN_BUF_HIGH			=	TOKBFH %,	! 001
PAT$TOKEN_BUF_LOW			=	TOKBFL %;	! 001
%FI								! 001

macro
    PAT$TOKEN_ADVANCE (BUF_PTR) =
	begin

	external
	    PAT$TOKEN_BUF_HIGH,
	    PAT$TOKEN_BUF_LOW;

	if .BUF_PTR eql .PAT$TOKEN_BUF_HIGH
	then
	    BUF_PTR = .PAT$TOKEN_BUF_LOW
	else
	    BUF_PTR = .BUF_PTR + %upval

	end
    %;

macro
    PAT$TOKEN_BACKUP (BUF_PTR) =
	begin

	external
	    PAT$TOKEN_BUF_HIGH,
	    PAT$TOKEN_BUF_LOW;

	if .BUF_PTR eql .PAT$TOKEN_BUF_LOW
	then
	    BUF_PTR = .PAT$TOKEN_BUF_HIGH
	else
	    BUF_PTR = .BUF_PTR - %upval

	end
    %;
%if PATBLSEXT_DEBUGGING
%then

external routine
    PAT$DUMP_TOKEN : novalue;

!++
! FUNCTIONAL DESCRIPTION:
!
!	PAT$DUMP_TOKEN outputs the lexical token pointed to by PAT$TOKEN_CURRENT_PTR.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	PAT$TOKEN_CURRENT_PTR
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--
%IF %BLISS (BLISS36)						! 001
%THEN								! 001
macro								! 001
PAT$DUMP_TKN_BUF			=	DMPTKB %;	! 001
%FI								! 001

external routine
    PAT$DUMP_TKN_BUF : novalue;

!++
! FUNCTIONAL DESCRIPTION:
!
!	PAT$DUMP_TKN_BUF outputs the buffer of tokens read but not consumed
!	and the temporary buffer of tokens used in local error recovery.
!	When called other than during local error recovery the temporary
!	buffer may contain some "garbage".
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	TKN_BUF_HEAD
!
!	TKN_BUF_TEMP_HEAD
!
!	TKN_BUF_TAIL
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

%fi

! End of PATTOKEN.REQ