Google
 

Trailing-Edge - PDP-10 Archives - bb-h138f-bm - 7-sources/diusem.bli
There are 4 other files named diusem.bli in the archive. Click here to see a list.
MODULE DIUSEM (ident = '253'
	%require ('DIUPATSWITCH')
		) =
begin

!	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.
!
!++
! FACILITY:	PAT parser
!
! ABSTRACT:
!
!	PATSEM.BLI.  PAT/BLISS interface.  Definition of parse tables.
!	Logically part of PATDAT.BLI.
!
!	This file is generally language independent.  (See PATDATA.REQ.)
!
! ENVIRONMENT:
!
! AUTHOR:  C. Mitchell, CREATION DATE:  18-Feb-80
!
! MODIFIED BY:
!
! 	Charlie Mitchell, 03-Sep-81 : VERSION X1-001
! 001 - Define the parse tables as an abstract data type.
!
! 9-Sep-1983, allow semacts to have holes for text table
!
! 003 - Remove VMS dependencies.  C. Richardson 25-May-84.
!
! 004 - C. Richardson 13 Aug 85
!	Allow debug compilation without debug output
!
!--
! INCLUDE FILES:

require 'DIUPATPROLOG';

library 'DIUPATDATA';

library 'BLI:XPORT';					! 003
! TABLE OF CONTENTS FOR INTERNAL ROUTINES:

