Friday, March 15, 2019

Chapter 9. CLAUSE: Find the Noun Clause Boundaries

  • Arguments: Start address of clause, Preposition number of clause, Vocabulary address of current token
  • Return: Address to start of clause, -1 if no tokens are left to process, or FALSE if error in clause syntax

9.1 Introduction

CLAUSE will find the end address of a noun clause and saves the start and end addresses for this clause along with the preposition information in ITBL. P-NCN (noun clause number) indicates if the direct (1) or indirect (2) object clause is being processed. Specific locations in ITBL for the extracted information to be stored are calculated depending on P-NCN.

Direct Object (Noun 1) Clause
Indirect Object (Noun 2)
Clause
Preposition Number
Word 2
Word 4
Vocabulary Address of Preposition
Word 3
Word 5
Address of First Token (Start)
Word 6
Word 8
Address after Last Token (End)
Word 7
Word 9

9.2 How it screens...

CLAUSE loops through tokens in LEXV as long as the given tokens are part of a valid syntax for a noun clause. Briefly, the routine will
  1. Save any preposition information (number and address) if it exists into the proper locations in ITBL.
  1. The preposition information is usually passed as an argument. CLAUSE will then find the Vocabulary address of the preposition.
  2. If no preposition is given or exists, $00 is saved as the preposition number and address
  1. Save the start address of the noun clause into the proper location in ITBL.
  2. Attempt to get the next token to process as well.
  3. Loop through the tokens in LEXV as long as the given tokens are part of a valid syntax for a noun clause (see rules below)
Once the routine stopped checking for tokens, it can return three possible results: FALSE if there was a syntax error, -1 if no more tokens left to process, or offset to the last token in the newly found clause. The address after the end of the newly found clause will be saved in the proper location in ITBL for the end address of the clause.

Type
Example
Action
Unmatched
Display error & return
Conjunction (“and” or “,”)
Eat apple and orange
Set ANDFLAG & continue
Quantity (“all” or “one”)
Take all bananas
Continue
Quantity (“all” or “one”) + “of”
Burn one of the letters
Skip “of” token & continue
End-of-command
“then” or “.”
Throw hammer then go west
Save end address of current noun clause and return
Preposition (not the first token in the clause)
Put letter inside mailbox
Save end address of current noun clause and return
Noun (also an Adjective) + Noun
Drop gold coin
Continue
Noun and ANDFLAG set
Eat apple and orange and grape
Clear ANDFLAG & continue
Noun and ANDFLAG clear and next token is an exception (“but” or “exception”) or conjunction token
Eat apple and orange
Eat all fruit except banana
Continue
Noun
Turn statue
Save end address of current noun clause & return
Adjective
Read brown book
Continue
Special (not Conjunction, Quantity, or End-of-command)
Push the button
Continue
All others (verbs or direction) and ANDFLAG set
Ignite red match and go east
Change conjunction token to “then” and go back 2 tokens to process again*
All others (verbs or direction) and ANDFLAG clear
Cut rope go north
Display “Can’t Use” error & return
*For example:
        get candle and eat apple
                     ^
is converted to:
        get candle then eat apple
                 ^                
with CLAUSE going back to the conjunction token to reprocess the clause. The routine will recognize “then” as an end-of-command token, marking the end of a clause.

9.3 Update: New Matches…
Later Infocom games added more acceptable token combination for clauses which caused CLAUSE to also grow. Outside of specialized tokens used in specific games (such as spell names in Spellbreaker), the new and improved CLAUSE mainly became more sophisticated on deciding what part of speech a token was being based upon its context with other tokens. The major additional rules created by Infocom are below:
Type
Example
Action
Game
Articles ("the","a","an")
Eat an apple
Skip over token & continue
Deadline
Unmatched
and NUMBER? is true
Take 2 candles
Unmatched token changed to “intnum”, global var set to value, & continue
Deadline
“of” and verb = “accuse”
Accuse Bob of murder
Change “of” to “with” & continue
Deadline
“.” and previous token is a title (“mrs”,”mr”,”ms”, “dr”, “st”)
Ask Mr. Smith about paper
Continue
Deadline, LGOP
Preposition (first token checked)
Throw out ball
Continue
Zork 1-R88
Preposition (prep value already given in argument)
Skip over token & continue
LGOP
Preposition (can also be an adjective) and a prep has already been give
Write on back side
Assume preposition is an adjective and continue
Bureaucracy
Noun (can also be adjective) and next token is noun or adj or direction
Drop gold coin
Take copper hot rod
Assume noun is an adjective & Continue
HGTG, Moonmist
Adjective AND P-MERGED/ P-OFLAG set or verb given
Green
Get Green
Continue
Zork 1-R88
Special (not Conjunction, Quantity, or End-of-command) AND P-MERGED/ P-OFLAG set or verb given
red
Get red
Continue
Zork 1-R88
All others (verb, direction) and ANDFLAG set and verb given
Ignite red match and go east
Change conjunction token to “then” and go back 2 tokens & continue
Seastalker
Profanity, interrogatives
Eat banana who
Display error message & stop
LGOP, Trinity

No comments:

Post a Comment