Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 8 - From the Individual VM's i6t File

    To decide what understood word is (n - a pattern union) as an understood word:
    (- VM_NumberToDictionaryAddress({n} - (+ the misunderstood command +)) -).

    To decide what number is (word - an understood word) as a number:
    (- VM_DictionaryAddressToNumber({word}) -).

    To decide if (word - an alternative grammar result) would be an invalid understood word:
    (- VM_InvalidDictionaryAddress({word}) -)

    The restore window colors rule translates into I6 as "VM_RestoreWindowColours".

    [ Do not use the below with "the player's input buffer". Get the # letters copied from "the number of elements in (buf)" ]
    To copy (t - some text) into (buf - a 1-based index based rulebook producing ZSCII letters):
    (- {buf}-->0 = INPUT_BUFFER_LEN;
        VM_PrintToBuffer({buf}, INPUT_BUFFER_LEN, {t}); -).

    [ This appends 2 - 4 spaces (which were an array size briefly), then the word, onto the end of the buffer. ]
    To append (w - an understood word) to (buf - a 1-based index based rulebook producing ZSCII letters):
    (- {-require-ctvs}
        ct_0 = {buf};
        ct_1 = (+ the number of letters in the chosen array +) + WORDSIZE;
        (+ the number of letters in the chosen array +) = (+ the number of letters in the chosen array +) + WORDSIZE + VM_PrintToBuffer(ct_0+ct_1, INPUT_BUFFER_LEN - ct_1 - WORDSIZE, SayUnderstoodWord, {w});
        (ct_0+ct_1)->0 = ' '; ! now fill with spaces the place where the array's size had landed
        (ct_0+ct_1)->1 = ' ';
        #ifdef TARGET_GLULX;
        (ct_0+ct_1)->2 = ' ';
        (ct_0+ct_1)->3 = ' ';
        #endif; -).
    Include (- [ SayUnderstoodWord word x; print (address) word; ]; -).

    To Parse (input array - a 1-based index based rulebook producing ZSCII letters) into (parsed array - a 1-based index based rulebook producing a struct):
    (- VM_Tokenise({input array}, {parsed array}); -).

    To decide which UNDO reason is the result of saving the game state:
    (- VM_Save_Undo() + 1 -).

    To decide which UNDO reason is the result of carrying out undoing a game turn:
    (- VM_Undo() + 1 -). [ Unused in here, but I included it in case you want to roll your own Undoing action ]