! PATLRTUNE.REQ ! ! ! ! COPYRIGHT (c) 1982 BY ! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. ! ! 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 WHICH IS NOT SUPPLIED BY DIGITAL. ! !++ ! FACILITY: VAX-11 Ada ! ! 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. ! ! Logical name PAT_LANGSP_LIBRARY should be defined as the ! library file produced by ! ! BLISS/LIB PATLANGSP.REQ ! ! 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 VAX-11 Ada compiler. ! ! 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. !-- ! ! INCLUDE FILES: ! require 'PATREQPRO_REQ'; library 'XPORT_LIB'; library 'PATDATA_LIB'; ! !+ ! 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 advantageous to implement these macros to access an own ! location initially so that these values can be modified via ! the debugger. ! ! 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. !- macro LR_PRIORITIES_ARE_ADVISORY = begin external PAT$LR_PRIORITIES_ARE_ADVISORY; .PAT$LR_PRIORITIES_ARE_ADVISORY end %; macro LR_SUB_PRIORITY = begin ! Substitution external PAT$LR_SUB_PRIORITY; .PAT$LR_SUB_PRIORITY end %; macro LR_INSERT_PRIORITY = begin ! Insertion external PAT$LR_INSERT_PRIORITY; .PAT$LR_INSERT_PRIORITY end %; macro LR_SCOPE_PRIORITY = begin ! Scope Recovery external PAT$LR_SCOPE_PRIORITY; .PAT$LR_SCOPE_PRIORITY end %; macro LR_DELETE_PRIORITY = begin ! Deletion external PAT$LR_DELETE_PRIORITY; .PAT$LR_DELETE_PRIORITY end %; ! !++ ! ! Literals, structures, external declarations for building local ! error recovery tables. The tables are described in ! !-- ! ! Declarations for PAR$LR_NEVER_INSERT_BEFORE table (declared in PATLRTUNE.BLI) $FIELD LR_NIB_INSERTION = [$BYTE], LR_NIB_CURTOK = [$BYTE], LR_NIB_NEXTTOK = [$BYTE], LR_NIB_UNUSED = [$BYTE]; literal LR_NIB_SIZE = $FIELD_SET_SIZE*%upval, ! Size of each table entry !! LR_NUM_NIB = 23; ! Number of elements in table--**LANGUAGE SPECIFIC** LR_NUM_NIB = 0; ! Number of elements in table--**LANGUAGE SPECIFIC** external 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); ! ! Declarations for PAR$LR_SYMBOL_MERGE_TABLE (declared in PATLRTUNE.BLI) $FIELD LR_SM_FIRST_TERM = [$BYTE], LR_SM_SECOND_TERM = [$BYTE], LR_SM_MERGED_TERM = [$BYTE], LR_SM_UNUSED = [$BYTE]; literal LR_SM_SIZE = $FIELD_SET_SIZE*%upval, ! Size of each table entry !! LR_NUM_SM = 11; ! Number of elements in table--**LANGUAGE SPECIFIC** LR_NUM_SM = 0; ! Number of elements in table--**LANGUAGE SPECIFIC** external 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); ! ! Declarations for PAR$LR_IDENTIFIER_MERGE_TABLE (declared in PATLRTUNE.BLI) $FIELD LR_IM_FIRST_ID = [$ADDRESS], LR_IM_SECOND_ID = [$ADDRESS], LR_IM_MERGED_TERM = [$LONG_INTEGER]; literal LR_IM_SIZE = $FIELD_SET_SIZE*%upval, ! Size of each table entry !! LR_NUM_IM = 1; ! Number of elements in table--**LANGUAGE SPECIFIC** LR_NUM_IM = 0; ! Number of elements in table--**LANGUAGE SPECIFIC** external 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); !+ ! Misc. tables !- external PAT$LR_NEVER_SUBSTITUTE_FOR : bitvector [PAT$DATA_NUM_TERM], PAT$LR_PREFERRED_INSERTIONS : bitvector [PAT$DATA_NUM_TERM]; !+ ! Declarations for Scope Recovery !- ! ! List of literals representing possible scope closers--**LANGUAGE SPECIFIC** ENUMERATION ('LR_CLOSER', 0 ); !!, ! !! LR_RP, ! ")" !! LR_ES, ! "END;" !! LR_ECS, ! "END CASE;" !! LR_EIS, ! "END IF;" !! LR_ELS, ! "END LOOP;" !! LR_ERS, ! "END RECORD;" !! LR_ESS, ! "END SELECT;" !! LR_SE, ! "; END" !! LR_CSE, ! "CASE; END" !! LR_ISE, ! "IF; END" !! LR_LSE, ! "LOOP; END" !! LR_RSE, ! "RECORD; END" !! LR_SSE, ! "SELECT; END" !! LR_BNSES); ! "BEGIN NULL; END;" 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_MAX_TOKENS_IN_CLOSER = 0, ! Size of largest scope closer--**LANGUAGE SPECIFIC** LR_NUM_TOKS_INDEX = 0; structure LR_BITMATRIX [ROWNUM, BITNUM; ROWS, BITS] = [((ROWS*BITS) + (%bpunit - 1))/%bpunit] LR_BITMATRIX<((BITNUM*ROWS) + ROWNUM), 1>; structure LR_MATRIX [ROWNUM, COLNUM; ROWS, COLS] = [(ROWS*COLS)*%upval] (LR_MATRIX + ((ROWNUM*COLS) + COLNUM)*%upval); 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]; !