! LSE$GRAMMAR_TOKEN.TPU ! !************************************************************************* ! * ! © Copyright 2005 Hewlett-Packard Development Company, L.P. * ! * ! Confidential computer software. Valid license from HP required for * ! possession, use or copying. Consistent with FAR 12.211 and 12.212, * ! Commercial Computer Software, Computer Software Documentation, and * ! Technical Data for Commercial Items are licensed to the U.S. * ! Government under vendor's standard commercial license. * ! * !************************************************************************* ! !++ ! FACILITY: ! VAX Language-Sensitive Editor ! ! ABSTRACT: ! This file contains the Portable/LSE token-related grammar syntax. ! ! ENVIRONMENT: ! Portable/LSE ! ! Author: Diana E. Carroll ! ! CREATION DATE: 11-June-1991 ! ! MODIFIED BY: ! ! X4.0 DEC 11-Jun-91 New module ! X4.0-1 DAS 25-Jun-91 StreamLf this file ! X4.0-2 DEC 08-Aug-91 Implement token get_info and set extensions ! X4.0-3 DAS 09-Aug-91 Missing declarations of TOKEN ! X4.0-4 DEC 15-Aug-91 Implement show_token and extract_new_token ! X4.0-5 NMC 26-Aug-91 Removed some debugging messages in lse_delete_token ! X4.0-6 ch 7-Sep-91 Added missing local decl for LANG. ! X4.0-7 DEC 09-Sep-91 Fix bug in lse_new_token ! X4.0-8 NMC 9-Sep-91 Use lse$add in add_remove builtins. ! X4.0-9 NMC 30-Sep-91 Add error trap to lse_new_token for redefined token. ! Ensure no update of current token if add ! operation fails in lse_new_token. ! Add lse$compare_lang_pack_elem call to check for ! possible current token being deleted. ! X4.0-10 DEC 09-Oct-91 Standardize parameter names ! X4.0-11 NMC 10-Oct-91 Modified lse$prompt_lang_elem_param to ! lse$prompt_lang_pack_elem_param ! Modified lse$get_valid_lang_elem to ! lse$get_valid_lang_pack_elem ! X4.0-12 NMC 21-Oct-91 Modified lse_delete_token to take wildcard name ! Fix bug in lse_show_token to make sure we have a ! valid language before the show operation. ! X4.0-13 NMC 31-Dec-91 Modified lse_show_token to set the current language. ! X4.0-14 DEC 08-Jan-92 ! X4.0-15 DEC 22-Jan-92 Fixed documention ! X4.0-16 WC3 13-Apr-92 Make NEW silently re-initialize instead of issue ! an error when the element exists ! X4.0-17 SHE 4-May-92 Set current language before token ! X4.0-18 SHE 14-May-92 Modified related commands ! X4.2 RAM 20-Jul-94 Added set token book commands ! X4.3-1 RAM 22-Feb-95 Commented out Hyperhelp commands. ! ! NOTE - FOR ADDING PROCEDURES ! ! The following is a documentation template which is used with PDF to ! create documentation. When creating a new procedure, copy the template ! above the procedure. The information will be supplied by the documentation ! group. !doc_begin ! ! ONE LINE DEFINITION: ! «TBS» ! ! DESCRIPTION: ! «TBS» ! ! RELATED COMMANDS: ! «TBS» ! ! EXAMPLE: ! «TBS» ! ! CATEGORY: ! «TBS» ! !doc_end ! procedure lse$grammar_token_module_ident return "4.6-2"; endprocedure; procedure lse_new_token (; token_name, token_type, defined_language) !doc_begin ! ! ONE LINE DEFINITION: ! Creates an token for use with the specified language. ! ! DESCRIPTION: ! (NEW TOKEN) ! (NEW TOKENSee also SET TOKEN commands) ! (Tokenname) ! When you enter the EXPAND command while the cursor is positioned ! immediately after the token name or an abbreviation of the token name, ! LSE replaces the token name with the body of the token. !

