Google
 

Trailing-Edge - PDP-10 Archives - BB-H138F-BM_1988 - 7-sources/diulrt.bli
There are 4 other files named diulrt.bli in the archive. Click here to see a list.
MODULE DIULRT (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:
!
!	PATLRTUNE.REQ defines the interface between the user of the
!	PAT Parser and the language independent portion of the parser.
!	PATLRTUNE.REQ and PATLRT.BLI are provided with the PAT parser 
!	package and provide an example of a particular implementation of 
!	the interface specification.
!
!	PATLRTUNE.REQ is the specification for local error recovery
!	tuning.  It defines the local error recovery tables and
!	permits some control of the order in which various corrections
!	are attempted.
!
!	Good results can be obtained with no modifications to this 
!	file.
!
! ENVIRONMENT:	VAX/VMS user mode
!
! AUTHOR:  Harvey Alcabes, CREATION DATE:  18-Nov-80
!
! MODIFIED BY:
!
!	Charlie Mitchell, 12-Nov-1981 : VERSION X2-001
! 001 -	Use new PAT/BLISS interface.  Remove from LANGSPEC since
!	changes often aren't needed for particular applications
!	and since this interface is more likely to change in the
!	future than the LANGSPEC interface.
!
! 002 - Remove VMS dependencies.  C. Richardson 29-May-84
!
!  253  Rename file to DIULRT.
!       Gregory A. Scott 1-Jul-86--
!
! INCLUDE FILES:

require 'DIUPATPROLOG';

library 'DIUPATLRTUNE';

library 'DIUPATDATA';

library 'BLI:XPORT';


! TABLE OF CONTENTS OF INTERNAL ROUTINES:

!	NONE


! MACROS:

macro
    SET_TERM (ROW) [TERM] =
	[ROW, TERM] = TRUE %;

macro
    FROM_TO (START, FINISH) [] =
	START
	%if START lss FINISH
	%then
	    , FROM_TO (START + 1, FINISH)
	%fi
    %;


! Weak Recovery Priorities
! These are explained in PATLRTUNE.REQ.

global
    PAT$LR_PRIORITIES_ARE_ADVISORY : initial (TRUE),
    PAT$LR_SUB_PRIORITY		: initial (1),	! Substitutions
    PAT$LR_INSERT_PRIORITY	: initial (2),	! Insertions
    PAT$LR_SCOPE_PRIORITY	: initial (3),	! Scope recovery
    PAT$LR_DELETE_PRIORITY	: initial (4);	! Deletion
!   Tables for local error recovery:


! Identifier Merge Table:

!   This table is used in the language independent portion of the parser.
!   It lists pairs of identifiers which might be entered instead of a reserved
!   word and the terminal symbol number corresponding to that reserved word.
!   The error recovery routines may try to correct an error by merging these
!   tokens.  For example, for Ada the identifiers "GO" and "TO" could be merged
!   into the terminal symbol "GOTO".
!   The contents of this table are **LANGUAGE SPECIFIC**

own
    id_column		: $str_descriptor (string = 'COLUMN'),
    id_complex		: $str_descriptor (string = 'COMPLEX'),
    id_d		: $str_descriptor (string = 'D'),
    id_d_floating	: $str_descriptor (string = 'D_FLOATING'),
    id_default		: $str_descriptor (string = 'DEFAULT'),
    id_edit		: $str_descriptor (string = 'EDIT'),
    id_f		: $str_descriptor (string = 'F'),
    id_f_floating	: $str_descriptor (string = 'F_FLOATING'),
    id_floating		: $str_descriptor (string = 'FLOATING'),
    id_floating_complex	: $str_descriptor (string = 'FLOATING_COMPLEX'),
    id_g		: $str_descriptor (string = 'G'),
    id_g_floating	: $str_descriptor (string = 'G_FLOATING'),
    id_h		: $str_descriptor (string = 'H'),
    id_h_floating	: $str_descriptor (string = 'H_FLOATING'),
    id_header		: $str_descriptor (string = 'HEADER'),
    id_initial		: $str_descriptor (string = 'INITIAL'),
    id_major		: $str_descriptor (string = 'MAJOR'),
    id_missing		: $str_descriptor (string = 'MISSING'),
    id_name		: $str_descriptor (string = 'NAME'),
    id_query		: $str_descriptor (string = 'QUERY'),
    id_row		: $str_descriptor (string = 'ROW'),
    id_string		: $str_descriptor (string = 'STRING'),
    id_value		: $str_descriptor (string = 'VALUE');

global
    PAT$LR_IDENTIFIER_MERGE_TABLE : blockvector [LR_NUM_IM, LR_IM_SIZE]
	field (LR_IM_FIRST_ID, LR_IM_SECOND_ID, LR_IM_MERGED_TERM) 

preset (
	[0, LR_IM_FIRST_ID]	= id_column,
	[0, LR_IM_SECOND_ID]	= id_major,
	[0, LR_IM_MERGED_TERM]	= T_COLUMN_MAJOR,

	[1, LR_IM_FIRST_ID]	= id_default,
	[1, LR_IM_SECOND_ID]	= id_value,
	[1, LR_IM_MERGED_TERM]	= T_DEFAULT_VALUE,

	[2, LR_IM_FIRST_ID]	= id_d,
	[2, LR_IM_SECOND_ID]	= id_floating,
	[2, LR_IM_MERGED_TERM]	= T_D_FLOATING,

	[3, LR_IM_FIRST_ID]	= id_d,
	[3, LR_IM_SECOND_ID]	= id_floating_complex,
	[3, LR_IM_MERGED_TERM]	= T_D_FLOATING_COMPLEX,

	[4, LR_IM_FIRST_ID]	= id_d_floating,
	[4, LR_IM_SECOND_ID]	= id_complex,
	[4, LR_IM_MERGED_TERM]	= T_D_FLOATING_COMPLEX,

	[5, LR_IM_FIRST_ID]	= id_edit,
	[5, LR_IM_SECOND_ID]	= id_string,
	[5, LR_IM_MERGED_TERM]	= T_EDIT_STRING,

	[6, LR_IM_FIRST_ID]	= id_floating,
	[6, LR_IM_SECOND_ID]	= id_complex,
	[6, LR_IM_MERGED_TERM]	= T_FLOATING_COMPLEX,

	[7, LR_IM_FIRST_ID]	= id_f,
	[7, LR_IM_SECOND_ID]	= id_floating,
	[7, LR_IM_MERGED_TERM]	= T_F_FLOATING,

	[8, LR_IM_FIRST_ID]	= id_f,
	[8, LR_IM_SECOND_ID]	= id_floating_complex,
	[8, LR_IM_MERGED_TERM]	= T_F_FLOATING_COMPLEX,

	[9, LR_IM_FIRST_ID]	= id_f_floating,
	[9, LR_IM_SECOND_ID]	= id_complex,
	[9, LR_IM_MERGED_TERM]	= T_F_FLOATING_COMPLEX,

	[10, LR_IM_FIRST_ID]	= id_g,
	[10, LR_IM_SECOND_ID]	= id_floating,
	[10, LR_IM_MERGED_TERM]	= T_G_FLOATING,

	[11, LR_IM_FIRST_ID]	= id_g,
	[11, LR_IM_SECOND_ID]	= id_floating_complex,
	[11, LR_IM_MERGED_TERM]	= T_G_FLOATING_COMPLEX,

	[12, LR_IM_FIRST_ID]	= id_g_floating,
	[12, LR_IM_SECOND_ID]	= id_complex,
	[12, LR_IM_MERGED_TERM]	= T_G_FLOATING_COMPLEX,

	[13, LR_IM_FIRST_ID]	= id_h,
	[13, LR_IM_SECOND_ID]	= id_floating,
	[13, LR_IM_MERGED_TERM]	= T_H_FLOATING,

	[14, LR_IM_FIRST_ID]	= id_h,
	[14, LR_IM_SECOND_ID]	= id_floating_complex,
	[14, LR_IM_MERGED_TERM]	= T_H_FLOATING_COMPLEX,

	[15, LR_IM_FIRST_ID]	= id_h_floating,
	[15, LR_IM_SECOND_ID]	= id_complex,
	[15, LR_IM_MERGED_TERM]	= T_H_FLOATING_COMPLEX,

	[16, LR_IM_FIRST_ID]	= id_initial,
	[16, LR_IM_SECOND_ID]	= id_value,
	[16, LR_IM_MERGED_TERM]	= T_INITIAL_VALUE,

	[17, LR_IM_FIRST_ID]	= id_missing,
	[17, LR_IM_SECOND_ID]	= id_value,
	[17, LR_IM_MERGED_TERM]	= T_MISSING_VALUE,

	[18, LR_IM_FIRST_ID]	= id_query,
	[18, LR_IM_SECOND_ID]	= id_header,
	[18, LR_IM_MERGED_TERM]	= T_QUERY_HEADER,

	[19, LR_IM_FIRST_ID]	= id_query,
	[19, LR_IM_SECOND_ID]	= id_name,
	[19, LR_IM_MERGED_TERM]	= T_QUERY_NAME,

	[20, LR_IM_FIRST_ID]	= id_row,
	[20, LR_IM_SECOND_ID]	= id_major,
	[20, LR_IM_MERGED_TERM]	= T_ROW_MAJOR);
! Symbol Merge Table:

!   This table is used in the language independent portion of the parser.
!   It lists pairs of terminals whose symbols might be entered instead of a
!   multi-symbol terminal and the number of the corresponding terminal.
!   The error recovery routines may try to correct an error by merging these
!   tokens.  For example, for Ada the terminals ":" and "=" could be merged
!   into ":=".
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_SYMBOL_MERGE_TABLE : blockvector [LR_NUM_SM, LR_SM_SIZE]
	field (LR_SM_FIRST_TERM, LR_SM_SECOND_TERM, LR_SM_MERGED_TERM, LR_SM_UNUSED) 
;

! This table has no entries for this particular grammar.

!preset (

!	[0, LR_SM_FIRST_TERM]	= T_COLON,
!	[0, LR_SM_SECOND_TERM]	= T_EQUAL,
!	[0, LR_SM_MERGED_TERM]	= T_COLON_EQUAL,

!	[1, LR_SM_FIRST_TERM]	= T_LESS,
!	[1, LR_SM_SECOND_TERM]	= T_EQUAL,
!	[1, LR_SM_MERGED_TERM]	= T_LESS_EQUAL,

!	[2, LR_SM_FIRST_TERM]	= T_GREATER,
!	[2, LR_SM_SECOND_TERM]	= T_EQUAL,
!	[2, LR_SM_MERGED_TERM]	= T_GREATER_EQUAL,

!	[3, LR_SM_FIRST_TERM]	= T_EQUAL,
!	[3, LR_SM_SECOND_TERM]	= T_LESS,
!	[3, LR_SM_MERGED_TERM]	= T_LESS_EQUAL,

!	[4, LR_SM_FIRST_TERM]	= T_EQUAL,
!	[4, LR_SM_SECOND_TERM]	= T_GREATER,
!	[4, LR_SM_MERGED_TERM]	= T_EQUAL_GREATER,

!	[5, LR_SM_FIRST_TERM]	= T_LESS,
!	[5, LR_SM_SECOND_TERM]	= T_GREATER,
!	[5, LR_SM_MERGED_TERM]	= T_LESS_GREATER,

!	[6, LR_SM_FIRST_TERM]	= T_GREATER,
!	[6, LR_SM_SECOND_TERM]	= T_GREATER,
!	[6, LR_SM_MERGED_TERM]	= T_GREATER_GREAT,

!	[7, LR_SM_FIRST_TERM]	= T_LESS,
!	[7, LR_SM_SECOND_TERM]	= T_LESS,
!	[7, LR_SM_MERGED_TERM]	= T_LESS_LESS,

!	[8, LR_SM_FIRST_TERM]	= T_SLASH,
!	[8, LR_SM_SECOND_TERM]	= T_EQUAL,
!	[8, LR_SM_MERGED_TERM]	= T_SLASH_EQUAL,

!	[9, LR_SM_FIRST_TERM]	= T_STAR,
!	[9, LR_SM_SECOND_TERM]	= T_STAR,
!	[9, LR_SM_MERGED_TERM]	= T_STAR_STAR,

!	[10, LR_SM_FIRST_TERM]	= T_DOT,
!	[10, LR_SM_SECOND_TERM]	= T_DOT,
!	[10, LR_SM_MERGED_TERM]	= T_DOT_DOT);
! Never-Substitute-For Table:

!   This table is used in the language independent portion of the parser.
!   It contains a bit which is set for each terminal that should not
!   be substituted for during local error recovery.
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_NEVER_SUBSTITUTE_FOR : bitvector [PAT$DATA_NUM_TERM] 
preset (

	[T_DOT]			= TRUE,
	[T_END]			= TRUE,
	[T_PATH_NAME]		= TRUE,
	[T_CDD_NAME]		= TRUE,
	[T_DESCR_TEXT]		= TRUE,
	[T_UNSIGNED_INTEGER]	= TRUE,
	[T_SIGNED_INTEGER]	= TRUE,
	[T_FIXED_POINT]		= TRUE,
	[T_FLOATING_POINT]	= TRUE,
	[T_QUOTED_STRING]	= TRUE,
	[T_HEX_NUMBER]		= TRUE,
	[T_OCTAL_NUMBER]	= TRUE,
	[T_EOF]			= TRUE);
! Preferred-Insertions Table:

!   This table is used in the language independent portion of the parser.
!   It contains a bit which is set for each terminal that the
!   local error recovery routines should preference when there
!   exist more than one possible insertion or replacement.
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_PREFERRED_INSERTIONS : bitvector [PAT$DATA_NUM_TERM] 
preset (

	[T_DOT]			= TRUE,
	[T_END]			= TRUE);
! Never-Insert-Before Table:

!   This table is used in the language independent portion
!   of the parser for local error recovery.
!   It indicates the terminal numbers of tokens which should not be inserted
!   immediately prior to a specific pair of tokens.  This can be used to
!   prevent corrections which may parse but are generally not the desired
!   correction.  For example, for Ada DECLARE should not be inserted
!   immediately prior to PRAGMA IDENTIFIER.
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_NEVER_INSERT_BEFORE : blockvector [LR_NUM_NIB, LR_NIB_SIZE]
	field (LR_NIB_INSERTION, LR_NIB_CURTOK, LR_NIB_NEXTTOK, LR_NIB_UNUSED) 
preset (

	[0, LR_NIB_INSERTION]	= T_END,
	[0, LR_NIB_CURTOK]	= T_DEFINE,
	[0, LR_NIB_NEXTTOK]	= T_RECORD);
!   Tables for scope recovery:


! Closer-Tokens Table:

!   This table is used in the language independent portion of the parser
!   for scope recovery.
!
!   It indicates contents of each scope closer by listing the
!   number of tokens in the closer and the actual tokens.
!   For example, for Ada the closer "END;" has 2 for the number of tokens
!   and END and SEMICOLON for the tokens.
!
!   If one closer fully contains another and they both have the same
!   beginning (e.g. "end if" and "end if;") then the LONGER closer
!   must appear in the table FIRST or the scope recovery routine  may
!   incorrectly insert the shorter one in its place.
!
!   Table indices are literals declared in the enumeration LR_CLOSER
!   in PATLRTUNE.REQ.
!
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_CLOSER_TOKENS : LR_MATRIX [LR_NUM_CLOSERS, (LR_MAX_TOKENS_IN_CLOSER + 1)]
	preset (

	[LR_ERD, LR_NUM_TOKS_INDEX]	= 3,	! "END RECORD."
	[LR_ERD, 1]	= T_END,
	[LR_ERD, 2]	= T_RECORD,
	[LR_ERD, 3]	= T_DOT,

	[LR_ESD, LR_NUM_TOKS_INDEX]	= 3,	! "END STRUCTURE."
	[LR_ESD, 1]	= T_END,
	[LR_ESD, 2]	= T_STRUCTURE,
	[LR_ESD, 3]	= T_DOT,

	[LR_ETD, LR_NUM_TOKS_INDEX]	= 3,	! "END TRANSFORM."
	[LR_ETD, 1]	= T_END,
	[LR_ETD, 2]	= T_TRANSFORM,
	[LR_ETD, 3]	= T_DOT,

	[LR_EVSD, LR_NUM_TOKS_INDEX]	= 3,	! "END VARIANTS."
	[LR_EVSD, 1]	= T_END,
	[LR_EVSD, 2]	= T_VARIANTS,
	[LR_EVSD, 3]	= T_DOT,

	[LR_EVD, LR_NUM_TOKS_INDEX]	= 3,	! "END VARIANT."
	[LR_EVD, 1]	= T_END,
	[LR_EVD, 2]	= T_VARIANT,
	[LR_EVD, 3]	= T_DOT);
! Only-Close-Before Table:

!   This table is used in the language independent portion of the parser
!   for scope recovery.
!   Its rows correspond to literals declared in the enumeration LR_CLOSER
!   in PATLRTUNE.REQ.
!   It indicates where each scope closer may be inserted with a bit
!   set corresponding to the terminals that it may be inserted before.
!   This is necessary because insertions performed by scope recovery are
!   not checked with a parse beyond the inserted closers, allowing for
!   several scopes to be closed.  The table is derived from the grammar
!   by listing the terminals which are in the "follow set" of the closer
!   to be inserted or of closers in that set.
!   All such terminals may be listed, but care should be taken when including
!   those that are likely to occur within the scope being closed.
!   The first terminal in the token itself need not be listed because
!   if it was in the input an error would not have occurred.
!
!   For example, for Ada the closer "END;" can be followed by the terminals
!   FUNCTION, GENERIC, PACKAGE,	PROCEDURE, SEPARATE, TASK, WITH or the
!   end of file token.
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_ONLY_CLOSE_BEFORE : LR_BITMATRIX [LR_NUM_CLOSERS, PAT$DATA_NUM_TERM] 
preset (

	SET_TERM (LR_ERD, T_DEFINE, T_EOF),		! "END RECORD."
	SET_TERM (LR_ESD, T_DEFINE, T_EOF),		! "END STRUCTURE."
	SET_TERM (LR_ETD, T_DEFINE, T_EOF),		! "END TRANSFORM."
	SET_TERM (LR_EVSD, T_DEFINE, T_EOF),		! "END VARIANTS."
	SET_TERM (LR_EVD, T_DEFINE, T_EOF));		! "END VARIANT."
! Closer-Match Table:

!   This table is used in the language independent portion of the parser
!   for scope recovery.
!   Its indices are literals declared in the enumeration LR_CLOSER
!   in PATLRTUNE.REQ.
!   For each closer it contains either the terminal or nonterminal symbol
!   on the stack which opens the corresponding scope or the literal
!   LR_NOT_MATCHED if the error message will not indicate the matching
!   scope opener.
!   For example, for Ada the closer "END;" closes a scope opened by the
!   terminal BEGIN (which appears on the stack until the scope is closed).
!   The contents of this table are **LANGUAGE SPECIFIC**

global
    PAT$LR_CLOSER_MATCH : blockvector [LR_NUM_CLOSERS, LR_CLOSERS_SIZE] 
	field (LR_CLOSERS_STACK, LR_CLOSERS_TERMINAL)

preset (

! "End record.":

	[LR_ERD, LR_CLOSERS_STACK]	= NT_DEFINE_STATEMENT,
	[LR_ERD, LR_CLOSERS_TERMINAL]	= T_DEFINE,

! "End structure.":

	[LR_ESD, LR_CLOSERS_STACK]	= NT_STRUCTURE_BEGIN,
	[LR_ESD, LR_CLOSERS_TERMINAL]	= T_STRUCTURE,

! "End transform.":

	[LR_ETD, LR_CLOSERS_STACK]	= T_DEFINE,
	[LR_ETD, LR_CLOSERS_TERMINAL]	= T_DEFINE,

! "End variants.":

	[LR_EVSD, LR_CLOSERS_STACK]	= NT_VARIANTS_HEAD,
	[LR_EVSD, LR_CLOSERS_TERMINAL]	= T_VARIANTS,

! "End variant.":

	[LR_EVD, LR_CLOSERS_STACK]	= NT_VARIANT_HEAD,
	[LR_EVD, LR_CLOSERS_TERMINAL]	= T_VARIANT);
! Closer-Message Table:

!   This table is used in the language independent portion of the parser
!   for scope recovery.
!   Its indices are literals declared in the enumeration LR_CLOSER
!   in PATLRTUNE.REQ.
!   For each closer it contains a pointer to a string descriptor
!   which contains text for the closer.
!   For example, for Ada there is the text "end;" for the closer "END;".
!   The contents of this table are **LANGUAGE SPECIFIC**

own
    msg_end_dot		: $str_descriptor (string = '"END."');

global
    PAT$LR_CLOSER_MESSAGE : vector [LR_NUM_CLOSERS]
	preset (

	[LR_ERD]	= msg_end_dot,			! "END RECORD."
	[LR_ESD]	= msg_end_dot,			! "END STRUCTURE."
	[LR_ETD]	= msg_end_dot,			! "END TRANSFORM."
	[LR_EVSD]	= msg_end_dot,			! "END VARIANTS."
	[LR_EVD]	= msg_end_dot );		! "END VARIANT."
! Point-at-Previous-Token Table:

!   This table is used in the language independent portion of the parser
!   for scope recovery.
!   Its indices are literals declared in the enumeration LR_CLOSER
!   in PATLRTUNE.REQ.
!   Each entry is TRUE iff the error message should indicate the
!   token before the one where the error was encountered.
!   For example, for Ada when "if; end;" is inserted after "end" the
!   error message should indicate that "end if;" appeared before the "end".
!   The contents of this table are **LANGUAGE SPECIFIC**

global
!!    PAT$LR_POINT_AT_PREV_TOKEN : bitvector [LR_NUM_CLOSERS] preset (	! SHOULD BE THIS 
!!		MOD DUE TO BLISS BUG
    PAT$LR_POINT_AT_PREV_TOKEN : bitvector [32] 
;
!preset (

!	[LR_SE]		= TRUE,				! "; END"
!	[LR_CSE]	= TRUE,				! "CASE; END"
!	[LR_ISE]	= TRUE,				! "IF; END"
!	[LR_LSE]	= TRUE,				! "LOOP END"
!	[LR_RSE]	= TRUE,				! "RECORD; END"
!	[LR_SSE]	= TRUE);			! "SELECT; END"

end						! End of module

eludom