Interpreter inheritance

The inheritance mechanism is designed to reuse the already developed interpreters when translating and interpreting control programs with a similar but different syntax. The degree of the required difference of the control program from the original for the implementation of the heir, and not the new interpreter, we propose to determine the developer independently.

The purpose of the successor interpreter is to translate and interpret differences in the control program, as well as transfer control to the parent interpreter to translate and interpret similar parts of the G-code.

The differences in the implementation of the interpreter-heir from the usual interpreter are as follows:

  1. In the file of interpreter settings (SNCI) it is necessary to fill in the fields ParentID, ParentFileName.

  2. If necessary, override existing or add new registers. You can do this by adding changes to the list of registers of the SNCI file or to the list of registers returned by the INCT_Interpreter.GetRegisters function of the interpreter program library.

  3. Implement the heir interpreter software library. When a library is implemented, the functions and methods of the program library of the interpreter-parent are called or not by the successor, depending on the algorithms laid down for the translation and interpretation of the text of the control program. The parent interpreter interface (INCT_Interpreter) is passed to the heir during initialization.

Inheritance is possible only from one parent. The number of interpreters-heirs from one parent and the depth of inheritance are not limited.


Register inheritance.

Heir interpreter registers override the parent interpreter registers. Register inheritance is implemented as follows. In the resulting list (list of base registers) produced:

  1. Load the list of registers from the interpreter-heir configuration file.

  2. Loading the list of registers from the program library of the interpreter-heir (INCT_Interpreter.GetRegisters). If a register with the same name already exists in the list of base registers, then it is not loaded.

  3. Load the list of registers from the parent interpreter settings file. If a register with the same name already exists in the list of base registers, then it is not loaded.

  4. Loading the list of registers from the parent interpreter program library. If a register with the same name already exists in the list of base registers, then it is not loaded.

  5. Load the list of registers from the parent interpreter's parent settings file. If a register with the same name already exists in the list of base registers, then it is not loaded.

  6. Load a list of registers from the parent interpreter parent program library. If a register with the same name already exists in the list of base registers, then it is not loaded.

  7. And so on, until the very first parent.


Inheritance of the program library.

When initializing the parent interpreter program library, a number of methods and functions are called by the SprutCAM X core and do not require calling these functions from a successor:

  1. INCT_Interpreter.GetIdentifier.

  2. INCT_Interpreter.GetRegisters.

  3. INCT_Interpreter.SetInterface.

  4. INCT_Interpreter.Initialize.

The remaining functions and methods of the program library of the interpreter-parent are called or not by the heir, depending on the algorithms laid down for translation and interpretation of the text of the control program. To call the methods of the parent, when initializing the program library of the interpreter-heir, it also passes the interface of the interpreter-parent (INCT_Interpreter.SetInterface function).

The following are recommendations for invoking parent interpreter functions and methods from a heir interpreter.

  1. INCT_Interpreter.TransLine - call the parent's TransLine in case the analysis of the line of the control program did not reduce the original line. All parameters that the parent method returned (ProcessedChars, NextLine, BreakLine) are passed to the output parameters of the method of the heir.

  2. INCT_Interpreter.DefineRegister - call the parent's DefineRegister in case the definition of the register at the address is not made in the heir. The Index parameter and the result of the work that the parent function returned to the output parameter and the result of the inheritor function.

  3. INCT_Interpreter.BeforeInterprete - call parent BeforeInterprete always.

  4. INCT_Interpreter.Interprete - call Interprete parent in case the interpretation of the interpretation object is not performed by the heir.

  5. INCT_Interpreter.AfterInterprete - call parent AfterInterprete always.

  6. INCT_Interpreter.EndOfProgram - call the parent EndOfProgram always, if the heir does not specify the end of the control program. The result of the work of the parent function is passed as the result of the work function of the heir.

The page Examples of interpreters with source codes will give an example of the source codes of the heir interpreter library, the 'dll' compiled from them, and an example of the settings file.