! If you do not specify a language name, LSE uses the currently ! defined language. These language and token names become ! the defaults for subsequent SET TOKEN comands. ! ! RELATED COMMANDS: ! DELETE TOKEN ! EXPAND ! EXTRACT TOKEN ! EXTRACT NEW TOKEN ! SET TOKEN commands ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local the_token_type, lang, lang_name, the_token_name, token; ON_ERROR [LSE$_TEMPORALIASDEF]: eve$message( ERROR_TEXT ); lse$post_command_proc; RETURN FALSE; [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_new_token"); ENDON_ERROR; lse_new_token := FALSE; ! get the token name and language name ! if NOT lse$prompt_lang_pack_elem_param( token_name, LSE$TOKEN, defined_language, LSE$LANGUAGE, the_token_name, lang_name ) then lse$post_command_proc; return; endif; ! ! get the language from the name ! lang := get_info(lang_name, 'lse$language_type'); if lang = tpu$k_unspecified then eve$message (lse$_langnotdef, 0, lang_name); lse$post_command_proc; return; endif; ! ! get the token type ! if lse$prompt_list (token_type, the_token_type, lse$_tokentypeprompt, lse$_tokendelimit, lse$_tokentypelist, false, '', lse$_tokendeftype) then case the_token_type from 1 to 2 [1]: the_token_type := lse$terminal; [2]: the_token_type := lse$alias; endcase; ! Check for already exising ! token := get_info( lang, 'lse$find_token', the_token_name ); if get_info( token, 'type' ) = LSE$TOKEN_TYPE then lse$delete_token( token ); endif; ! ! create the token ! token := lse$create_token(the_token_name, the_token_type); ! associate the token with the language ! if set(lse$token, lang, token, lse$add) then ! set the current language and token ! lse$set_curr_lang_element(lang); lse$set_curr_lang_element(token); lse_new_token := TRUE; endif; endif; lse$post_command_proc; endprocedure; ! lse_new_token procedure lse_delete_token (; token_name_wild, language_name_wild) !doc_begin ! ! ONE LINE DEFINITION: ! Deletes the definition of one or more tokens associated with a ! specified language(s). ! ! DESCRIPTION: ! (DELETE TOKEN) ! ! RELATED COMMANDS: ! NEW TOKEN ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local lang_name_pattern, token_name_pattern; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_delete_token"); ENDON_ERROR; lse_delete_token := FALSE; ! Get the token ! if lse$prompt_lang_pack_elem_param( token_name_wild, LSE$TOKEN, language_name_wild, LSE$LANGUAGE, token_name_pattern, lang_name_pattern ) then lse_delete_token := lse$delete_lang_pack_elem( token_name_pattern, LSE$TOKEN, lang_name_pattern, LSE$LANGUAGE ); endif; lse$post_command_proc; endprocedure; ! lse_delete_token procedure lse_set_token_description(; description, defined_token, defined_language) !doc_begin ! ! ONE LINE DEFINITION: ! Specifies text for a token description. ! ! DESCRIPTION: ! (SET TOKEN DECSRIPTION) ! (SET TOKEN commandsSET TOKEN DECSRIPTION) ! (Tokensetting descriptions) ! Specifies a single line of text to be displayed along with the ! token name when the token is an option in the menu body of a menu-type ! placeholder. ! ! RELATED COMMANDS: ! DELETE TOKEN ! EXPAND ! EXTRACT TOKEN ! SET TOKEN commands ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local token, language, local_string; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_set_token_description"); ENDON_ERROR; lse_set_token_description:= FALSE; ! get the description string if NOT lse$prompt_string ( description, local_string, lse$_placdescprompt ) then lse$post_command_proc; return FALSE; endif; ! get the token and language if lse$get_valid_lang_pack_elem( defined_token, LSE$TOKEN, defined_language, LSE$LANGUAGE, token, language ) then set(lse$description, token, local_string); lse$set_curr_lang_element(language); lse$set_curr_lang_element(token); lse_set_token_description := true; endif; lse$post_command_proc; endprocedure; ! lse_set_token_description procedure lse_set_token_help_topic (; help_topic, defined_token, defined_language) !doc_begin ! ! ONE LINE DEFINITION: ! Sets the help topic string for the given token. ! ! DESCRIPTION: ! (SET TOKEN HELP TOPIC) ! (SET TOKEN commandsSET TOKEN HELP TOPIC) ! (Tokensetting help topics) ! (Help topic) ! This command specifies a string that LSE uses to retrieve ! help text for the token. ! The help topic string is appended to the string specified by the ! SET LANGUAGE HELP TOPIC command ! to form the complete topic string that LSE uses to look up the ! help text for this token. ! ! RELATED COMMANDS: ! NEW TOKEN ! EXTRACT TOKEN ! SET LANGUAGE HELP TOPIC ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local token, language, local_string; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_set_token_help_topic"); ENDON_ERROR; lse_set_token_help_topic := FALSE; ! get the description string if NOT lse$prompt_string ( help_topic, local_string, lse$_langtopicprompt ) then lse$post_command_proc; return FALSE; endif; ! get the token and language if lse$get_valid_lang_pack_elem( defined_token, LSE$TOKEN, defined_language, LSE$LANGUAGE, token, language ) then set(lse$help_topic, token, local_string); lse_set_token_help_topic := true; lse$set_curr_lang_element(language); lse$set_curr_lang_element(token); endif; lse$post_command_proc; endprocedure; ! lse_set_token_help_topic procedure lse_set_token_inherit(; placeholder_name, defined_token, defined_language ) !doc_begin ! ! ONE LINE DEFINITION: ! Specifies the name of a defined placeholder that expands in place of ! the token. ! ! DESCRIPTION: ! (SET TOKEN INHERIT) ! (SET TOKEN commandsSET TOKEN INHERIT) ! (Alias type tokens) ! (Tokenalias type) ! When you expand an alias-type token, the body of the specified placeholder ! is substituted for the token name. Since tokens of this type inherit ! all their attributes from the specified defined placeholder, no ! other attributes may be set for them. This command is valid only ! for alias-type tokens. ! ! RELATED COMMANDS: ! EXPAND ! EXTRACT TOKEN ! NEW TOKEN ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local token, language, local_string; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_set_token_inherit"); ENDON_ERROR; lse_set_token_inherit := FALSE; ! get the name of the inherited placeholder if NOT lse$prompt_string ( placeholder_name, local_string, lse$_placnamprompt ) then lse$post_command_proc; return FALSE; endif; ! get the token and language if lse$get_valid_lang_pack_elem( defined_token, LSE$TOKEN, defined_language, LSE$LANGUAGE, token, language ) then set(lse$placeholder, token, local_string); lse$set_curr_lang_element(language); lse$set_curr_lang_element(token); lse_set_token_inherit := true; endif; lse$post_command_proc; endprocedure; ! lse_set_token_inherit procedure lse_show_token ( ; token_name_wild, defined_language) !doc_begin ! ! ONE LINE DEFINITION: ! Displays the definitions and characteristics of one or more tokens. ! ! DESCRIPTION: ! (SHOW TOKEN) ! (Tokenshowing attributes) ! If you specify a token name, LSE displays all the attributes ! associated with that token. If you specify a wildcard ! token name, ! LSE displays a list with brief information about each matching token. !

