Lhogho  0.0.027
Errors

The errors module is responsible for creating and handling errors.

Structure

Error atoms contain a description of an error, defined by error code, error position and error data.

The error code (ERRCODE) is used to identify the type of the error. It is an integer number. Some error codes are used for non-error exceptions - these are ones generated by bye and throw.

The error data (ERRDATA) is a value which is associated with the error condition. The data is set when the error is generated. The data for throw exceptions is a list with two elements -- the first one is the tag, and the second one is the value passed as second input of throw.

The error position (ERRPOS) is a list of all accumulated error positions. They are used to track stack calls if needed. Each element of the list points to a single place of the source -- actually it point an atom from the source where the error has been generated. The system can use this atom and recover (in most cases) the real address of the error in respect to the original source.

Use IS_ERROR macro to check whether the atom is error.

errors_structure.png
Error atom structure

These are the errors reported by Lhogho:

These are the exitters reported by Lhogho:

The codes for exitters are only within the interval from FIRST_EXIT_CODE to LAST_EXIT_CODE inclusive.

Error ERROR_INCOMPLETE_PAIR

The ERROR_INCOMPLETE_PAIR error is generated by functions tokenize() and parse() defined in parder.c when only one symbol is available in a pair of symbols. The first symbol pointed to by ERRPOS() is the existing symbol form the pair. It determines the missing counterpart.

