Evaluation

Once FMSLogo has parsed a line into an instruction list, it runs the instruction list. An instruction list is expected to be composed of one or more instructions, which are expressions that do not output a value. When FMSLogo encounters a token that is neither a variable, a number, a word, an infix operator, a parenthesis, a brace, nor a bracket, then the token is interpreted as the name of a procedure. If it's the name of a primitive or a procedure that has already been defined, then FMSLogo calls that procedure. Otherwise, FMSLogo attempts to load the procedure into the workspace. If a ".lgo" file with the same name as with the procedure exists in the current working directory, then FMSLogo loads that file (as with the LOAD command). If no errors were encountered and the procedure was defined by loading the file, then that procedure is called. However, if the procedure is still not defined and a file with the same name exists in the Logolib directory, then that Logolib file is loaded. If no errors were encountered and the procedure was defined by loading the Logolib file, then the procedure is called. If the procedure is still not defined, then FMSLogo throws an "I don't know how to" error.

To call a procedure, FMSLogo must determine how many inputs to provide it. If the procedure name is not preceded by an open parenthesis, then FMSLogo continues recursively parsing and evaluating the tokens which follow the procedure name on the line until it has enough values to satisfy that procedure's default number of inputs. It then runs the procedure, providing those values as input. However, if a procedure name is immediately preceded by an open parenthesis, then FMSLogo continues parsing and evaluating the tokens which follow the procedure name until the close parenthesis is reached. In both cases, after the procedure is called, any tokens which come after its inputs are parsed and evaluated as the next instruction.


SourceForge.net Logo