!forward routine (it's global, folks)

!	PAT$DATA_NEXT_TRANSITION: no value;
! Define general macros

macro
    EXPAND_ARG_LIST [A] =
	! Expand an argument list with comma separators
	A
    %;
! Define macros in PAT_REQUIRE_FILE that must be defined for
! correct compilation but that aren't needed here.

macro
    PAT_INTERNAL_DEFINITIONS (A) =
    %,						! null
    PAT_INTRNLDEF (NAME, VALUE) =
    %;
! Define macros for definition of symbol text table:


! Define PAT$DATA_SYMBOL_TEXT_TABLE as a vector of string
! descriptors (not pointers to string descriptors) for the
! text of the terminal (and non-terminal if debugging) symbols.

macro
    PAT_SYMBOL_DEFINITIONS (A) =
	%;							! null
!	global	
!	    PAT$DATA_SYMBOL_TEXT_TABLE :				! 003
!		blockvector [%length, STR$K_F_BLN] field (		! 003
!		    STR$B_CLASS,					! 003
!		    STR$B_DTYPE,					! 003
!		    STR$H_LENGTH,					! 003
!		    STR$A_POINTER )					! 003
!	    PRESET (							! 003
!		EXPAND_ARG_LIST (A, %remaining) 
!	    );			! 003 blockvector of string descriptors

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_symbol_definitions_dummy = begin return 0; end;
!    %;

! Declared terminal symbol definitions:

macro
    PAT_DECTRMDEF (SYMBOL_NAME, EXT_NAME, VALUE) =
	%;						! null
!	[value, STR$B_CLASS] = STR$K_CLASS_F,				! 003
!	[value, STR$B_DTYPE] = STR$K_DTYPE_T,				! 003
!	[value, STR$H_LENGTH] = %charcount (symbol_name),		! 003
!	[value, STR$A_POINTER] = ch$ptr (uplit (symbol_name)) %;	! 003

! Undeclared terminal symbol definitions:

macro
    PAT_UNDTRMDEF (SYMBOL_NAME, VALUE) =
	%;						! null
!	[value, STR$B_CLASS] = STR$K_CLASS_F,				! 003
!	[value, STR$B_DTYPE] = STR$K_DTYPE_T,				! 003
!	%if PATBLSEXT_DEBUGGING
!	%then
!	    [value, STR$H_LENGTH] = 11,					! 003
!	    [value, STR$A_POINTER] = ch$ptr (uplit ('**UNDEFINED'))	! 003
!	%else
!	    [value, STR$H_LENGTH] = 0,					! 003
!	    [value, STR$A_POINTER] = ch$ptr (uplit (0))			! 003
!	%fi
!    %;
! Non-terminal definitions:

macro
    PAT_NONTRMDEF (NAME, VALUE) =
	%;						! null
!	[value, STR$B_CLASS] = STR$K_CLASS_F,				! 003
!	[value, STR$B_DTYPE] = STR$K_DTYPE_T,				! 003
!	%if PATBLSEXT_DEBUGGING
!	%then
!	    [value, STR$H_LENGTH] = %charcount (name),			! 003
!	    [value, STR$A_POINTER] = ch$ptr (uplit (name))		! 003
!	%else
!	    [value, STR$H_LENGTH] = 0,					! 003
!	    [value, STR$A_POINTER] = ch$ptr (uplit (0))			! 003
!	%fi
!    %;

! Unused symbol numbers:

macro
    PAT_UNUSEDNUM (NUM) =
	%;						! null
!	[num, STR$B_CLASS] = STR$K_CLASS_F,				! 003
!	[num, STR$B_DTYPE] = STR$K_DTYPE_T,				! 003
!	[num, STR$H_LENGTH] = 0,					! 003
!	[num, STR$A_POINTER] = ch$ptr (uplit (0))			! 003
!    %;
! Define literals and macros for parse tables:

literal
    PAT_CONT_CODE = PAT$DATA_CONT_CODE,
    PAT_ELSE_CODE = PAT$DATA_ELSE_CODE,
    PAT_SCAN_CODE = PAT$DATA_SCAN_CODE,
    PAT_ERROR_CODE = PAT$DATA_ERROR_CODE;

! Define PAT$DATA_STATE_SYMBOL_TABLE.

macro
    PAT_STATE_SYMBOL_TABLE (A) =
	%;						! null
!	global bind
!	    PAT$DATA_STATE_SYMBOL_TABLE = uplit %BLISS32 (PAT_STATE_SYMBOL_TABLE_ALLOC) (	! 003
!		EXPAND_ARG_LIST(A, %remaining)
!	    ) : vector [%BLISS32 (, PAT_STATE_SYMBOL_TABLE_ALLOC)];	! 003

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_state_symbol_table_dummy = begin return 0; end;
!    %;

! Define PAT$DATA_STATE_ACTION_TABLE.

macro
    PAT_STATE_ACTION_TABLE (A) =
	%;					! null
!	global bind
!	    PAT$DATA_STATE_ACTION_TABLE = uplit %BLISS32 (PAT_STATE_ACTION_TABLE_ALLOC) (	! 003
!		EXPAND_ARG_LIST(A, %remaining)
!	    ) : vector [%BLISS32 (, PAT_STATE_ACTION_TABLE_ALLOC, signed)];! 003

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_state_action_table_dummy = begin return 0; end;
!    %;

! Define PAT$DATA_RHS_COUNT_TABLE.

macro
    PAT_RHS_COUNT_TABLE (A) =
	%;					! null
!	global bind
!	    PAT$DATA_RHS_COUNT_TABLE =
!		uplit %BLISS32 (PAT_RHS_COUNT_TABLE_ALLOC) (		! 003
!		EXPAND_ARG_LIST(A, %remaining)
!	    ) : vector [%BLISS32 (, PAT_RHS_COUNT_TABLE_ALLOC)];	! 003

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_srhs_count_table_dummy = begin return 0; end;
!    %;

! Define PAT$DATA_LHS_TABLE.

macro
    PAT_LHS_TABLE (A) =
	%;					! null
!	global bind
!	    PAT$DATA_LHS_TABLE = uplit %BLISS32 (PAT_LHS_TABLE_ALLOC) (	! 003
!		EXPAND_ARG_LIST(A, %remaining)
!	    ) : vector [%BLISS32 (, PAT_LHS_TABLE_ALLOC)];	! 003

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_lhs_table_dummy = begin return 0; end;
!    %;

! Define PAT$DATA_SEMACT_TABLE.

macro
    PAT_SEMACT_TABLE (A) =
	%;					! null
!	global bind
!	    PAT$DATA_SEMACT_TABLE =
!		uplit %BLISS32 (PAT_SEMACT_TABLE_ALLOC) (	! 003
!		EXPAND_ARG_LIST(A, %remaining)
!	    ) : vector [%BLISS32 (, PAT_SEMACT_TABLE_ALLOC)];	! 003

! Dummy routine is necessary to force symbols out during compilation.

!	routine pat_semact_table_dummy = begin return 0; end;

!    %;
! Declared terminal reference

macro
    PAT_DECTRMREF (EXT_NAME) =
	%;						! null
!	%name (EXT_NAME) %;

! Undeclared terminal reference

macro
    PAT_UNDTRMREF (EXT_NAME) =
	%;						! null
!	%name (EXT_NAME) %;

! Non-terminal reference

macro
    PAT_NONTRMREF (NAME) =
	%;						! null
!	%name ('NT_', NAME) %;

! Semantics action reference

macro
    PAT_SEMACTREF (NAME) =
	%;						! null
!	%name (NAME) %;

! Reference to an internal name

macro
    PAT_INTRNLREF (NAME) =
	%;						! null
!	%name (NAME) %;
! Define macros for definition of semantics action text table:

%if PATBLSEXT_DEBUGGING
%then			! Only needed for debugging

! If debugging, define PAT$DATA_SEMACT_TEXT_TABLE as a vector of 
! pointers to string descriptors for the
! text of the semantic action symbols.

compiletime
    SEMACT_TOTAL = 0;

macro
    PAT_SEMACT_DEFINITIONS (A) =
	    own
		EXPAND_ARG_LIST(A, %remaining) ;

! Dummy routine is necessary to force symbols out during compilation.

	routine pat_semact_definitions_dummy = begin return 0; end;
    %;

macro
    PAT_SEMACTDEF (NAME, VALUE) =
	%name ('S_', name): $str_descriptor (string = name)
	%assign (SEMACT_TOTAL, value)
    %;

%else			! Not used if not debugging

macro
    PAT_SEMACT_DEFINITIONS (A) =		! null
    %,
    PAT_SEMACTDEF (NAME, VALUE) =		! null
    %;
%fi

 literal
	PAT_DFS = 1,
	PAT_TABLES = 1;

%IF %BLISS (BLISS32) %THEN						! 003
    psect
    plit = PAT$PLIT(
    noshare,
    nopic,
    align (2),
    addressing_mode (long_relative) %quote ,
    read,
    nowrite,
    noexecute,
    concatenate,
    local
    );
%FI									! 003

require 'diuddl';

%if PATBLSEXT_DEBUGGING
%then
%assign (SEMACT_TOTAL, SEMACT_TOTAL + 1)
%fi

undeclare
	PAT_DFS,
	PAT_TABLES,
	%quote pat_semact_definitions,
	%quote pat_semactdef;
%if PATBLSEXT_DEBUGGING %then

own
	null_semact_null: $str_descriptor (string = ' ');

compiletime
	SEMACT_COUNT = 0;

macro
    PAT_SEMACT_DEFINITIONS (A) =
%if PATBLSEXT_DEBUGGING %then
	global								! 003
	    PAT$DATA_SEMACT_TEXT_TABLE :				! 003
		vector [SEMACT_TOTAL]
	    initial (							! 003
		EXPAND_ARG_LIST(A, %remaining) 
	    );			! 003 vector of string descriptor pointers
%fi
    %;

macro
    PAD_SEMACT_TABLE (VALUE) [] = null_semact_null,
	%assign(SEMACT_COUNT, SEMACT_COUNT + 1)
	%if SEMACT_COUNT lss VALUE %then PAD_SEMACT_TABLE(VALUE) %fi
    %;
		
macro
    PAT_SEMACTDEF (NAME, VALUE) =
	%if SEMACT_COUNT lss VALUE %then PAD_SEMACT_TABLE(VALUE) %fi
	%if SEMACT_COUNT neq VALUE %then %error('Charlie blew it') %fi
	%name ('S_', name)
	%assign(SEMACT_COUNT, SEMACT_COUNT + 1)
    %;

%else			! Not used if not debugging

macro
    PAT_SEMACT_DEFINITIONS (A) =		! null
    %,
    PAT_SEMACTDEF (NAME, VALUE) =		! null
    %;

%fi
! Now require PAT_REQUIRE_FILE to actually define the tables.

literal
    PAT_DFS = 1,				! Declare so process definitions
    PAT_TABLES = 1;				! Declare so define parsing tables

require 'diuddl';					! 003 CHANGE HERE!!

undeclare
    PAT_DFS,
    PAT_TABLES;
!global routine PAT$DATA_NEXT_TRANSITION (STATE, ONLY_TERMINALS, REF_LAST_TRANSITION, REF_ACTION_CODE,
!	REF_SYMBOL) : novalue =

!++
!
! FUNCTIONAL DESCRIPTION:
!
!	Determine next parsing transition.
!
! FORMAL PARAMETERS:
!
!	STATE		?
!	ONLY_TERMINALS	?
!	REF_LAST_TRANSITION	?
!	REF_ACTION_CODE		?
!	REF_SYMBOL		?
!
! IMPLICIT INPUTS:
!
!
! IMPLICIT OUTPUTS:
!
!
! ROUTINE VALUE:
!
!	None.
!
! SIDE EFFECTS:
!
!	None.
!
!--

!    begin

!    bind
!	STATE_INDEX = .REF_LAST_TRANSITION,
!	ACTION_CODE = .REF_ACTION_CODE,
!	SYMBOL = .REF_SYMBOL;

!    if .STATE_INDEX eql PAT$DATA_FIND_FIRST_TRANSITION
!	then STATE_INDEX = .STATE
!	else STATE_INDEX = .STATE_INDEX + 1;

!    while TRUE do
!	selectone .PAT$DATA_STATE_SYMBOL_TABLE [.STATE_INDEX] of
!	    set

!	    [PAT_CONT_CODE] : 			! Continue elsewhere in table
!		STATE_INDEX = .PAT$DATA_STATE_ACTION_TABLE [.STATE_INDEX];

!	    [PAT_ELSE_CODE] : 			! No more transitions to try
!		begin
!		ACTION_CODE = .PAT$DATA_STATE_ACTION_TABLE [.STATE_INDEX];
!		SYMBOL = PAT$DATA_NO_MORE_TRANSITIONS;
!		return
!		end;

!	    [PAT$DATA_FIRST_TERM to PAT$DATA_LAST_TERM] : 	! It's a terminal
!		begin
!		SYMBOL = .PAT$DATA_STATE_SYMBOL_TABLE [.STATE_INDEX];
!		return
!		end;

!	    [otherwise] : 			! It's not a terminal
!		if .ONLY_TERMINALS
!		    then STATE_INDEX = .STATE_INDEX + 1
!		    else begin
!			SYMBOL = .PAT$DATA_STATE_SYMBOL_TABLE [.STATE_INDEX];
!			return
!			end;

!	    tes;

!    end;					! Of routine PAT$DATA_NEXT_TRANSITION

end						!End of module

eludom