! You can navigate through the list using Ctrl/F (forward) ! and Ctrl/B (reverse). Ctrl/E (expand) lets you dislay full ! information about the indicated placeholder. The COLLAPSE command ! reverts back to the brief display. ! ! RELATED COMMANDS: ! EXTRACT TOKEN ! NEW TOKEN ! SET TOKEN commands ! ! CATEGORY: ! Help ! !doc_end ! local saved_lang, the_lang, token_name_pattern, the_lang_name; ON_ERROR [OTHERWISE]: if saved_lang <> 0 then lse$set_curr_lang_element(saved_lang); endif; lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_show_token"); ENDON_ERROR; lse_show_token := FALSE; ! Get the token ! if lse$prompt_lang_pack_elem_param( token_name_wild, LSE$TOKEN, defined_language, LSE$LANGUAGE, token_name_pattern, the_lang_name) then the_lang := get_info(the_lang_name, 'lse$language_type'); if the_lang <> tpu$k_unspecified then ! Saved the current language ! saved_lang := lse$get_curr_lang_element(LSE$LANGUAGE); lse$set_curr_lang_element(the_lang); ! Do the show ! if lse$shlst_process( token_name_pattern, lse$token_list ) then lse_show_token := TRUE; else ! Restore the current language ! lse_show_token := FALSE; lse$set_curr_lang_element(saved_lang); endif; else eve$message (lse$_langnotdef, 0, the_lang_name); endif; endif; lse$post_command_proc; endprocedure; ! lse_show_token procedure lse_extract_token (; token_name_wild, language_name_wild ) !doc_begin ! ! ONE LINE DEFINITION: ! Extracts the definition of the specified token(s). ! ! DESCRIPTION: ! (EXTRACT TOKEN) ! (Tokenextracting) ! LSE inserts the indicated definitions at the end of the current ! buffer in a form that lets them be executed with the EXECUTE ! BUFFER PLSE command. ! ! RELATED COMMANDS: ! EXTRACT NEW TOKEN ! NEW TOKEN ! SET TOKEN commands ! DELETE TOKEN ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local token_name_pattern, lang_name_pattern; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_extract_token"); ENDON_ERROR; lse_extract_token := FALSE; if lse$prompt_lang_pack_elem_param( token_name_wild, LSE$TOKEN, language_name_wild, LSE$LANGUAGE, token_name_pattern, lang_name_pattern ) then lse_extract_token := lse$extract_lang_pack_elem(token_name_pattern, lse$token, lang_name_pattern, lse$language, FALSE) endif; lse$post_command_proc; endprocedure; ! lse_extract_token procedure lse_extract_new_token (; token_name_wild, language_name_wild ) !doc_begin ! ONE LINE DEFINITION: ! Extracts the definition of the specified token(s) defined during this ! editing session. ! ! DESCRIPTION: ! (EXTRACT NEW TOKEN) ! (Tokenextracting) ! LSE inserts the indicated definitions at the end of the current ! buffer in a form that lets them be executed with the EXECUTE ! BUFFER PLSE command. ! ! RELATED COMMANDS: ! NEW TOKEN ! SET TOKEN commands ! DELETE TOKEN ! SHOW TOKEN ! EXTRACT TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local token_name_pattern, lang_name_pattern; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_extract_new_token"); ENDON_ERROR; lse_extract_new_token := FALSE; if lse$prompt_lang_pack_elem_param( token_name_wild, LSE$TOKEN, language_name_wild, LSE$LANGUAGE, token_name_pattern, lang_name_pattern ) then lse_extract_new_token := lse$extract_lang_pack_elem(token_name_pattern, lse$token, lang_name_pattern, lse$language, TRUE) endif; lse$post_command_proc; endprocedure; ! lse_extract_new_token procedure lse_set_token_body_line (; body_string, indent_type, indent_column, tab_or_space, same_next_line, add_remove, defined_token, defined_language) !doc_begin ! ! ONE LINE DEFINITION: ! Specifies a body line of a token. ! ! DESCRIPTION: ! (SET TOKEN BODY LINE) ! (SET TOKEN commandsSET TOKEN BODY LINE) ! (Tokenterminal) ! (Tokensetting body lines) ! The body of a terminal type token is the text of the token ! expansion; when a terminal token is expanded, the token ! is replaced with the text of the token body. !

