Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next

  • Chapter - Keyboard Primitive

    [This is the primitive routine to read from the keyboard: it usually delegates
    this to a routine specific to the virtual machine being used, but sometimes
    uses a hacked version to allow TEST commands to work. (When a TEST is running,
    the text in the walk-through provided is fed into the buffer as if it had
    been typed at the keyboard.)]

    [ This is called from outside Parser.i6t, and the multiple #defines means it's pointless to translate it. ]
    To read a command into (buffer - a 1-based index based rulebook producing ZSCII letters) and parse it into (parse table - a 1-based index based rulebook producing structs):
    (- KeyboardPrimitive({buffer}, {parse table}); -).

    Include (-
    [ KeyboardPrimitive a_buffer a_table;
        ! In case of an array entry corruption that shouldn't happen, but would be disastrous if it did.
    #Ifdef TARGET_ZCODE;
        a_buffer->0 = INPUT_BUFFER_LEN;
        a_table->0 = 15; ! Allow to split input into this many words
    #Ifdef DEBUG;
    #Iftrue ({-value:NUMBER_CREATED(test_scenario)} > 0);
        return TestKeyboardPrimitive(a_buffer, a_table);
        return VM_ReadKeyboard(a_buffer, a_table);