Hermit Crab Parsing Engine Specification


Miscellaneous Functions and Variables



Download 403.76 Kb.
Page18/20
Date31.07.2017
Size403.76 Kb.
#25627
1   ...   12   13   14   15   16   17   18   19   20

6.7Miscellaneous Functions and Variables

6.7.1*quit_on_error*


Summary: If the *quit_on_error* variable is true, when a command is executed that terminates abnormally, calling send_error_message, the morpher writes the error message to the current output. It then returns to the top-level read-eval-print loop, closing any files from which it has been reading input or to which it has been sending output. All further input comes from standard input, and all further output is sent to standard output. If the *quit_on_error* variable is false, when a command is executed that terminates abnormally, the morpher issues the error message but continues with the next command in the current input source, and continues writing output to the current output.

Note that *quit_on_error* is defined on a per-language basis, not globally.



Default: true

Possible values: true or false

6.7.2load_msg_file


Summary: Loads a file of messages in some language convenient for the user.

Argument: file name (obligatory) (string)

Normal output: Message hc6514 “Morpher: Loaded message file .”, where is the name of the file.

Abnormal output: Message hc6049 “Morpher error: Unable to load message file .” This may be because the file does not exist, or because it was in the wrong format.

Note: The format for error messages in a file of messages follows the example below:

msg_text(hc6041, 'Morpher error: Natural class «name» is unknown.').

where « (ASCII 174) and » (ASCII 175) enclose the labels of the arguments, which will be replaced by the actual arguments when the message is output. The argument labels may appear in any order. Argument labels should not be omitted; if they are, the corresponding arguments will appear at the end of the message.

If no message file is loaded, the messages will be printed out in the form



This format will also be used for any messages not listed in the most recently loaded message file.


6.7.3open_language


Summary: Adds a language to the list of possible languages that the morpher variable *cur_lang* may refer to, and sets that variable to point to the new language.

Argument: name of the language (obligatory): string

Normal output: Message hc6510 “Morpher: Opened new language .” All following commands refer to this named language until a new language is opened with this command, or until the variable *cur_lang* is changed.

Abnormal output: Message hc6045 “Morpher error: Language has already been opened.” (The variable *cur_lang* retains whatever value it had before this command was issued.)

hc6046 “Morpher error: Invalid language name .” (Note that there may be an implementation-specific limitation.


6.7.4initialization_complete


Summary: Indicates that the current language has been initialized.

Argument: none

Normal output: Message hc6525 “Morpher: Initialization complete.”

Abnormal output: None. (Calling this function twice without closing and re-opening the language between times will not cause an error.)

Purpose: If an error occurs between the time a language has been opened (with open_language) and when this command is issued, while the variable *quit_on_error* is true, the language will be closed. This ensures against a language being partially initialized.

6.7.5close_language


Summary: Removes a language from the list of languages that the morpher variable *cur_lang* may refer to. After this command, if the value of the variable *cur_lang* was the language which was closed, the variable’s new value is *unknown*; otherwise the variable retains its previous value.

Argument: name of the language (obligatory): string

Normal output: Message hc6511 “Morpher: Closed language ; current language is .” where was the name given in this command’s argument, and is the new value of the variable *cur_lang*. (See comments above concerning the new value of *cur_lang*.)

Abnormal output: hc6023 “Morpher error: Unknown language .” (The specified language has not already been opened by the command open_language; the current language remains whatever it was before.)

Warning: Attempting to perform any commands except setting the variable *cur_lang*, redirecting input or output, or terminating the morpher when that variable has the default value *unknown* will result in error message hc6036 “Morpher error: There is no current language.”

6.7.6morpher_input_from_file


Summary: Loads a file of morpher commands. Commands are taken from the named file until end of file, bypassing any upstream modules (e.g. the preprocessor). Morpher_input_from_file commands may be nested.

Argument: fname (obligatory) (string)

Normal output: Message hc6508 “Morpher: Taking input from file .” Any messages resulting from processing of the morpher commands in the file will follow this message. At end of file, message hc6521 “Morpher: Finished taking input from file .”

Abnormal output: If the designated file is already open for output, the function send_error_msg is called with the message hc6030 “Morpher error: unable to open file for input, because it is already open for output.”

Operating system errors (such as invalid file name) should be trapped and output as errors.



See also: *quit_on_error* (section 6.7.1)

6.7.7morpher_output_to_file


Summary: Redirects all output (including error output) produced by processing morpher commands to a file or to standard output. If the file already exists, output is appended to the end. (It is assumed the shell will provide a means of deleting files if it is desired instead to overwrite them.) If output is currently to a file (not standard output), that file is closed. (Thus, only one file can be open for output at a time. This should not be a limitation, as a given file can be opened any number of times for output.)

Argument: fname (obligatory) (string). The special string “stdout” redirects output to standard output for the morpher module, i.e. to whatever module is downstream from the morpher.

Normal output: Message hc6522 “Morpher: Sending output to file .” This message is sent to whatever the output is being sent to before the command takes effect. (There is no message when a file is closed.)

Abnormal output: If the designated file is already open for input, the function send_error_msg is called with the message hc6031 “Morpher error: unable to open file for output, because it is already open for input.”

Operating system errors (such as invalid file name) should be trapped and the error message sent to standard output (not to the file). It is not an error to call morpher_output_to_file on a file which is already open for output.


6.7.8terminate_morpher


Summary: Causes the process running the morpher to quit.

Argument: none

Normal output: none

Abnormal output: none

Implementation note: This function may be superfluous under some operating systems.


Download 403.76 Kb.

Share with your friends:
1   ...   12   13   14   15   16   17   18   19   20




The database is protected by copyright ©ininet.org 2024
send message

    Main page