INTERPRET - ponyatov/orth GitHub Wiki

INTERPRET

Full internals description See Interpreter.

FVM command implemented as function with one string parameter : PAD=source code stream

## `INTERPRET ( -- )` interpreter loop
## @param[in] PAD source code stream (string)
def INTERPRET(PAD=''):
    lexer.input(PAD)            # feed source to lexer
    while True:                 # infty interpreter loop
        if not WORD():          # end of source
            del D[-1] ; break   # drop None from stack and exit loop
        if D[-1].type == 'COMMENT':
            del D[-1]
        elif D[-1].type in ['WORD','OPERATOR']:
            FIND()              # lookup in vocabulary
            if isCallable(D[-1]):
                EXECUTE()       # execute found object
    wnMain.onUpdate(None)       # update GUI (stack, vocabulary,..)
W['INTERPRET'] = INTERPRET