! The parameters to this command allow you to specify the format ! of the body when it is expanded. See the parameter glossary for ! a detailed explanation of how these work. ! ! RELATED COMMANDS: ! DELETE TOKEN ! EXPAND ! EXTRACT TOKEN ! SET TOKEN commands ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! local same_line, token, language, local_keyword, local_int, local_type, local_string, tok_line, add_flag; ON_ERROR [OTHERWISE]: lse$post_command_proc; lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, "lse_set_token_body_line"); ENDON_ERROR; ! get the string (allowed to be '') if body_string= '' then local_string := ''; else if NOT lse$prompt_string ( body_string, local_string, lse$_placbodyprompt ) then lse$post_command_proc; return FALSE; endif; endif; ! get keyword if NOT lse$prompt_list ( indent_type, local_keyword, lse$_placindkeyprompt, lse$_placdelimit, lse$_plackwrdlist, false, '', lse$_placdefindkwrd) then lse$post_command_proc; return FALSE; endif; case local_keyword from 1 to 5 [1] : local_keyword := lse$expand; [2] : local_keyword := lse$current; [3] : local_keyword := lse$previous; [4] : local_keyword := lse$fixed; endcase; ! get integer if NOT lse$prompt_number ( indent_column, local_int, lse$_placindnumprompt, '', lse$_placdefindnum ) then lse$post_command_proc; return FALSE; endif; ! get type if NOT lse$prompt_list ( tab_or_space, local_type, lse$_placindtypeprompt, lse$_placdelimit, lse$_placindtypelist, false, '', lse$_placdefindtype ) then lse$post_command_proc; return false; endif; case local_type from 1 to 2 [1] : local_type := lse$space; [2] : local_type := lse$tab; endcase; ! get same/next line if NOT lse$prompt_list ( same_next_line, same_line, lse$_placlineprompt, lse$_placdelimit, lse$_placlinelist, false, '', lse$_placdefline) then lse$post_command_proc; return FALSE; endif; case same_line from 1 to 2 [1] : same_line := false; [2] : same_line := true; endcase; ! get add_remove if NOT lse$prompt_add_remove( add_remove, add_flag, '', '', lse$_langdefaddrmv ) then lse$post_command_proc; return FALSE; endif; ! get the token if NOT lse$get_valid_lang_pack_elem( defined_token, LSE$TOKEN, defined_language, LSE$LANGUAGE, token, language ) then lse$post_command_proc; return FALSE; endif; ! create a token line with associated values tok_line := lse$create_token_line(); set(lse$lines_string, tok_line, local_string); set(lse$lines_indent, tok_line, local_keyword); set(lse$lines_integer, tok_line, local_int); set(lse$lines_indent_type, tok_line, local_type); set(lse$same_line, tok_line, same_line); ! set the token line into the token lse_set_token_body_line := set(lse$token_line, token, tok_line, add_flag); lse$set_curr_lang_element(language); lse$set_curr_lang_element(token); lse$post_command_proc; endprocedure; ! lse_set_token_body_line !-Hyperhelp !procedure lse_set_token_reference (; book_reference, defined_token, defined_language) !-Hyperhelp - added comment tags around doc_begin and doc_end ! !doc_begin ! ! ONE LINE DEFINITION: ! Specifies a book reference tag string, defining the section of an ! online book to display for a token. ! ! DESCRIPTION: ! (SET TOKEN REFERENCE) ! (SET TOKEN commandsSET TOKEN REFERENCE) ! (Help reference) ! (Tokensetting book reference tag strings) ! LSE uses a VAX DOCUMENT reference tag string to retrieve the ! online text for a token. If you do not specify a reference ! with SET TOKEN REFERENCE, LSE defaults to the book section referenced ! in the SET LANGUAGE REFERENCE command. ! ! RELATED COMMANDS: ! EXTRACT TOKEN ! NEW TOKEN ! SET LANGUAGE TOKEN ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! ! ! local ! token, ! language, ! local_string; ! ! ON_ERROR ! [OTHERWISE]: ! lse$post_command_proc; ! lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, ! "lse_set_token_reference"); ! ENDON_ERROR; ! ! lse_set_token_reference := FALSE; ! ! ! get the description string ! if NOT lse$prompt_string ( book_reference, ! local_string, ! lse$_bookrefprompt ) ! then ! lse$post_command_proc; ! return FALSE; ! endif; ! ! ! get the token and language ! if lse$get_valid_lang_pack_elem( defined_token, ! LSE$TOKEN, ! defined_language, ! LSE$LANGUAGE, ! token, ! language ) ! then ! set(LSE$BOOKREFERENCE, token, local_string); ! lse_set_token_reference := true; ! lse$set_curr_lang_element(language); ! lse$set_curr_lang_element(token); ! endif; ! ! lse$post_command_proc; ! !endprocedure; ! lse_set_token_reference !-Hyperhelp !-Hyperhelp !procedure lse_set_token_book (; file_spec, defined_token, defined_language) !-Hyperhelp - added comment tags around doc_begin and doc_end ! !doc_begin ! ! ONE LINE DEFINITION: ! Specifies an online book file name that LSE uses ! to retrieve online text for a token. ! ! DESCRIPTION: ! (SET TOKEN BOOK) ! (SET TOKEN commandsSET TOKEN BOOK) ! (Help reference) ! (Tokensetting book file name strings) ! If you do not specify a book with SET TOKEN BOOK, LSE defaults to the ! book defined in the SET LANGUAGE BOOK command. ! ! RELATED COMMANDS: ! EXTRACT TOKEN ! NEW TOKEN ! SET LANGUAGE TOKEN ! SHOW TOKEN ! ! CATEGORY: ! Language ! !doc_end ! ! ! local ! token, ! language, ! the_file_spec; ! ! ON_ERROR ! [OTHERWISE]: ! lse$post_command_proc; ! lse$$unexpected_error( ERROR, ERROR_TEXT, ERROR_LINE, ! "lse_set_token_book"); ! ENDON_ERROR; ! ! lse_set_token_book := FALSE; ! ! ! get the description string ! ! IF NOT lse$prompt_existing_file ( file_spec, ! the_file_spec, ! lse$_bookprompt, ! '', ! '') ! then ! lse$post_command_proc; ! return FALSE; ! endif; ! ! ! get the token and language ! if lse$get_valid_lang_pack_elem( defined_token, ! LSE$TOKEN, ! defined_language, ! LSE$LANGUAGE, ! token, ! language ) ! then ! set(LSE$BOOK, token, the_file_spec); ! lse_set_token_book := true; ! lse$set_curr_lang_element(language); ! lse$set_curr_lang_element(token); ! endif; ! ! lse$post_command_proc; ! !endprocedure; ! lse_set_token_book !-Hyperhelp