Symbol Description
|
A closing bar | is not found till the end of the source.
\
A backslash \ is the last character in the source.
~
A tilde ~ used for line continuation is on the last line of the source.
[
An opening square bracket [ does not have matching closing bracket ].
]
A closing square bracket ] does not have matching opening bracket [.
caption.png
Error ERROR_INCOMPLETE_PAIR generated by the tokenizer
Symbol Description
(
An opening parenthesis ( does not have matching closing parenthesis ) within the current sublist.
)
A closing parenthesis ) does not have matching opening parenthesis ( within the current sublist.
caption.png
Error ERROR_INCOMPLETE_PAIR generated by the parser

In the general case it is not possible to provide a solution how to fix a program having an ERROR_INCOMPLETE_PAIR error, because there are many possible solutions and which of them is the correct one depends on the program logic.

Error ERROR_EMPTY_EXPRESSION

The ERROR_EMPTY_EXPRESSION is generated by parse() when an empty expression is met: ( ). The first symbol pointed to by ERRPOS() is the closing parenthesis. Resolving this error is most often done by inserting a value or an expression inside the parentheses. If the idea was to create an empty list use empty square brackets [ ].

Error ERROR_CROWDED_EXPRESSION

The ERROR_CROWDED_EXPRESSION is generated by parse() when there are more than one values in a parenthesized expression. The first symbol pointed to by ERRPOS() is the first extra value within the parentheses. Resolving this error is most often done by removing extra expressions or using a function to process all expressions into a single value.

Error ERROR_MISSING_LEFTS

The ERROR_MISSING_LEFTS is generated by parse() when an variable receives less left parameters than it needs. The first symbol pointed to by ERRPOS() is the hungry var itself. Resolving this error is most often done by inserting a value or an expression before the var.

Error ERROR_MISSING_RIGHTS

The ERROR_MISSING_RIGHTS is generated by parse() when an variable receives less right parameters than it needs. The first symbol pointed to by ERRPOS() is the hungry var itself. Resolving this error is most often done by inserting a value or an expression after the var.

Error ERROR_EMPTY_TO_END

The ERROR_EMPTY_TO_END error is generated by preparse() when an empty TO ... END definition is met. Empty means that there are no any tokens in between. Resolving this error is often done by adding at least a name for the definition.

Error ERROR_MISSING_NAME

The ERROR_MISSING_NAME error is generated by define_user_function() when it is not possible to determine the name of a user-defined function. The name should be a word which does not start with colon : or double quotes ", is on the same line as the TO word, and is either right after TO or after the left inputs. Resolving this error is most often done by fixing the header of the function.

Error ERROR_DUPLICATE_INPUT

The ERROR_DUPLICATE_PARAM error is generated by define_user_function() when it finds two inputs of a function with the same names. It doesn't matter whether the inputs are both left, right or one is left and the other is right. Resolving this error is most often done by renaming one of the duplicate names.

Error ERROR_UNKNOWN_OPTION

The ERROR_UNKNOWN_OPTION error is generated by init_options() when it finds unknown command-line option. Unknown options are reported and ignored - the execution continues as if they were missing.

Error ERROR_CROWDED_SOURCES

The ERROR_CROWDED_SOURCES error is generated by init_options() when it finds more than one input source files. Only the first source file is used, the rest are just ignored.

Error ERROR_OS_ERROR

The ERROR_OS_ERROR error is generated by read_word() when the operating system returns an error message (e.g. the file does not exists).

Error ERROR_INCOMPATIBLE_REDEFINITION

The ERROR_INCOMPATIBLE_REDEFINITION error is generated when a function is redefined with different number of input parameters (either left or right).

Error ERROR_UNUSED_VALUE

The ERROR_UNUSED_VALUE error is generated from the compiled Lhogho program when a function returns a value which is not used.

Error ERROR_MISSING_VALUE

The ERROR_MISSING_VALUE error is generated from the compiled Lhogho program when a command is used as a function (i.e. a value is expected but the command does not output anything).

Error ERROR_MISSING_FOR_LIMITS

The ERROR_MISSING_FOR_LIMITS error is generated ar compile-time when the second input of FOR command is a list with 0 or 1 elements.

Error ERROR_DO_NOT_KNOW

The ERROR_DO_NOT_KNOW error is generated by the parser when a function with a given name cannot be found in the already defined system and user functions.

Error ERROR_UNUSED_VALUE

The ERROR_UNKNOWN_VAR error is generated by the compiler when it attempts to compile reference to a variable which is not known at the time of compilation.

Error ERROR_BOOLEAN_EXPECTED

The ERROR_BOOLEAN_EXPECTED error is generated at run-time when a function expects boolean value as argument but differrent type is passed.

Error ERROR_NOT_AN_INTEGER

The ERROR_NOT_AN_INTEGER error is generated at run-time when a function expects integer value as argument but data passed can not be converted to integer type.

Error ERROR_NOT_A_LIST

The ERROR_NOT_A_LIST error is generated at run-time when a function expects list as argument but data passed is not a list.

Error ERROR_NOT_A_LIST_CONST

The ERROR_NOT_A_LIST_CONST error is generated at compile-time when a function expects list constant as argument but data passed is not a list or is not a constant list. List constants are expected by functions like IF, REPEAT, WHILE, etc.

Error ERROR_NOT_A_WORD

The ERROR_NOT_A_WORD error is generated at run-time when a function expects word or subword as argument but data passed can not be converted to this type.

Error ERROR_NOT_A_WORD_CONST

The ERROR_NOT_A_WORD_CONST error is generated at compile-time when a function expects word or subword constant. Word constants are expected for the first input of FOR commands.

Error ERROR_INCOMPATIBLE_DATA

The ERROR_INCOMPATIBLE_DATA error is generated at run-time when the value of a function parameter is not compatible with the function itself. For example function expects two words or two lists as arguments but a list and a word is passed.

Error ERROR_TOO_BIG_NUMBER

The ERROR_TOO_BIG_NUMBER error could be generated both at compile-time and run-time. It is generated for situations where a number is expected and the number is too big. For example, the number of repetitions in a repeat command cannot be bigger than 2147483648.

Error ERROR_TOO_SMALL_NUMBER

The ERROR_TOO_SMALLs_NUMBER error could be generated both at compile-time and run-time. It is generated for situation where a number is expected and the number is too small. For example, the number of repetitions in a repeat command cannot be less than 1.

Error ERROR_NOT_A_VAR

The ERROR_NOT_A_VAR error is generated by the compiler when it tries to compile a reference to a procedure or a commands as if it is a variable. The reference could be both reading variable's value or setting it. For example: PRINT :LIST and MAKE "LIST 1</tt> would both generate the error. To override a primitive function redeclare it as a local variable with <tt>LOCAL "LIST. Afterwards it can be used as a standard user-defined variable.

Error ERROR_NOT_A_TAG

The ERROR_NOT_A_TAG error is generated by the compiler when a tag defined by tag command is not a valid name of a tag (e.g. it is a name of a variable or command). The error is also generated during the execution of command goto when its input is not a name of an existing tag.

Error ERROR_NOT_A_USER_FUNCTION

The ERROR_NOT_A_USER_FUNCTION error is generated by runtime functions when they expect an input, which is a anme of a user-defined function or command (e.g. text).

Error ERROR_NOT_A_FUNCTION

The ERROR_NOT_A_FUNCTION error is generated when a variable is used as a function or a command.

Error ERROR_NOT_A_TYPE_NAME

The ERROR_NOT_A_TYPE_NAME error is geerated at runtime when a type name cannot be resolved into any of the internally supported types. Type names are used by packs, external and internal functions.

ERROR_BAD_PROTOTYPE

The ERROR_BAD_PROTOTYPE error is generated at runtime when an internal or external function is being defined and the prototype does not match the function's Logo definition.

Exitter EXIT_BY_BYE

The EXIT_BY_BYE error atom is generated by the bye command (rt_bye).

Exitter EXIT_BY_THROW_TOPLEVEL

The EXIT_BY_THROW_TOPLEVEL error atom is generated by the throw command with tag toplevel (rt_throw).

Exitter EXIT_BY_THROW_SYSTEM

The EXIT_BY_THROW_SYSTEM error atom is generated by the throw command with tag system (rt_throw).

Exitter EXIT_BY_THROW_ERROR

The EXIT_BY_THROW_ERROR error atom is generated by the throw command with only one input - the tag error (rt_throw).

Exitter EXIT_BY_THROW_USER_ERROR

The EXIT_BY_THROW_USER_ERROR error atom is generated by the throw command with two inputs - the tag error and a value for the error message (rt_throw).

Exitter EXIT_BY_THROW_TAG

The EXIT_BY_THROW_TAG error atom is generated by the throw command with only one input - a user-defined tag (rt_throw).

Exitter EXIT_BY_THROW_TAG_VALUE

The EXIT_BY_THROW_TAG_VALUE error atom is generated by the throw command with two inputs - a user-defined tag and a value (rt_throw).


[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Tue Feb 7 2012