Google
 

Trailing-Edge - PDP-10 Archives - BB-JF18A-BM - sources/diu/diupatlrtune.req
There are 4 other files named diupatlrtune.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.
!
! PATLRTUNE.REQ
!++
! FACILITY:	Data Interchange Utility
!
! ABSTRACT:
!
!	PATLRTUNE.REQ defines the interface between the user of the
!	PAT Parser and the language independent portion of the parser
!	that permits local error recovery to be tuned to a particular
!	use.  This file is provided with the PAT parser package and provides
!	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.
!
!	PATLRTUNE.REQ can be used without modification with good results.  
!	However, better error recovery results can be obtained by 
!	tuning the tables for a particular language.  This module
!	tunes local recovery for the Data Interchange Utiltiy.
!
!	For example, a symbol-merge-table can be used to indicate
!	that the lexical tokens "<" and "=" can be merged to form
!	the token "<=".
!
! 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 25-May-84
!
!  253  Rename file to DIUPATLRTUNE.
!       Gregory A. Scott 1-Jul-86
!
!--
!
! INCLUDE FILES:
!

require 'DIUPATREQPRO';

library 'BLI:XPORT';					! 002

library 'DIUPATDATA';
! General tuning (not specific to particular lexical tokens and
! terminal symbols

! The LR_*_PRIORITY macros and the LR_PRIORITIES_ARE_ADVISORY
! macro define the order in which weak local error recoveries
! should be made.
!
! The LR_*_PRIORITY macros should each return a different number between
! 1 and 4 indicating the order in which they should be attempted
! (lower numbers before higher) or 0 for any that should not
! be attempted.
!
! It is advantagous to implement these macros to access an own
! location initially so that these values can be modified via
! the debugger.
!
! The values are defined in PATLRT.BLI.
! Macro LR_PRIORITIES_ARE_ADVISORY indicates if the priorities
! are absolute or advisory.
!
!	A priority of 0 is absolute.  The correction will never
!	be attempted regardless of the value of
!	LR_PRIORITIES_ARE_ADVISORY.  Otherwise the following applies:
!
!	If this macro has value TRUE, the algorithm may or may
!	not use the priority information.  The algorithm will
!	pick the order in which local recoveries are attempted
!	and the order chosen may vary from version to version.
!	(It is antipated that a future version may chose the
!	"best" weak local recovery by means of a contest -- which
!	parses ahead the furthest -- rather than the first successful
!	recovery.  Priorities may then be used to resolve ties.)
!
!	If this macro has value FALSE, the algorithm will attempt
!	corrections in the order specified and will chose the
!	the first which satisfies the criteria.

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_PRIORITIES_ARE_ADVISORY	=	PRIAAD %;		! 002
%FI								! 002

macro
    LR_PRIORITIES_ARE_ADVISORY =
	begin

	external
	    PAT$LR_PRIORITIES_ARE_ADVISORY;

	.PAT$LR_PRIORITIES_ARE_ADVISORY
	end
    %;
! Substitutions:

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_SUB_PRIORITY		=	SUBPRI %;		! 002
%FI								! 002

macro
    LR_SUB_PRIORITY =
	begin
	external
	    PAT$LR_SUB_PRIORITY;

	.PAT$LR_SUB_PRIORITY
	end
    %;
! Insertions:

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_INSERT_PRIORITY			=	INSPRI %;	! 002
%FI								! 002

macro
    LR_INSERT_PRIORITY =
	begin
	external
	    PAT$LR_INSERT_PRIORITY;

	.PAT$LR_INSERT_PRIORITY
	end
    %;
! Scope recovery:

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_SCOPE_PRIORITY			=	SCOPRI %;	! 002
%FI								! 002

macro
    LR_SCOPE_PRIORITY =
	begin
	external
	    PAT$LR_SCOPE_PRIORITY;

	.PAT$LR_SCOPE_PRIORITY
	end
    %;
! Deletion:

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_DELETE_PRIORITY		=	DELPRI %;		! 002
%FI								! 002

macro
    LR_DELETE_PRIORITY =
	begin
	external
	    PAT$LR_DELETE_PRIORITY;

	.PAT$LR_DELETE_PRIORITY
	end
    %;
! Numbers of tokens to parse ahead during local error recovery in PATPAR.BLI:

literal
    PARSE_AHEAD_EOL		= 3, ! EOL corrections
    PARSE_AHEAD_MERGE		= 2, ! Token merging
    PARSE_AHEAD_SPELLING	= 3, ! Spelling correction
    PARSE_AHEAD_SUBSTITUTION	= 3, ! Token substitution
    PARSE_AHEAD_INSERTION	= 3, ! Token insertion
    PARSE_AHEAD_DELETION	= 3; ! Token deletion

! NOTE: For scope recovery, parse ahead is done for the number of tokens in the
! scope closer (.PAT$LR_CLOSER_TOKENS [..., LR_NUM_TOKS_INDEX]).
!   Literals, structures, external declarations for building local
!   error recovery tables.  The tables are described in PATLRT.BLI.


! Never-Insert-Before Table:

!   Declarations for PAR$LR_NEVER_INSERT_BEFORE table (declared in PATLRT.BLI)

    $FIELD LR_NIB_FIELDS =
    set
    LR_NIB_INSERTION = [$BYTE],
    LR_NIB_CURTOK = [$BYTE],
    LR_NIB_NEXTTOK = [$BYTE],
    LR_NIB_UNUSED = [$BYTE]
    tes;

literal
    LR_NIB_SIZE = $FIELD_SET_SIZE*%upval,	! Size of each table entry
    LR_NUM_NIB = 1;				! Number of elements in table--**LANGUAGE SPECIFIC**

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_NEVER_INSERT_BEFORE		=	NEVIBF %;	! 002
%FI								! 002

external
    PAT$LR_NEVER_INSERT_BEFORE : blockvector [LR_NUM_NIB, LR_NIB_SIZE]
	field (LR_NIB_FIELDS);
! Symbol Merge Table:

!   Declarations for PAR$LR_SYMBOL_MERGE_TABLE (declared in PATLRTUNE.BLI)

    $FIELD LR_SM_FIELDS =
    set
    LR_SM_FIRST_TERM = [$BYTE],
    LR_SM_SECOND_TERM = [$BYTE],
    LR_SM_MERGED_TERM = [$BYTE],
    LR_SM_UNUSED = [$BYTE]
    tes;

literal
    LR_SM_SIZE = $FIELD_SET_SIZE*%upval,	! Size of each table entry
    LR_NUM_SM = 0;				! Number of elements in table--**LANGUAGE SPECIFIC**

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_SYMBOL_MERGE_TABLE		=	SYMTAB %;	! 002
%FI								! 002

external
    PAT$LR_SYMBOL_MERGE_TABLE : blockvector [LR_NUM_SM, LR_SM_SIZE]
	field (LR_SM_FIELDS);
! Identifier Merge Table:

!   Declarations for PAR$LR_IDENTIFIER_MERGE_TABLE (declared in PATLRTUNE.BLI)

    $FIELD LR_IM_FIELDS =
    set
    LR_IM_FIRST_ID = [$ADDRESS],
    LR_IM_SECOND_ID = [$ADDRESS],
    LR_IM_MERGED_TERM = [$LONG_INTEGER]
    tes;

literal
    LR_IM_SIZE = $FIELD_SET_SIZE*%upval,	! Size of each table entry
    LR_NUM_IM = 21;				! Number of elements in table--**LANGUAGE SPECIFIC**

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_IDENTIFIER_MERGE_TABLE		=	IDMTAB %;	! 002
%FI								! 002

external
    PAT$LR_IDENTIFIER_MERGE_TABLE : blockvector [LR_NUM_IM, LR_IM_SIZE]
	field (LR_IM_FIELDS);
! Misc. tables: see PATLRT.BLI for more information:

! Never-Substitute-For Table
! Preferred-Insertions Table

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_NEVER_SUBSTITUTE_FOR		=	NEVSUB %,	! 002
PAT$LR_PREFERRED_INSERTIONS		=	PRFINS %;	! 002
%FI								! 002

external
    PAT$LR_NEVER_SUBSTITUTE_FOR : bitvector [PAT$DATA_NUM_TERM],
    PAT$LR_PREFERRED_INSERTIONS : bitvector [PAT$DATA_NUM_TERM];
! Declarations for Scope Recovery


! Closer-Tokens Table:

!   List of literals representing possible scope closers--**LANGUAGE SPECIFIC**

ENUMERATION ('LR_CLOSER', 0,
	LR_ERD,					! "END RECORD."
	LR_ESD,					! "END STRUCTURE."
	LR_ETD,					! "END TRANSFORM."
	LR_EVSD,				! "END VARIANTS."
	LR_EVD);				! "END VARIANT."

! Declarations for PAT$LR_CLOSER_MATCH table (declared in PATLRT.BLI):

$FIELD LR_CLOSERS_FIELDS =
set
LR_CLOSERS_STACK	= [$LONG_INTEGER],	! terminal/nonterminal on stack
LR_CLOSERS_TERMINAL	= [$LONG_INTEGER]	! terminal that began it
tes;

literal
    LR_CLOSERS_SIZE = $field_set_size * %upval;

literal
    LR_NUM_CLOSERS = LAST_LR_CLOSER - FIRST_LR_CLOSER + 1,
    LR_MAX_TOKENS_IN_CLOSER = 5,		! Size of largest scope closer--**LANGUAGE SPECIFIC**
    LR_NUM_TOKS_INDEX = 0;

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_CLOSER_MATCH			=	CLMTCH %;	! 002
%FI								! 002

external
    PAT$LR_CLOSER_MATCH: blockvector [LR_NUM_CLOSERS, LR_CLOSERS_SIZE]
	field (LR_CLOSERS_FIELDS);
! Data structures used in scope recovery tables:

! A vector of bit strings, each starting on a Bliss unit boundary,
! and addressable bit-by-bit:

structure
    LR_BITMATRIX [ROWNUM, BITNUM; ROWS, BITS] =
	[rows * ((bits + (%bpunit - 1))/ %bpunit)]
! Address of a bit: starting unit position of a row of the structure
! + integral units in the row (zero-relative)
! <offset within that unit, 1 bit>
	( LR_BITMATRIX + (rownum * ((bits + (%bpunit - 1)) / %bpunit))
	    + ((bitnum + %bpunit)/ %bpunit) - 1 )
	    <((bitnum + %bpunit) mod %bpunit), 1>;

! A matrix of Bliss units:

structure
    LR_MATRIX [ROWNUM, COLNUM; ROWS, COLS] =
	[(ROWS*COLS)*%upval]
	(LR_MATRIX + ((ROWNUM*COLS) + COLNUM)*%upval);
! More scope recovery tables (see PATLRT.BLI):

! Closer-Tokens Table
! Only-Close-Before Table
! Closer-Match Table
! Closer-Message Table
! Point-at-Previous-Token Table

%IF %BLISS (BLISS36)						! 002
%THEN								! 002
macro								! 002
PAT$LR_CLOSER_TOKENS			=	CLSTOK %,	! 002
PAT$LR_ONLY_CLOSE_BEFORE		=	ONCLBF %,	! 002
PAT$LR_CLOSER_MESSAGE			=	CLOMSG %,	! 002
PAT$LR_POINT_AT_PREV_TOKEN		=	PTPRTK %;	! 002
%FI								! 002

external
    PAT$LR_CLOSER_TOKENS : LR_MATRIX [LR_NUM_CLOSERS, (LR_MAX_TOKENS_IN_CLOSER + 1)],
    PAT$LR_ONLY_CLOSE_BEFORE : LR_BITMATRIX [LR_NUM_CLOSERS, PAT$DATA_NUM_TERM],
!    PAT$LR_CLOSER_MATCH : vector [LR_NUM_CLOSERS],
    PAT$LR_CLOSER_MESSAGE : vector [LR_NUM_CLOSERS],
!!    PAT$LR_POINT_AT_PREV_TOKEN : bitvector [LR_NUM_CLOSERS];  ! SHOULD BE THIS
    PAT$LR_POINT_AT_PREV_TOKEN : bitvector [32];  
! Other definitions (language independent)

literal
    LR_NOT_MATCHED = 999;

! End of PATLRTUNE.REQ