Thursday, August 29, 2013

Encoder – Introduction

As mentioned a while ago (March 25, 2011), the translation of more BASIC commands is being postponed so that the other modules can be developed.  The translation of enough commands with expressions has been implemented (INPUT, LET, and PRINT) to make a useful, though very limited, BASIC program (limited by the lack of conditionals and loops).

These modules include the encoder to convert a translated program line into the internal program code, the recreator to convert the internal program code back to program text, and the run-time module to execute the internal program code.  Once initial versions of these three modules are complete and connected to the GUI, additional commands will be implemented one at a time for each of the four modules.

Only certain elements of the BASIC language will be implemented initially to simplify development of the remaining modules.  This includes just simple variables and constants, with arrays, defined functions and user functions implemented later.  Variables come from the identifier with no parentheses token type, which could also be user functions (either a call to a function with no arguments, or an assignment of the function return value inside the function).  For now this token type will be assumed to be a variable until functions are implemented.

A major part of encoder development is to define the internal program code format, the code that will be stored in the program and executed by the run-time module.  The other major part are the dictionaries that will hold the information about variables, arrays, constants, remarks, functions, etc., which will be referenced from the program code.  For example, the actual names (variables, functions, etc.) are not be stored in the internal program, but in a dictionary and the program code contains references to these dictionary entries.

A minor part of encoder development (not needed by the final application), is the conversion of individual instructions of the program code into text.  This is similar to conversion of the translated tokens into text for output by the command line test mode, or in the GUI program view.  The GUI program view translator output will be replaced by the encoder output, which will have the same reverse polish notation layout as the translator output.

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)